Re: Simple SQL help needed
by Chris Winters other posts by this author
Nov 5 1997 9:27AM messages near this date
Simple SQL help needed
|
Perl-Win32-Database FAQ
> I have the below code that I am able to modify the $sql = to retrieve
> (select) a row based on the column USERID in the database. However, I
> need to be able to select one row at a time and call my sub-functions
> and then send $sqlU back to the database. How can I modify my code to
> accomplish this?
Hi James,
Keep in mind that you can have multiple connections to the database
open: just create a new Win32::ODBC object. Untested example:
$dbh = new Win32::ODBC($DSN);
$dbh2 = new Win32::ODBC($DSN);
$people_sql = qq(SELECT * FROM Users);
$dbh-> Sql($people_sql);
while ($dbh-> FetchRow()) {
%data = $dbh-> DataHash();
if ($data{Administration} eq 'Y') {
$update_sql = qq(UPDATE Users SET Message = 'Is Admin!' WHERE
username = '$data{username}');
$dbh2-> Sql($update_sql);
}
}
This way, you can update your rows while still fetching them...
good luck!
Chris Winters
Webmaster (www.irex.org)
cwinters@[...].org
......................................
To leave this list, send an email message to ListManager@[...].com
with the following text in the body: leave Perl-Win32-Database
For support related to the Mailing Lists, send email to ListHelp@[...].com
.
Thread:
Jursch, James
Chris Winters
|