DBD::Sybase with freetds -- no statement executing???
Hi, someone please help me. I've just installed freetds, DBI, and DBD::Sybase and this is the first program. --- #! /good_directory_for_perl/perl -w # fttest -- access MS-SQL7 using freetds use strict; use DBI; $ENV{SYBASE} = "/good_direcroty_for_freetds/freetds"; $ENV{LD_LIBRARY_PATH} = $ENV{SYBASE}."/lib"; $ENV{DSQUERY} = "GOOD_SERVERNAME_WHERE_REGISTERED_IN_INTERFACES"; my $db = "gooddatabase"; my $user = "gooduser"; my $pass = "goodpassword"; my $dbh = DBI-connect("dbi:Sybase:database=$db", $user, $pass, {RaiseError = 1, AutoCommit = 1}); my $sth = $dbh-prepare("select * from project where projectname = \"good project\""); $sth-execute(); for (my @row = $sth-fetchrow_array) { print; } $sth-finish(); $dbh-disconnect(); --- And when I submitted this program, only I saw is the mesage follows; no statement executing at /srv/home/fuc/perl/fttest line 19. the line 19 is $sth-execute(); but why? I hope I executed good query properly... Could someone give me any suggetions? Thank you very much in advance! -- fukushi
test Pl delete this mail
* Those who do not understand Unix are condemned to reinvent it, poorly. -- Henry Spencer Unix is user-friendly (it only choose its friends carefully) It will be a long time before you hear me praise NT or any other MS product. I believe that Gates and his empire have done more to lower the standards of our society than anything else in my lifetime. If my product had the same quality as theirs, airplanes would be falling out of the sky hourly. -Robert Schindler, a mechanical engineer *
Passing variables in DBD::Oracle
Hi, I'm new to the list and to the DBI in general. I have "Programming the PERL DBI" -- I'm about 1/2 way through it. I've read the documentation that comes with the DBD::Oracle source, but in both I've yet to find an answer to something. In experimenting with the DBI, I can pass a literal string through $dbh-prepare (ex: $sth = $dbh-prepare( q{ SELECT * FROM ALL_TABLES}); ) That works fine. But, if I assign the literal string to a variable, ($buf = "SELECT * FROM ALL_TABLES"; and pass it through the prepare statement ($sth = $dbh-prepare( $buf ); ) it doesn't work. I turned on debugging to level 5, and what I found was this line: - prepare for DBD::Oracle::db (DBI::db=HASH(0x1c666c)~0x1c66d8 ' $buf ') Why doesn't the variable substitution occur first? I've tried variations with and without quotes, and with \$buf. Nothing seems to work. If there's some documentation I haven't found, or if this is addressed somewhere in the book, please let me know. I don't mean to spam the list with newbie questions, but I'm on a deadline to get up to speed on this. Thanks for the help and insight. Dave Tamillow P.S. While I'm at it, one other thing.How do you issue a DESCRIBE statement through the DBI? I tried $dbh-do(q{ DESCRIBE ALL_TABLES}); and I get the following: DBD::Oracle::db do failed: ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute) at db.pl line 18. I tried $dbh-prepare, but I get basically the same message.
DBD::Oracle for Oraperl scripts
Hi , A simple query. If Oracle is very much required for DBD installtion on a HPUX box, is it possible to run old oraperl scripts to access a remote oracle database (on a different machine) using DBD::Oracle and local Oracle libraries ? If yes , then what are the Oracle components are necessary for DBD::Oracle installation? I have Oracle 7 server (Version 7.3.2.3 Patch) for HPUX and Oracle 7.1.6 bundle with me. Are they enough to have a right environment for DBD::oracle? Regards, S Bala --- FREE! The World's Best Email Address @email.com Reserve your name now at http://www.email.com
Re: Oracle call just hangs...
On Thu, Apr 05, 2001 at 10:53:40PM +, sara starre wrote: We use the DBI for all sorts of MYSQL and Oracle queries, but today something happened I never saw before. I do a prepare of a legitimate UPDATE query (I tested it on thew SQLPLUS prompt and it ran fine). But when I call it from the DBI, the $dbh-do statement never returns. In the same script are of dozens of other queries which all seem to run to completion just fine. Could there ever be a cause for this behavior other than the system is somehow weirding out? The update should return 15 rows affected in this case. If it fails it should return right? It acts as if the $dbh-do goes into a while (1) {} Did you commit or rollback in SQLPLUS after testing the query? If not, then the DBI update is waiting for the lock on the table to be released. I've been caught by this one several times. :) Ronald
DBD::Oracle 64-bit perl
It would seem that after I recompiled perl as 64 bit instead of 32, the problems I was having with binding of NULLs in DBD::Oracle disappeared. David Nicklay Systems Engineer II [EMAIL PROTECTED] CNN - SW1025J
Re: DBD::Sybase with freetds -- no statement executing???
fukushi wrote: #! /good_directory_for_perl/perl -w # fttest -- access MS-SQL7 using freetds use strict; use DBI; $ENV{SYBASE} = "/good_direcroty_for_freetds/freetds"; $ENV{LD_LIBRARY_PATH} = $ENV{SYBASE}."/lib"; I believe, that you can't set the LD_LIBRARY_PATH variable this way (just from within of you Perl-script and without any forking), so you should set this variable in the UNIX shell (or in httpd.conf of Apache). I haven't used freetds, so I can't comment on your other problems...
[Fwd: Passing variables in DBD::Oracle]
Never mind on the variable substitution question. I found my problem. I wasn't using the q and qq functions properly to make sure the variable was set up correctly. I am still curious about the DESCRIBE call, though. Thanks! Dave Tamillow Original Message Subject: Passing variables in DBD::Oracle Date: Fri, 06 Apr 2001 08:12:55 -0400 From: Dave Tamillow [EMAIL PROTECTED] To: [EMAIL PROTECTED] Hi, I'm new to the list and to the DBI in general. I have "Programming the PERL DBI" -- I'm about 1/2 way through it. I've read the documentation that comes with the DBD::Oracle source, but in both I've yet to find an answer to something. In experimenting with the DBI, I can pass a literal string through $dbh-prepare (ex: $sth = $dbh-prepare( q{ SELECT * FROM ALL_TABLES}); ) That works fine. But, if I assign the literal string to a variable, ($buf = "SELECT * FROM ALL_TABLES"; and pass it through the prepare statement ($sth = $dbh-prepare( $buf ); ) it doesn't work. I turned on debugging to level 5, and what I found was this line: - prepare for DBD::Oracle::db (DBI::db=HASH(0x1c666c)~0x1c66d8 ' $buf ') Why doesn't the variable substitution occur first? I've tried variations with and without quotes, and with \$buf. Nothing seems to work. If there's some documentation I haven't found, or if this is addressed somewhere in the book, please let me know. I don't mean to spam the list with newbie questions, but I'm on a deadline to get up to speed on this. Thanks for the help and insight. Dave Tamillow P.S. While I'm at it, one other thing.How do you issue a DESCRIBE statement through the DBI? I tried $dbh-do(q{ DESCRIBE ALL_TABLES}); and I get the following: DBD::Oracle::db do failed: ORA-00900: invalid SQL statement (DBD ERROR: OCIStmtExecute) at db.pl line 18. I tried $dbh-prepare, but I get basically the same message.
Re: DBD-Sybase make test problem?
When reporting problems with using the FreeTDS client libraries you should in general start with asking your questions on the FreeTDS mailing list. See http://www.freetds.org for details. Michael fukushi writes: Hi again. From: fukushi [EMAIL PROTECTED] Subject: DBD-Sybase make test problem? I installed DBD-Sybase but I encountered a problem when "make test". But the testting stopped after saying; PERL_DL_NONLAZY=1 ../bin/perl -Iblib/arch -Iblib/lib -I/somedir/lib/perl5/5.6.0/i386-freebsd -I/somedir/lib/perl5/5.6.0 -e 'use Te st::Harness qw(runtests $verbose); $verbose=1; runtests @ARGV;' t/*.t t/autocommit1..4 ok! 1 I'm afraid the process is stopping at the following line of t/autocommit.t; my $dbh = DBI-connect("dbi:Sybase:server=$Srv", $Uid, $Pwd, {PrintError = 0}); Sorry to bother you. Somehow I could solve this problem by myself. I surrendered to use /usr/local/freetds that root had installed for me and I installed freetsd under my private directory, and rebuit DBI and DBD-Sybase, and did "make test". The test succeeded 50%. I don't know it's enough or not but MS SQL captured the query. So I would struggle with DBD/DBI/Perl. Thank you. -- Michael Peppler - Data Migrations Inc. - [EMAIL PROTECTED] http://www.mbay.net/~mpeppler - [EMAIL PROTECTED] International Sybase User Group - http://www.isug.com Sybase on Linux mailing list: [EMAIL PROTECTED]
Re: DBD::Sybase with freetds -- no statement executing???
Hi. this is fukushi struggling with FreeTDS/DBD-Sybase. From: "Alexander Farber \(EED\)" [EMAIL PROTECTED] Subject: Re: DBD::Sybase with freetds -- no statement executing??? Date: Fri, 06 Apr 2001 15:43:27 +0200 Message-ID: [EMAIL PROTECTED] fukushi wrote: #! /good_directory_for_perl/perl -w # fttest -- access MS-SQL7 using freetds use strict; use DBI; $ENV{SYBASE} = "/good_direcroty_for_freetds/freetds"; $ENV{LD_LIBRARY_PATH} = $ENV{SYBASE}."/lib"; I believe, that you can't set the LD_LIBRARY_PATH variable this way (just from within of you Perl-script and without any forking), so you should set this variable in the UNIX shell (or in httpd.conf of Apache). Thank you Alexander! This is console script and I set these variables in the .bashrc so these two statements are overlapping and needless. Anyway, the script doesn't work. As Micheal suggested, (Thank you! Micheal) I will also ask my question to FreeTDS ML. Thanks anyway. -- fukushi
Re: DBD::Sybase with freetds -- no statement executing???
Yes, you can set LD_LIBRARY_PATH within the script and it should pick up the correct path. It is standard with all of the DBI scripts accessing Sybase in our shop... normally the path is in an ini file, the ini file is read and the ENV variable set. We do this since the same account may be executing the same set of scripts but from different environments. As far as the code that is attempting to connect to the DB (where it was failing on $sth-execute())... I couldn't see anything outwardly wrong with it. Since there were problems installing FreeTDS, I suspect the problem starts there. --Good Luck Curt On Fri, 6 Apr 2001, Alexander Farber (EED) wrote: fukushi wrote: #! /good_directory_for_perl/perl -w # fttest -- access MS-SQL7 using freetds use strict; use DBI; $ENV{SYBASE} = "/good_direcroty_for_freetds/freetds"; $ENV{LD_LIBRARY_PATH} = $ENV{SYBASE}."/lib"; I believe, that you can't set the LD_LIBRARY_PATH variable this way (just from within of you Perl-script and without any forking), so you should set this variable in the UNIX shell (or in httpd.conf of Apache). I haven't used freetds, so I can't comment on your other problems...
Script Hangs when executing ...
Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? here is the script ... !/usr/bin/sybaseperl $ENV{'SYBASE'}="/opt/sybase"; $ENV{'DSQUERY'}="rodopi"; use DBI; use Date::Manip; use Date::Format; $tomorrow = time2str("%h %d %Y", UnixDate(ParseDate("tomorrow"),"%s")); $todaystring = ParseDate("today"); $today = time2str("%m/%d/%Y", UnixDate(ParseDate("today"),"%s")); $thismonth = time2str("%m/01/%Y", UnixDate(ParseDate("today"),"%s")); $lastmonth = time2str("%m/01/%Y", UnixDate(ParseDate("lastmonth"),"%s")); $charge = 3; $extracharge = 0; $duration = 6; $tax = 1.07; $dbh = DBI-connect("dbi:Sybase:database=X", "XX", "XXX"); $sql = _ENDSQL; SELECT Customers.CustomerID, Plans.PlanID, Emails.PopName, Emails.EmailAddress, Emails.Password FROM Plans INNER JOIN Customers ON Plans.CustomerID = Customers.CustomerID INNER JOIN Emails ON Plans.PlanID = Emails.PlanID WHERE Emails.PopName="$emailname" AND Emails.EmailAddress="$email" AND Emails.Password="$password" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; while (@detail = $sth-fetchrow_array) { $custid = $detail[0]; $emailid = $detail[1]; $popname = $detail[2]; $address = $detail[3]; $password = $detail[4]; $realname = $detail[5]; print "Custid : $custid\n"; print "EmailId : $emailid\n"; print "address : $address\n"; print "Popname : $popname\n"; print "Password: $password\n"; print "Real: $real\n"; print "Today : $today\n"; } #--- # Insert Plan $exec = qq{ Exec Subscribe_InsertPlan $custid,136,6,11,"$today"}; $sth2 = $dbh-prepare($exec); $sth2-execute || warn $sth2-errstr; #--- # Find New Plan Id $sql3 = _ENDSQL; SELECT Plans.PlanID, Plans.CustomerID, Plans.PlanInfoID, Plans.Closed FROM Plans WHERE Plans.CustomerID=$custid AND Plans.PlanInfoID=136 AND Plans.Closed = 0 _ENDSQL $sth3 = $dbh-prepare($sql3); $sth3-execute || warn $sth3-errstr; while (@detail = $sth3-fetchrow_array) { $planid = $detail[0]; $custid2 = $detail[1]; $planinfoid = $detail[2]; } print "PlanID : $planid\n"; print "CustID : $custid2\n"; print "PlanInfo: $planinfoid\n"; #-- #Set the next billing date $sql4 = _ENDSQL; INSERT INTO PlansBillState (PlanID, UnitTypeID, LastBillDate, NextBillDate) VALUES ($planid, 2, "$today", "07/01/2001") _ENDSQL $sth4 = $dbh-prepare($sql4); $sth4-execute || warn $sth4-errstr; #-- # Add a email login to virus scan table $exec5 = qq{ Exec Subscribe_InsertLogins $planid, "$popname", "$password"}; $sth5 = $dbh-prepare($exec5); $sth5-execute || warn $sth5-errstr; #--- # Add Debit to account $extracharge = ($charge * $duration) * $tax; $exec6 = qq{ Exec Bill_AddDebit $planid,2,"$today",$extracharge,"EMail Virus Scanning","$thismonth" $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-disconnect || print "$DBI::errstr $DBI::err\n";
Re: Script Hangs when executing ...
What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-trace(3); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; -- Thomas A. Lowery See DBI/FAQ http://tlowery.hypermart.net _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: Script Hangs when executing ...
Still just hangs after the last destory? (Also, keep the dbi-users mail list in the replies, the Sybase gurus are there.) Tom On Fri, Apr 06, 2001 at 01:03:52PM -0400, Jamie Orzechowski wrote: with tace 9 I get DBI::db=HASH(0x80efd9c) trace level set to 9 in DBI 1.14-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x80efdc0)~0x80efd9c) DBI::db=HASH(0x80efd9c)-disconnect invalidates 3 active statement handles (either destroy statement handles or call finish on them before disconnecting) at ./addplan line 107. syb_db_disconnect() - ct_close() - disconnect= 1 at ./addplan line 107. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd9c)~INNER) - DESTROY= undef during global destruction. any ideas?? - Original Message - From: "Thomas A. Lowery" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 12:55 PM Subject: Re: Script Hangs when executing ... What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-trace(3); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
RE: Script Hangs when executing ...
try $sthX-finish after execute when you do not need the $sthX anymore. -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED]] Sent: 6. april 2001 19:25 To: Jamie Orzechowski Cc: DBI-Users Subject: Re: Script Hangs when executing ... Still just hangs after the last destory? (Also, keep the dbi-users mail list in the replies, the Sybase gurus are there.) Tom On Fri, Apr 06, 2001 at 01:03:52PM -0400, Jamie Orzechowski wrote: with tace 9 I get DBI::db=HASH(0x80efd9c) trace level set to 9 in DBI 1.14-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x80efdc0)~0x80efd9c) DBI::db=HASH(0x80efd9c)-disconnect invalidates 3 active statement handles (either destroy statement handles or call finish on them before disconnecting) at ./addplan line 107. syb_db_disconnect() - ct_close() - disconnect= 1 at ./addplan line 107. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd9c)~INNER) - DESTROY= undef during global destruction. any ideas?? - Original Message - From: "Thomas A. Lowery" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 12:55 PM Subject: Re: Script Hangs when executing ... What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-trace(3); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: Oracle call just hangs...
Yes I did the COMMIT in SQLPLUS. Odd.. ! Anyhow, inexpliquably when I came in this morning the code worked fivers. No problems at all.. Go figure! This "Oracle" is more like a game of chance then a predictable engine. Thanks for the tips! -PG From: Ronald J Kimball [EMAIL PROTECTED] To: sara starre [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: Oracle call just hangs... Date: Fri, 6 Apr 2001 09:29:01 -0400 On Thu, Apr 05, 2001 at 10:53:40PM +, sara starre wrote: We use the DBI for all sorts of MYSQL and Oracle queries, but today something happened I never saw before. I do a prepare of a legitimate UPDATE query (I tested it on thew SQLPLUS prompt and it ran fine). But when I call it from the DBI, the $dbh-do statement never returns. In the same script are of dozens of other queries which all seem to run to completion just fine. Could there ever be a cause for this behavior other than the system is somehow weirding out? The update should return 15 rows affected in this case. If it fails it should return right? It acts as if the $dbh-do goes into a while (1) {} Did you commit or rollback in SQLPLUS after testing the query? If not, then the DBI update is waiting for the lock on the table to be released. I've been caught by this one several times. :) Ronald _ Get your FREE download of MSN Explorer at http://explorer.msn.com
Re: Script Hangs when executing ...
I tried sthX-finish and I get the same hangs ... I am split the script into seperate scripts and I run each part manually ... Even with the following script I get a hang ... if I insert sth-finish; then the script will hang ... If I remove it then script will run but I get the error DBI::db=HASH(0x80efd18) trace level set to 9 in DBI 1.14-nothread Can't locate object method "disconnect" via package "DBI::st" at ./test line 34. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd18)~INNER) syb_db_disconnect() - ct_close() - DESTROY= undef during global destruction. #- #script $dbh = DBI-connect("dbi:Sybase:database=xx", "x", ""); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"$today" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; $dbh-trace(9); $dbh-disconnect; - Original Message - From: "Hans Foght" [EMAIL PROTECTED] To: "'Thomas A. Lowery'" [EMAIL PROTECTED]; "Jamie Orzechowski" [EMAIL PROTECTED] Cc: "DBI-Users" [EMAIL PROTECTED] Sent: Friday, April 06, 2001 1:22 PM Subject: RE: Script Hangs when executing ... try $sthX-finish after execute when you do not need the $sthX anymore. -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED]] Sent: 6. april 2001 19:25 To: Jamie Orzechowski Cc: DBI-Users Subject: Re: Script Hangs when executing ... Still just hangs after the last destory? (Also, keep the dbi-users mail list in the replies, the Sybase gurus are there.) Tom On Fri, Apr 06, 2001 at 01:03:52PM -0400, Jamie Orzechowski wrote: with tace 9 I get DBI::db=HASH(0x80efd9c) trace level set to 9 in DBI 1.14-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x80efdc0)~0x80efd9c) DBI::db=HASH(0x80efd9c)-disconnect invalidates 3 active statement handles (either destroy statement handles or call finish on them before disconnecting) at ./addplan line 107. syb_db_disconnect() - ct_close() - disconnect= 1 at ./addplan line 107. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd9c)~INNER) - DESTROY= undef during global destruction. any ideas?? - Original Message - From: "Thomas A. Lowery" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 12:55 PM Subject: Re: Script Hangs when executing ... What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-trace(3); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Re: Script Hangs when executing ...
If Perl DBI is saying it can't find disconnect, then I would think either $dbh somehow gets undef'd or maybe your disconnect method is missing. I've run into this before where my disconnect method was "missing". It may be you just need to reinstall DBI, which is what my sysadmin did. Why disconnect was missing... who knows??? It may also be that we needed to reinstall the DBD::Sybase driver and possibly the db client libraries... it was a while ago and I do not remember. Is that the WHOLE script or just the section that deals with the db? On Fri, 6 Apr 2001, Jamie Orzechowski wrote: I tried sthX-finish and I get the same hangs ... I am split the script into seperate scripts and I run each part manually ... Even with the following script I get a hang ... if I insert sth-finish; then the script will hang ... If I remove it then script will run but I get the error DBI::db=HASH(0x80efd18) trace level set to 9 in DBI 1.14-nothread Can't locate object method "disconnect" via package "DBI::st" at ./test line 34. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd18)~INNER) syb_db_disconnect() - ct_close() - DESTROY= undef during global destruction. #- #script $dbh = DBI-connect("dbi:Sybase:database=xx", "x", ""); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"$today" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; $dbh-trace(9); $dbh-disconnect; - Original Message - From: "Hans Foght" [EMAIL PROTECTED] To: "'Thomas A. Lowery'" [EMAIL PROTECTED]; "Jamie Orzechowski" [EMAIL PROTECTED] Cc: "DBI-Users" [EMAIL PROTECTED] Sent: Friday, April 06, 2001 1:22 PM Subject: RE: Script Hangs when executing ... try $sthX-finish after execute when you do not need the $sthX anymore. -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED]] Sent: 6. april 2001 19:25 To: Jamie Orzechowski Cc: DBI-Users Subject: Re: Script Hangs when executing ... Still just hangs after the last destory? (Also, keep the dbi-users mail list in the replies, the Sybase gurus are there.) Tom On Fri, Apr 06, 2001 at 01:03:52PM -0400, Jamie Orzechowski wrote: with tace 9 I get DBI::db=HASH(0x80efd9c) trace level set to 9 in DBI 1.14-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x80efdc0)~0x80efd9c) DBI::db=HASH(0x80efd9c)-disconnect invalidates 3 active statement handles (either destroy statement handles or call finish on them before disconnecting) at ./addplan line 107. syb_db_disconnect() - ct_close() - disconnect= 1 at ./addplan line 107. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd9c)~INNER) - DESTROY= undef during global destruction. any ideas?? - Original Message - From: "Thomas A. Lowery" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 12:55 PM Subject: Re: Script Hangs when executing ... What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 = $dbh-prepare($exec6); $sth6-execute || warn $sth6-errstr; $dbh-trace(3); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
DBI::ODBC on Windows 2000 (IIS) Oracle Problem
Hello all, I have been attempting to use DBI::ODBC on a windows 2000 machine running IIS to connect to an Oracle database on a Unix machine. I have set up the DSN for the ODBC connection and I can actually get a connection to the database and retrieve data when I call cgi page from a command line. However, when I call the cgi from an html page the call to the database just hangs the web browser. If I take out the connection calls, the cgi page loads correctly. I feel that this is an error that is happening because of either security reasons or because how IIS forks off the process when calling the database. If some one could give me some advice on what might be happening and how to fix it I would greatly appreciate it. Here is my connection code: (again, this code does work when I run script command line just not when running as cgi) use DBI; my $dbh = DBI-connect("dbi:ODBC:dsnname", "username", "pswd"); my $sth = $dbh-prepare("Select * from table"); $sth-execute or die "Can't execute SELECT statement"; while (@row = $sth-fetchrow_array ) { print "@row \n"; } $sth-finish(); $dbh-disconnect(); TIA, Bob Reuss
Re: Script Hangs when executing ...
Looks like it's parts of the script that execute stored procedures ... This works fine $dbh = DBI-connect("dbi:Sybase:database=xxx", "", "x"); $sql = _ENDSQL; SELECT Customers.CustomerID, Plans.PlanID, Emails.PopName, Emails.EmailAddress, Emails.Password FROM Plans INNER JOIN Customers ON Plans.CustomerID = Customers.CustomerID INNER JOIN Emails ON Plans.PlanID = Emails.PlanID WHERE Emails.PopName="$userid" AND Emails.EmailAddress="$address" AND Emails.Password="$pass" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute; while (@detail = $sth-fetchrow_array) { $custid = $detail[0]; $emailid = $detail[1]; $popname = $detail[2]; $address = $detail[3]; $password = $detail[4]; $realname = $detail[5]; print "Custid : $custid\n"; print "EmailId : $emailid\n"; print "address : $address\n"; print "Popname : $popname\n"; print "Password: $password\n"; print "Today : $today\n"; } $dbh-trace(9); $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; This Fails (hangs)... $exec = qq{ Exec Subscribe_InsertPlan $custid,136,6,11,"$today"}; $sth2 = $dbh-prepare($exec); $sth2-execute; - Original Message - From: "Curt Russell Crandall" [EMAIL PROTECTED] To: "Jamie Orzechowski" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 2:26 PM Subject: Re: Script Hangs when executing ... If Perl DBI is saying it can't find disconnect, then I would think either $dbh somehow gets undef'd or maybe your disconnect method is missing. I've run into this before where my disconnect method was "missing". It may be you just need to reinstall DBI, which is what my sysadmin did. Why disconnect was missing... who knows??? It may also be that we needed to reinstall the DBD::Sybase driver and possibly the db client libraries... it was a while ago and I do not remember. Is that the WHOLE script or just the section that deals with the db? On Fri, 6 Apr 2001, Jamie Orzechowski wrote: I tried sthX-finish and I get the same hangs ... I am split the script into seperate scripts and I run each part manually ... Even with the following script I get a hang ... if I insert sth-finish; then the script will hang ... If I remove it then script will run but I get the error DBI::db=HASH(0x80efd18) trace level set to 9 in DBI 1.14-nothread Can't locate object method "disconnect" via package "DBI::st" at ./test line 34. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd18)~INNER) syb_db_disconnect() - ct_close() - DESTROY= undef during global destruction. #- #script $dbh = DBI-connect("dbi:Sybase:database=xx", "x", ""); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"$today" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; $dbh-trace(9); $dbh-disconnect; - Original Message - From: "Hans Foght" [EMAIL PROTECTED] To: "'Thomas A. Lowery'" [EMAIL PROTECTED]; "Jamie Orzechowski" [EMAIL PROTECTED] Cc: "DBI-Users" [EMAIL PROTECTED] Sent: Friday, April 06, 2001 1:22 PM Subject: RE: Script Hangs when executing ... try $sthX-finish after execute when you do not need the $sthX anymore. -Original Message- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED]] Sent: 6. april 2001 19:25 To: Jamie Orzechowski Cc: DBI-Users Subject: Re: Script Hangs when executing ... Still just hangs after the last destory? (Also, keep the dbi-users mail list in the replies, the Sybase gurus are there.) Tom On Fri, Apr 06, 2001 at 01:03:52PM -0400, Jamie Orzechowski wrote: with tace 9 I get DBI::db=HASH(0x80efd9c) trace level set to 9 in DBI 1.14-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x80efdc0)~0x80efd9c) DBI::db=HASH(0x80efd9c)-disconnect invalidates 3 active statement handles (either destroy statement handles or call finish on them before disconnecting) at ./addplan line 107. syb_db_disconnect() - ct_close() - disconnect= 1 at ./addplan line 107. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x80efd9c)~INNER) - DESTROY= undef during global destruction. any ideas?? - Original Message - From: "Thomas A. Lowery" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 12:55 PM Subject: Re: Script Hangs when executing ... What does trace say? ($dbh-trace(1-9) just before the disconnect). Tom On Fri, Apr 06, 2001 at 12:25:51PM -0400, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? ... snip $sth6 =
Re: Script Hangs when executing ...
On Fri, Apr 06, 2001 at 02:13:17PM -0400, Jamie Orzechowski wrote: I tried sthX-finish and I get the same hangs ... I am split the script into seperate scripts and I run each part manually ... Even with the following script I get a hang ... if I insert sth-finish; then the script will hang ... If I remove it then script will run but I get the error DBI::db=HASH(0x80efd18) trace level set to 9 in DBI 1.14-nothread Can't locate object method "disconnect" via package "DBI::st" at ./test line 34. This error occured because you called disconnect on a statement handle rather than on the database handle. I note that the code snippet you posted below isn't close to 34 lines long; what is the actual code you used to produce this error? Ronald #- #script $dbh = DBI-connect("dbi:Sybase:database=xx", "x", ""); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"$today" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; $dbh-trace(9); $dbh-disconnect;
Re: Script Hangs when executing ...
On Fri, Apr 06, 2001 at 02:26:31PM -0400, Curt Russell Crandall wrote: If Perl DBI is saying it can't find disconnect, then I would think either Perl is saying that it can't find the disconnect method in the DBI::st package. That's the statement handle package. The disconnect method is in the DBI package. The solution is to call disconnect on the database handle object rather than a statement handle object. $dbh somehow gets undef'd or maybe your disconnect method is missing. I've run into this before where my disconnect method was "missing". It may be you just need to reinstall DBI, which is what my sysadmin did. Why disconnect was missing... who knows??? It may also be that we needed to reinstall the DBD::Sybase driver and possibly the db client libraries... it was a while ago and I do not remember. I'm afraid that these approaches would not solve this problem. Ronald
Re: Script Hangs when executing ...
can you give me a quick snippet of code to disconnect on the database object? - Original Message - From: "Ronald J Kimball" [EMAIL PROTECTED] To: "Curt Russell Crandall" [EMAIL PROTECTED] Cc: "Jamie Orzechowski" [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, April 06, 2001 2:33 PM Subject: Re: Script Hangs when executing ... On Fri, Apr 06, 2001 at 02:26:31PM -0400, Curt Russell Crandall wrote: If Perl DBI is saying it can't find disconnect, then I would think either Perl is saying that it can't find the disconnect method in the DBI::st package. That's the statement handle package. The disconnect method is in the DBI package. The solution is to call disconnect on the database handle object rather than a statement handle object. $dbh somehow gets undef'd or maybe your disconnect method is missing. I've run into this before where my disconnect method was "missing". It may be you just need to reinstall DBI, which is what my sysadmin did. Why disconnect was missing... who knows??? It may also be that we needed to reinstall the DBD::Sybase driver and possibly the db client libraries... it was a while ago and I do not remember. I'm afraid that these approaches would not solve this problem. Ronald
Re: Script Hangs when executing ...
same error Name "main::charge" used only once: possible typo at ./test line 11. DBI::db=HASH(0x81ce7d8) trace level set to 9 in DBI 1.15-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x81ce82c)~0x81ce7d8) DBI::db=HASH(0x81ce7d8)-disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ./test line 25. syb_db_disconnect() - ct_close() - disconnect= 1 at ./test line 25. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x81ce7d8)~INNER) - DESTROY= undef during global destruction. -- $dbh = DBI-connect("dbi:Sybase:database=xxx", "x", "x"); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"04/06/2001" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute; $dbh-trace(9); $dbh-disconnect() or die("$DBI::errstr $DBI::err\n"); - Original Message - From: "Curt Russell Crandall" [EMAIL PROTECTED] To: "Jamie Orzechowski" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 2:37 PM Subject: Re: Script Hangs when executing ... I don't know if this will help, but try changing $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; to $dbh-disconnect() or die("$DBI::errstr $DBI::err\n"); I'm probably wrong, but if something is wrong with disconnect, but not 'die'ing, you might be causing it to hang on the print. Since disconnect is at the very end of your script and a failure in disconnect probably indicates something serious... I'd just let it die. On Fri, 6 Apr 2001, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? here is the script ... !/usr/bin/sybaseperl $ENV{'SYBASE'}="/opt/sybase"; $ENV{'DSQUERY'}="rodopi"; use DBI; use Date::Manip; use Date::Format; $tomorrow = time2str("%h %d %Y", UnixDate(ParseDate("tomorrow"),"%s")); $todaystring = ParseDate("today"); $today = time2str("%m/%d/%Y", UnixDate(ParseDate("today"),"%s")); $thismonth = time2str("%m/01/%Y", UnixDate(ParseDate("today"),"%s")); $lastmonth = time2str("%m/01/%Y", UnixDate(ParseDate("lastmonth"),"%s")); $charge = 3; $extracharge = 0; $duration = 6; $tax = 1.07; $dbh = DBI-connect("dbi:Sybase:database=X", "XX", "XXX"); $sql = _ENDSQL; SELECT Customers.CustomerID, Plans.PlanID, Emails.PopName, Emails.EmailAddress, Emails.Password FROM Plans INNER JOIN Customers ON Plans.CustomerID = Customers.CustomerID INNER JOIN Emails ON Plans.PlanID = Emails.PlanID WHERE Emails.PopName="$emailname" AND Emails.EmailAddress="$email" AND Emails.Password="$password" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; while (@detail = $sth-fetchrow_array) { $custid = $detail[0]; $emailid = $detail[1]; $popname = $detail[2]; $address = $detail[3]; $password = $detail[4]; $realname = $detail[5]; print "Custid : $custid\n"; print "EmailId : $emailid\n"; print "address : $address\n"; print "Popname : $popname\n"; print "Password: $password\n"; print "Real: $real\n"; print "Today : $today\n"; } #--- # Insert Plan $exec = qq{ Exec Subscribe_InsertPlan $custid,136,6,11,"$today"}; $sth2 = $dbh-prepare($exec); $sth2-execute || warn $sth2-errstr; #--- # Find New Plan Id $sql3 = _ENDSQL; SELECT Plans.PlanID, Plans.CustomerID, Plans.PlanInfoID, Plans.Closed FROM Plans WHERE Plans.CustomerID=$custid AND Plans.PlanInfoID=136 AND Plans.Closed = 0 _ENDSQL $sth3 = $dbh-prepare($sql3); $sth3-execute || warn $sth3-errstr; while (@detail = $sth3-fetchrow_array) { $planid = $detail[0]; $custid2 = $detail[1]; $planinfoid = $detail[2]; } print "PlanID : $planid\n"; print "CustID : $custid2\n"; print "PlanInfo: $planinfoid\n"; #-- #Set the next billing date $sql4 = _ENDSQL; INSERT INTO PlansBillState (PlanID, UnitTypeID, LastBillDate, NextBillDate) VALUES ($planid, 2, "$today", "07/01/2001") _ENDSQL $sth4 = $dbh-prepare($sql4); $sth4-execute || warn $sth4-errstr; #-- # Add a email login to virus scan table $exec5 = qq{ Exec Subscribe_InsertLogins $planid, "$popname", "$password"}; $sth5 = $dbh-prepare($exec5); $sth5-execute || warn $sth5-errstr; #--- #
Re: Script Hangs when executing ...
It doesn't appear that this should happen, though, since $dbh is the database handle ($dbh = DBI-connect()) and disconnect is called by $dbh-disconnect. From the code given, the DBI::st should not be complaining about this. This is an error similar to what I received a while ago using Sybase and Perl 5.005_03/DBI 1.13... it was corrected by reinstalling at least DBI. If this is only a problem when calling a stored proc, then I'm lost. I know DBD::Sybase won't deal with calls to sp's with placeholders... this doesn't appear to be the problem here. On Fri, 6 Apr 2001, Ronald J Kimball wrote: On Fri, Apr 06, 2001 at 02:26:31PM -0400, Curt Russell Crandall wrote: If Perl DBI is saying it can't find disconnect, then I would think either Perl is saying that it can't find the disconnect method in the DBI::st package. That's the statement handle package. The disconnect method is in the DBI package. The solution is to call disconnect on the database handle object rather than a statement handle object. $dbh somehow gets undef'd or maybe your disconnect method is missing. I've run into this before where my disconnect method was "missing". It may be you just need to reinstall DBI, which is what my sysadmin did. Why disconnect was missing... who knows??? It may also be that we needed to reinstall the DBD::Sybase driver and possibly the db client libraries... it was a while ago and I do not remember. I'm afraid that these approaches would not solve this problem. Ronald
Re: Script Hangs when executing ...
On Fri, Apr 06, 2001 at 03:03:30PM -0400, Curt Russell Crandall wrote: It doesn't appear that this should happen, though, since $dbh is the database handle ($dbh = DBI-connect()) and disconnect is called by $dbh-disconnect. From the code given, the DBI::st should not be complaining about this. This is an error similar to what I received a while ago using Sybase and Perl 5.005_03/DBI 1.13... it was corrected by reinstalling at least DBI. The code given was not the actual code that was used to generate the error. This was clear because the error message was for ./test.pl line 34, but the code given was only 10 lines long. :) Anyway, Jamie just sent me his script privately; line 34 was: $sth-disconnect; Ronald
Re: DBD::Sybase with freetds -- no statement executing???
Setting LD_LIBRARY_PATH inside a Perl script works in some platforms and doesn't in others. I'm not sure which are which, so I try real hard to have all the environment variables set before the script starts. -- Mac :}) ** I normally forward private database questions to the DBI mail lists. ** Give a hobbit a fish and he'll eat fish for a day. Give a hobbit a ring and he'll eat fish for an age. - Original Message - From: "Curt Russell Crandall" [EMAIL PROTECTED] To: "Alexander Farber (EED)" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 8:58 AM Subject: Re: DBD::Sybase with freetds -- no statement executing??? Yes, you can set LD_LIBRARY_PATH within the script and it should pick up the correct path. It is standard with all of the DBI scripts accessing Sybase in our shop... normally the path is in an ini file, the ini file is read and the ENV variable set. We do this since the same account may be executing the same set of scripts but from different environments.
Re: Script Hangs when executing ...
Have you tried running this through the debugger to see where exactly the problem is occurring. Have you also tried running the stored proc in isql (or what ever M$SQL calls it) to make sure the stored proc is OK? The error message below indicates that your statement handle is still active... you said you used finish() on this, right? I don't know about M$SQL, but in Sybase it is sometimes helpful to loop through the result set completely (look in the DBD::Sybase perldoc for the code). The small snippet of code you have looks like the syntax is correct, so I'd look at the stored proc and then try to make sure that the statement handle is not active by finishing it or making sure all the results have been returned. On Fri, 6 Apr 2001, Jamie Orzechowski wrote: same error Name "main::charge" used only once: possible typo at ./test line 11. DBI::db=HASH(0x81ce7d8) trace level set to 9 in DBI 1.15-nothread - disconnect for DBD::Sybase::db (DBI::db=HASH(0x81ce82c)~0x81ce7d8) DBI::db=HASH(0x81ce7d8)-disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ./test line 25. syb_db_disconnect() - ct_close() - disconnect= 1 at ./test line 25. - DESTROY for DBD::Sybase::db (DBI::db=HASH(0x81ce7d8)~INNER) - DESTROY= undef during global destruction. -- $dbh = DBI-connect("dbi:Sybase:database=xxx", "x", "x"); $sql = _ENDSQL; Exec Subscribe_InsertPlan 13200,136,6,11,"04/06/2001" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute; $dbh-trace(9); $dbh-disconnect() or die("$DBI::errstr $DBI::err\n"); - Original Message - From: "Curt Russell Crandall" [EMAIL PROTECTED] To: "Jamie Orzechowski" [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, April 06, 2001 2:37 PM Subject: Re: Script Hangs when executing ... I don't know if this will help, but try changing $dbh-disconnect || print "$DBI::errstr $DBI::err\n"; to $dbh-disconnect() or die("$DBI::errstr $DBI::err\n"); I'm probably wrong, but if something is wrong with disconnect, but not 'die'ing, you might be causing it to hang on the print. Since disconnect is at the very end of your script and a failure in disconnect probably indicates something serious... I'd just let it die. On Fri, 6 Apr 2001, Jamie Orzechowski wrote: Hello ... I have a script which connected to a MS SQL database ... it hangs right at the end of the script ... if I check my database it DOES insert all the information correctly ... it just hangs and never exits ... any ideas?? here is the script ... !/usr/bin/sybaseperl $ENV{'SYBASE'}="/opt/sybase"; $ENV{'DSQUERY'}="rodopi"; use DBI; use Date::Manip; use Date::Format; $tomorrow = time2str("%h %d %Y", UnixDate(ParseDate("tomorrow"),"%s")); $todaystring = ParseDate("today"); $today = time2str("%m/%d/%Y", UnixDate(ParseDate("today"),"%s")); $thismonth = time2str("%m/01/%Y", UnixDate(ParseDate("today"),"%s")); $lastmonth = time2str("%m/01/%Y", UnixDate(ParseDate("lastmonth"),"%s")); $charge = 3; $extracharge = 0; $duration = 6; $tax = 1.07; $dbh = DBI-connect("dbi:Sybase:database=X", "XX", "XXX"); $sql = _ENDSQL; SELECT Customers.CustomerID, Plans.PlanID, Emails.PopName, Emails.EmailAddress, Emails.Password FROM Plans INNER JOIN Customers ON Plans.CustomerID = Customers.CustomerID INNER JOIN Emails ON Plans.PlanID = Emails.PlanID WHERE Emails.PopName="$emailname" AND Emails.EmailAddress="$email" AND Emails.Password="$password" _ENDSQL $sth = $dbh-prepare($sql); $sth-execute || warn $sth-errstr; while (@detail = $sth-fetchrow_array) { $custid = $detail[0]; $emailid = $detail[1]; $popname = $detail[2]; $address = $detail[3]; $password = $detail[4]; $realname = $detail[5]; print "Custid : $custid\n"; print "EmailId : $emailid\n"; print "address : $address\n"; print "Popname : $popname\n"; print "Password: $password\n"; print "Real: $real\n"; print "Today : $today\n"; } #--- # Insert Plan $exec = qq{ Exec Subscribe_InsertPlan $custid,136,6,11,"$today"}; $sth2 = $dbh-prepare($exec); $sth2-execute || warn $sth2-errstr; #--- # Find New Plan Id $sql3 = _ENDSQL; SELECT Plans.PlanID, Plans.CustomerID, Plans.PlanInfoID, Plans.Closed FROM Plans WHERE Plans.CustomerID=$custid AND Plans.PlanInfoID=136 AND Plans.Closed = 0 _ENDSQL $sth3 = $dbh-prepare($sql3); $sth3-execute || warn $sth3-errstr; while (@detail = $sth3-fetchrow_array) {
Import Data
I tryng to import data from ascii file intercun=# copy clientes from '/home/aguztyn/archivo/' using delimiters '|' but I see this error: ERROR: COPY command, running en backend with effective uid 26, could not open file '/home/aguztyn/archivo' for reading. error = Permission Denied What Im doing wrong.
DBI 1.15 subclassing bug!
Since I posted the test scripts yesterday I also ran the trace at level three... There is no additional info that I can make out in the trace scripts because DBI never recieves the call to the disconnect method. Perl intercepts the invocation and dies: Uncaught exception from user code: DBI-disconnect is not a DBI method... To recap, something seems to have been broken between DBI 1.13 and DBI 1.15 when it comes to subclassing. So far no one has replied, but I don't really know where to go next. If this bug interests you and you are qualified to dig deeper than I know how to, please drop me a line. Thanks! Phil PS - Here are the test scripts so you can reproduce the problem. They were modelled from ./t/subclass.t in the DBI install dir. Test System Overview: SUBCLASS_DBI.pm - subclasses DBI, uses init_rootclass method, provides ridiculous alternate connect method STORIT.pm - uses SUBCLASS_DBI.pm to bless its own self and inherit all of the DBI use_SUBCLASS_DBI.pl - title says it all use_STORIT.pl - title says it all Please note this *Important Clue*: the error I noted above only occurs when running use_STORIT.pl. The first level(?semantics?) subclassing that goes on when invoking use_SUBCLASS_DBI.pl causes no error. ***SUBCLASS_DBI.pm*** --- package SUBCLASS_DBI; @ISA = qw(DBI); use DBI; use strict; sub test_connect { # Note that other classes may inherit and use this method # only if they also subclass SUBCLASS_DBI::db and # SUBCLASS_DBI::st in the same manner that SUBCLASS_DBI # subclasses DBI::db and DBI::st. See ./t/subclass.t in # the DBI install directory for the basic example of # subclassing the DBI from which this module was modelled. my $proto = shift; my $class = ref($proto) || $proto; # Tell the DBI that $class is a new 'root class'. This # enables DBI to bless our object for us. In other words, # the constructor for our class is in the DBI package! $class-init_rootclass; my $dbh = $class-connect( 'dbi:Oracle:bnco.world','prl2','prl24', {PrintError = 0} ); if ($dbh) { # Return PrintError to the default setting of ON. $dbh-{PrintError} = 1; } return $dbh; } #== package SUBCLASS_DBI::db; use vars qw( @ISA ); @ISA = qw( DBI::db); #== package SUBCLASS_DBI::st; use vars qw( @ISA ); @ISA = qw(DBI::st); --- ***STORIT.pm*** --- package STORIT; use strict; use SUBCLASS_DBI; use vars qw( @ISA ); @ISA = qw ( SUBCLASS_DBI ); sub new { my $proto = shift; my $class = ref($proto) || $proto; # SUBCLASS_DBI's test_connect method gives back $s already # blessed into our $class, or we die. my $s; $s = $class-test_connect or die; return $s; } sub storit { my $self = shift; my ($key,$val) = (shift,shift); $self-{private_STORIT_info}{$key} = $val; } sub getit { my $self = shift; my $key = shift; return $self-{private_STORIT_info}{$key}; } #== package STORIT::db; use vars qw( @ISA ); @ISA = qw( STORIT SUBCLASS_DBI::db ); #== package STORIT::st; use vars qw( @ISA ); @ISA = qw(SUBCLASS_DBI::st); --- ***use_SUBCLASS_DBI.pl*** --- #!/usr/local/bin/perl -w use diagnostics; use strict; use lib '/u/prl2/perl/modules'; use SUBCLASS_DBI; SUBCLASS_DBI-trace(1,"$0.trace"); my $dbh = SUBCLASS_DBI-test_connect or die; $dbh-{RaiseError} = 1; my $sth = $dbh-prepare("SELECT 'blah' FROM dual"); $sth-execute; my $val = $sth-fetchrow_array; $sth-finish; print "$0 ended up with $val\n"; $dbh-disconnect; --- ***use_STORIT.pl*** --- #!/usr/local/bin/perl -w use diagnostics; use strict; use lib '/u/prl2/perl/modules'; use STORIT; STORIT-trace(1,"$0.trace"); my $s = STORIT-test_connect; $s-{RaiseError} = 1; my $sth = $s-prepare("SELECT 'blah' FROM dual"); $sth-execute; my $val = $sth-fetchrow_array; $sth-finish; my $key = 'foo'; $s-storit($key,$val); print "$0 ended up with ", $s-getit($key), "\n"; $s-disconnect; ---
Re: Import Data
On Fri, 6 Apr 2001, Aguztyn Garcia-Cruz wrote: I tryng to import data from ascii file intercun=# copy clientes from '/home/aguztyn/archivo/' using delimiters '|' but I see this error: ERROR: COPY command, running en backend with effective uid 26, could not open file '/home/aguztyn/archivo' for reading. error = Permission Denied What Im doing wrong. I am guessing you are using PostgreSQL? You can only use the COPY command in PostgreSQL if you are the PostgreSQL super user. -- Brett http://www.chapelperilous.net/btfwk/ And now for something completely the same.
Re: Call for patches for DBD::Pg 0.95
That's undetermined: Of course everyone assumes unless we hear otherwise that Edmund will continue the great work he's done on DBD::Pg. No news? So here's a call for patches: if anyone else knows of patches to DBD::Pg 0.95 send them to me (along with some sort of explanation :) and I'll get a pl1 release out. There's the patch Tom Lane created that fix the problems with large attributes -- that's clearly a bug fix. The other possible patch I know of is this one: http://mailarchive.activestate.com/mail/msg/perl-DBI:299287 It's a bit less obviously a candidate for a "pl1" release, since it is removing a (mis-)feature. I think it's necessary, but it would perhaps be better kept separately for now. A cleaned up copy of that patch is below so nobody else has to dig it out of HTML ... unless they're reading this message as HTML, of course. :-) Regards, Giles --- DBD-Pg-0.95/Pg.pm-orig Mon Jul 10 19:47:51 2000 +++ DBD-Pg-0.95/Pg.pm Mon Aug 28 17:09:04 2000 @@ -867,11 +867,16 @@ parameters will be escaped in the following way: escape quote with a quote (SQL) - escape backslash with a backslash except for octal presentation + escape backslash with a backslash The default is on. Note, that PostgreSQL also accepts quotes, which are escaped by a backslash. Any other ASCII character can be used directly in a string constant. + +(Versions of DBD::Pg before 0.95 sometimes tried to leave backslashes +unescaped when the backslash preceded three digits, so you could pass +octal escapes to PostgreSQL. It no longer does so, use perl to escape +octal escapes if you want to). =item Bpg_INV_READ (integer, read-only) --- DBD-Pg-0.95/dbdimp.c-orig Tue Jul 11 03:47:29 2000 +++ DBD-Pg-0.95/dbdimp.cTue Apr 3 14:27:11 2001 @@ -1095,8 +1095,8 @@ if (*val == '\'') { *dest++ = '\''; } - /* escape backslash except for octal presentation */ -if (*val == '\\' !(isdigit(*(val+1)) isdigit(*(val+2)) isdigit(*(val+3))) ) { + /* escape backslash */ +if (*val == '\\') { *dest++ = '\\'; } } --- DBD-Pg-0.95/test.pl-orig Mon Jun 12 17:12:17 2000 +++ DBD-Pg-0.95/test.plMon Aug 28 17:14:55 2000 @@ -158,7 +158,7 @@ 'f', 'b', 'Halli Hallo', - 'but not \164\150\151\163', + 'no \123456 esc', 'Halli Hallo', 'Halli Hallo', '1995-01-06', @@ -241,7 +241,7 @@ or print "\$sth-fetchrow_array ... not ok: ", join(" ", @row_ary), "\n"; my $ary_ref = $sth-fetchrow_arrayref; -( join(" ", @$ary_ref) eq q{0 b Halli Hallo but not this Halli Hallo Halli Hallo 1995-01-06 5678 {5,6,7} 5.678 (4,5) [(4,5),(6,7)] (6,7),(4,5)} ) +( join(" ", @$ary_ref) eq q{0 b Halli Hallo no \123456 esc Halli Hallo Halli +Hallo 1995-01-06 5678 {5,6,7} 5.678 (4,5) [(4,5),(6,7)] (6,7),(4,5)} ) and print "\$sth-fetchrow_arrayref ok\n" or print "\$sth-fetchrow_arrayref not ok: ", join(" ", @$ary_ref), "\n";