sandygallant has asked for the wisdom of the Perl Monks concerning the following question:
immediately after that finishes I close off the connection, and cancel it to make sure that there are no results left to be processed by issuing:while (my ($key, $value) = each(%holidays)) { system("log4k", "DEBUG", "$0", "Staging holiday info data for: $ca +l_name: $key"); $sql = "INSERT INTO stg_holiday_data (hol_mnemonic, hol_date, hol_ +comment, dml_type) VALUES (\"$cal_name\", $key, \"$value\", \"N\") +"; system("log4k", "TRACE", "$0", "SQL being executed: $sql"); if ($test == 0) { $dbh->dbcmd($sql); ($dbh->dbsqlexec() && $dbh->dbresults) or &fatalError("Database error in $sql", "DB_ERROR"); while($dbh->dbresults != NO_MORE_RESULTS) { while(my @dat = $dbh->dbnextrow){} } } }
From there I call a separate subroutine to execute a stored procedure which will produce three lines of output signifying row numbers: subroutine call &run_sproc() if ($test == 0); subroutine:$dbh->dbcancel(); $dbh->dbclose();
I do have a third SQL block that comes after the stored procedure that works fine with or without this subroutine. What is happening is I am receiving the error mentioned above right before the results from the stored procedure print. I have tried everything I can imagine to make sure that all the results are being processed. A sample of the log output is below:sub run_sproc() { system("log4k", "DEBUG", "$0", "Loading staged holiday data"); my $sql1 = "upd_holiday_data"; system("log4k", "TRACE", "$0", "SQL being executed: $sql1"); my($dbh2) = new Sybase::DBlib $ENV{DATABASE_USER}, $ENV{DATABASE_P +ASSWORD}, $ENV{DATABASE_SERVER}, "GME_calendar_sync"; &fatalError("Failed to login to database", "DB_LOGIN_ERROR") unles +s ($dbh2); $dbh2->dbcmd($sql1); ($dbh2->dbsqlexec() && $dbh2->dbresults ) or &fatalError ("Database error in $sql", "DB_ERROR"); while ($dbh2->dbresults != NO_MORE_RESULTS) { while (my @d = $dbh2->dbnextrow) { system("log4k", "TRACE", "$0", "Next row being inserted @d +"); } } $dbh2->dbclose(); }
Any help with this would be greatly appreciated as I have already tried everything I can find doing an internet search and reading the documentation. Thanks Solution Found: Solution Found: In the run_sproc sub routine, the check:[Tuesday, 23 October 2012 13:30:02 BST] [DEBUG] gme_process_calendars. +pl: Staging holiday info data for: CA: 20251226 [Tuesday, 23 October 2012 13:30:03 BST] [TRACE] gme_process_calendars. +pl: SQL being executed: INSERT INTO stg_holiday_data (hol_mnemonic, h +ol_date, hol_comment, dml_type) VALUES ("CA", 20251226, "upload", +"N") [Tuesday, 23 October 2012 13:30:03 BST] [DEBUG] gme_process_calendars. +pl: Staging holiday info data for: CA: 20220103 [Tuesday, 23 October 2012 13:30:03 BST] [TRACE] gme_process_calendars. +pl: SQL being executed: INSERT INTO stg_holiday_data (hol_mnemonic, h +ol_date, hol_comment, dml_type) VALUES ("CA", 20220103, "upload", "N" +) [Tuesday, 23 October 2012 13:30:03 BST] [DEBUG] gme_process_calendars. +pl: Loading staged holiday data [Tuesday, 23 October 2012 13:30:03 BST] [TRACE] gme_process_calendars. +pl: SQL being executed: upd_holiday_data DB-Library error: Attempt to initiate a new SQL Server operation with results pendin +g. [Tuesday, 23 October 2012 13:30:03 BST] [TRACE] gme_process_calendars.pl: Next row being inserted 310107230
the second condition $dbh2->dbresults is what is causing this error condition, once this was removed the error did not come up anymore. Thank you everyone that looked into this for me($dbh2->dbsqlexec() && $dbh2->dbresults ) or &fatalError ("Database error in $sql", "DB_ERROR");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBLib error driving me crazy
by roboticus (Chancellor) on Oct 23, 2012 at 17:59 UTC | |
|
Re: DBLib error driving me crazy
by mpeppler (Vicar) on Oct 24, 2012 at 10:54 UTC |