[Zope-DB] Types between zsql methods and postgresql types
Russell Hires
rhires@earthlink.net
Thu, 5 Sep 2002 09:14:03 -0400
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It works! Thanks so much!
> Use an explicit cast. E.g.,
> insert into condo_tbl (unit_number, bedrooms, bathrooms, sleeps,
> powder_room, linens, weekly_rate, owner_id) values
> ('100', 3, 1, 5,
> 'yes'::boolean, 'no'::boolean, 500::money, 'RH01')
Thank you for this. I knew about the casting, and this answers my question
of exactly how to do it.
> Notes:
>
> Money has been deprecated in postgresql. See section 3.2 of the
> documentation. I do not know if yes/no will cast to boolean, I always
> use 1/0.
Yeah, I got to reading the postgresql docs after I sent my mail, and saw
this. I didn't know how to change the type of the column after I created the
table. I'll stay away from money in the future. ;-) The booleans are read
with "yes" and "no", and come out in the table as 1 or 0.
> You will probably be using variables in the actual application. Then it
> might look like (variable names may be same as, or different from SQL
> column names, both practices are shown below):
And this was even better than I had hoped! I can't say enough about this.
Thanks again.
Russell
> insert into condo_tbl (unit_number, bedrooms, bathrooms, sleeps,
> powder_room, linens, weekly_rate, owner_id) values
> (<dtml-sqlvar unit_number type=string>,
> <dtml-sqlvar bedrooms type=int>,
> <dtml-sqlvvar baths type=int>,
> <dtml-sqlvar sleeps type=string>::boolean,
> <dtml-sqlvar powder_room type=string>::boolean,
> <dtml-sqlvar linens type=string>::boolean,
> <dtml-sqlvar rate type=string>::money,
> <dtml-sqlvar owner type=string>)
>
> Be sure to use sqlvar, or otherwise be sure that there are no SQL
> Injection problems.
>
> Jim Penny
>
- --
Linux -- the OS for the Renaissance Man
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE9d1icAqKGrvVshJQRAl+wAKCxD7KXM95HxZBaNg1bN2fRr1+abgCeLafl
xfNkQN1R7qOA6JiINSzDRhA=
=TvRx
-----END PGP SIGNATURE-----