Thread: Casting
Hi, In pgsql I'm removing charaters from a String which should be numbers. I then want to make calculations on these numbers (calculate the ISBN number). Do I have to cast the char into int's before I can do the calulations. Also I looked in the User manual but could not find the modulo function where is it ? tx, Thomas, -- Thu Jan 4 20:19:03 CET 2001 Thomas SMETS e-mail : tsmets@altern.org Av. de la Brabançonne 133 / 3 Tel. : +32 (0)2 742. 05. 94. 1030 Bruxelles ======= Quote of the Day ========= Jealousy is all the fun you think they have. ========= End of Quote ===========
Thomas SMETS writes: > I'm removing charaters from a String which should be numbers. > I then want to make calculations on these numbers (calculate the ISBN > number). (You might want to look into contrib/isbn_issn for an isbn type.) > Do I have to cast the char into int's before I can do the calulations. Depends on the calculation. I'd just try to see if it works. When in doubt add casts. > Also I looked in the User manual but could not find the modulo function > where is it ? 5 % 4 mod(5, 4) -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
Yes. Casts are done like this: SomeFiled::int4 or SomeField::text Double colons is the key '::' --rob ----- Original Message ----- From: "Thomas SMETS" <tsmets@altern.org> To: "psql novice" <pgsql-novice@postgresql.org>; "psql sql" <pgsql-sql@postgresql.org> Sent: Thursday, January 04, 2001 7:31 PM Subject: Casting > > > Hi, > > In pgsql > > I'm removing charaters from a String which should be numbers. > I then want to make calculations on these numbers (calculate the ISBN > number). > > Do I have to cast the char into int's before I can do the calulations. > > Also I looked in the User manual but could not find the modulo function > where is it ? > > tx, > > Thomas, > > > > > > > > > > > > > > -- > Thu Jan 4 20:19:03 CET 2001 > > Thomas SMETS e-mail : tsmets@altern.org > Av. de la Brabançonne 133 / 3 Tel. : +32 (0)2 742. 05. 94. > 1030 Bruxelles > ======= Quote of the Day ========= > Jealousy is all the fun you think they have. > ========= End of Quote =========== >