Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How to do update with GT::SQL?

Quote Reply
How to do update with GT::SQL?
How is possible to do this update using GT::SQL module?
Code:
UPDATE set col_a=col_b WHERE col_a IS NULL
Anybody knows the GT::SQL solution?
Thanks.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to do update with GT::SQL? In reply to
I haven't tested it, but try this:
Code:
my $cond = GT::SQL::Condition->new( col_a => IS => \'NULL' );
$table->update( { col_a => \'col_b' }, $cond );

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] How to do update with GT::SQL? In reply to
Yes, I did also thinking on passing the value parameter as reference (\'col_b'), so the GT::SQL may understand it as field name.
$table->update( { col_a => \'col_b' }, $cond );

Now I remember, that GT::SQL::Table doc says the arguments are quoted, but if are passed as reference, they will be not quoted.

Quote:
quoting in where:
All arguments in the where clause are automatically quoted. If you don't want quotes, you should pass in a scalar reference as in:

my $sth = $obj->select ( { Col => \"NOW()" } );

which turns into ``SELECT * FROM Table WHERE Col = NOW()''.
It is for WHERE clause, so I do not know if same effect works in UPDATE, too.
The doc hasn't any info about UPDATE quoting....
Hopefully will work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to do update with GT::SQL? In reply to
Thanks, Yogi!
$table->update( { col_a => \'col_b' }, $cond ); => Works fine!

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...