ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-database
perl-win32-database
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved