Re: conversion

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Ken Kline <ken(at)oldbs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: conversion
Date: 2001-02-26 17:06:57
Message-ID: Pine.BSF.4.21.0102260905130.31970-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


It looks like you have some rows for pyear which do
not convert cleanly into a number like ' '. What
do you want it to do in such cases?

On Sun, 25 Feb 2001, Ken Kline wrote:

> follow up....
> actually the destination column is defined
> as a numeric(4)
>
> the following are the statements again with there error messages:
>
> SELECT pseason, to_number(pyear,'9999') from temp;
> ERROR: Bad numeric input format ' '
>
> SELECT pyear::int from temp;
> ERROR: Cannot cast type 'varchar' to 'int4'
>
>
>
>
> Ken Kline wrote:
>
> > Hello,
> > another brain twister, at least for me...
> > i have a table of varchar and one of the values I want
> > to insert into another table, one of the columns is
> > defined as INTEGER in destination table, column...
> > and none of these statements seem to work
> >
> > INSERT INTO pledge_classes (semester, year)
> > SELECT pseason, to_number('pyear','9999') from temp;
> >
> > INSERT INTO pledge_classes (semester, year)
> > SELECT pseason, pyear::integer from temp;
> >
> > INSERT INTO pledge_classes (semester, year)
> > SELECT pseason, pyear::numeric(4) from temp;
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2001-02-26 17:14:18 Re: Need your help
Previous Message Ken Kline 2001-02-26 16:46:49 Re: conversion