[SQL] Boolean to int

2002-07-04 Thread Stephane Schildknecht
Hi, I'd like to get 1 or 0 from a select on a boolean field. How could I do ? I tried the following rule, which I can't insert : CREATE FUNCTION bool_to_int( boolean ) RETURNS integer AS ' DECLARE my_bool ALIAS FOR $1 ; BEGIN -- Retourn

Re: [SQL] how to use nextval()

2002-07-05 Thread Stephane Schildknecht
Le ven 05/07/2002 à 14:03, [EMAIL PROTECTED] a écrit : > Hello there > > I have an idea how to solve my problem on copy a record to a new one in the > same table. To do so I need the next value for the primary key. > > Using : > > select nextval('pk_auftrag') as nextkey from auftrag; > > I get

Re: [SQL] Boolean to int

2002-07-05 Thread Stephane Schildknecht
Le jeu 04/07/2002 à 23:32, Arjen van der Meijden a écrit : > How about this hint in the postgresql-manual: > >"Tip: Values of the boolean type cannot be cast directly to other > types (e.g., CAST (boolval AS integer) does not work). This can be > accomplished using the CASE expression: CAS