[prev in list] [next in list] [prev in thread] [next in thread] 

List:       msql
Subject:    Re: [mSQL] insert's query using variables in a perl5...
From:       jcoy () arkansas ! net (Coy, John)
Date:       1995-09-02 18:32:09
[Download RAW message or body]

At 08:28 PM 9/2/96 +0100, you wrote:
>Hi, there.:)B
>
>On Sun, 1 Sep 1996, Luis Alberto Vianna Tavares wrote:
>
>> How can I make a insert's query using variables in a perl5 and MsqlPerl ?
>> Like: 
>> INSERT INTO table( field1, field2 ) VALUES ( $var1, $var2 )
>
>As long as you put your query in double quotes, you should be fine. I.e.:
>
>$dbh->$query("INSERT INTO table(field1,field2 ) VALUES ($var1,$var2 )");
>
You'll also have to 'quote' your variables, something like this will do:

$var1 = $dbh->quote($var1);
$var2 = $dbh->quote($var2);
$dbh->query("INSERT INTO table (field1, field2) VALUES ($var1, $var2)");

Presuming $var1 and $var2 are char() type variables.  If they are ints,
then you don't have to quote them at all.

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to msql-list-request@bunyip.com.  Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic