Re: conversion - Mailing list pgsql-sql

From Ken Kline
Subject Re: conversion
Date
Msg-id 3A99D769.94EF54B6@oldbs.com
Whole thread Raw
In response to conversion  (Ken Kline <ken@oldbs.com>)
Responses Re: conversion
Re: conversion
List pgsql-sql
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;



pgsql-sql by date:

Previous
From: Ken Kline
Date:
Subject: conversion
Next
From: Andrew Perrin
Date:
Subject: create function w/indeterminate number of args?