> On Dec 10, 2016, at 11:32 AM, Igor Korot <ikoro...@gmail.com> wrote:
> 
> Hi, guys,
> I'm working thru my script and I hit a following issue:
> 
> In the script I have a following command:
> 
> CREATE TABLE playersinleague(id integer, playerid integer, ishitter
> char, age integer, value decimal, currvalue decimal, draft boolean,
> isnew char(1), current_rank integer, original_rank integer, deleted
> integer, teamid integer, notes varchar(125), PRIMARY KEY(id,playerid),
> foreign key(id) references leagues(id), foreign key(playerid)
> references players(playerid),foreign key(teamid) references
> teams(teamid));
> 
> Now this command finished successfully, however trying to insert a
> record with following command:
> 
> INSERT INTO  playersinleague  
> VALUES(1,1,'1',27,42.0,42.0,0,'0',1,1,0,23,NULL);
> 
> gives following error:
> 
> psql:/Users/igorkorot/draft.schema:10578: ERROR:  column "draft" is of
> type boolean but expression is of type integer
> 
> Looking at https://www.postgresql.org/docs/9.5/static/datatype-numeric.html,
> I don't see a 'boolean' as supported data type.

Booleans aren't numeric.

https://www.postgresql.org/docs/9.5/static/datatype-boolean.html

Boolean will take a range of formats, including '0' - an untyped literal
"0". But it won't take an integer, which is what an unquoted 0 is.

You'll need to modify your insert statement slightly to use a valid boolean
value for that field ("true" or "false" are idiomatic).

Cheers,
  Steve



-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to