Problem with dbsqlexec

Problem with dbsqlexec

Post by RenĂ© Hau » Fri, 08 Jun 2001 18:31:54



Hi,

I have a problem with my Sybase-SQL.
I want to add a product via a perlscript:

# This function is only for generating debuglog
sub deb {

($datesec,$datemin,$datehour,$dateday,$datemon,$dateyear)=(localtime)[0..5];

open(DEB,">>weltpild_neu.log")||open(DEBUGLOG,">weltpild_neu.log")
or die "Cannot open weltbild_neu.log\n";
  printf(DEB
"%04d-%02d-%02d|%02d:%02d:%02d|",$dateyear,$datemon,$dateday,$datehour,$datemin,$datesec);
  print(DEB $debtext."\n");
  close(DEB);
  return 1;

Quote:}

# This function executes SQL
sub doSQL {

  if(!defined($sql) || !sql) {
    deb("doSQL called with uninitialized parameter");
  }
  $dbh->dbcmd($sql) || deb("Error in (dbcmd) (\"$sql\")");
  $dbh->dbsqlexec() || deb("Error in (dbsqlexec) (\"$sql\")
(".$dbh->dbresults().")");
  my($dbresult)=$dbh->dbresults();
  if($dbresult=NO_MORE_RESULTS && $dbh->dbhasretstat &&
$dbh->dbretstatus<0) {
    deb("database error (".$dbh->dbretstatus.")_>
(\"$sql\")");
  }
  return $dbresult;

Quote:}

# Main
$dbh= Sybase::DBlib->dblogin('USER','PASSWORD','DBSERVER');
$dbh->dbuse("shopdb");

...
# Code, that generates following vars
...

    doSQL("spa_InsertProduct
'$pnr','$titel','$beschreibung',0,0,$preis,$unitanr,'','',0,1,0,'','','1',1,'$template',1");

...

OK, this Code produces following output in debuglog:

0101-05-06|18:21:08|Error in (dbsqlexec) ("spa_InsertProduct
'WB-807823','Der Himmel h?ngt voller Geigen','Ein
musikalisches Portrait einer gro?en Operetten- und
Lieders?ngerin.Mit: - Summertime - Zauberhafter Frhling -
Und der Himmel h?ngt voller Geigen - Frhlingsstimmen-Walzer
- Mein Herr Marquis -
u.a.',0,0,17.95,2,'','',0,1,0,'','','1',1,'default',1") (2)

But if I copy and paste that generated SQL-Statement and run
it in iSQL, it works fine.

Can anyone explain that to me, please?
Thanks, Ren

--
Ren Haude, GHEC - Bookshop - Webterra
Bozenerstr. 1, 86165 Augsburg, Germany(BRD)
Tel.:   0821/7292112   FAX:   0821/7292119

 
 
 

Problem with dbsqlexec

Post by Michael Pepple » Fri, 08 Jun 2001 23:45:32




Quote:> Hi,

> I have a problem with my Sybase-SQL.
> I want to add a product via a perlscript:

<snip>

> # This function executes SQL
> sub doSQL {

>   if(!defined($sql) || !sql) {
>     deb("doSQL called with uninitialized parameter");
>   }
>   $dbh->dbcmd($sql) || deb("Error in (dbcmd) (\"$sql\")");
>   $dbh->dbsqlexec() || deb("Error in (dbsqlexec) (\"$sql\")
> (".$dbh->dbresults().")");
>   my($dbresult)=$dbh->dbresults();
>   if($dbresult=NO_MORE_RESULTS && $dbh->dbhasretstat &&
> $dbh->dbretstatus<0) {
>     deb("database error (".$dbh->dbretstatus.")_>
> (\"$sql\")");

This bit is wrong.

You need to write this like so:

while($dbh->dbresults != NO_MORE_RESULTS) {

      ... do something with any returned rows, or just throw them away
   }

Quote:}

if($dbh->dbhasretstat) {
    my $status = $dbh->dbretstatus;
    if($status != 0) {
        ... an error occured in the proc execution...
    }

Quote:}

You should read the manual page for dbhasretstat() in the Sybase
DB-Library manual (available on http://sybooks.sybase.com, look in the
"middleware" section, I think) for details on using dbhasretstat() as it
is a little tricky...

Michael
--


International Sybase User Group - http://www.isug.com


 
 
 

1. dbsqlexec

Hi,

I am running SQL 7.0 with SP4 on NT with SP6a.  I have a Database that is
used for authenticating and accounting for Telephony services.  Over the
last few weeks I have been receiving a number of errors that I cannot seem
to work out.  We have tried exporting he data, blowing the tables away and
re-inserting the data, moving to a new high perfromance machine and still
the same errors.

The first error looks like this:

2002:11:05-08:53:02:171: 0x00DA: Warning:
DataBaseConnectionClass::ErrorHandler 98b480 7 10038 -1 Attempt to initiate
a new SQL Server operation with results pending. (null)
2002:11:05-08:53:02:171: 0x00DA: Warning: DataBaseConnectionClass::Sql() Err
in dbsqlexec 98b480
2002:11:05-08:53:02:171: 0x00DA: Warning: DataBaseConnectionClass::Sql() End
Wait on 98b480 select COL_NAME(OBJECT_ID('UserTable'),1)
2002:11:05-08:53:02:171: 0x00DA: Warning: BsRequestHandler::dbUser() user
500211 not found

The user obviously exists in the databse and if tried again immediatley
afterwoods all works fine.  This error re-occurs every 1hr or so during the
day until we finally receive this error, stating that certain tables cannot
even be read!

2002:11:05-21:55:37:343: 0x0152: Warning:
DataBaseConnectionClass::ErrorHandler 98b480 7 10038 -1 Attempt to initiate
a new SQL Server operation with results pending. (null)
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() Err
in dbsqlexec 98b480
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() End
Wait on 98b480 select * from RateTable (NOLOCK)
2002:11:05-21:55:37:343: 0x0152: Warning:
DataBaseConnectionClass::ErrorHandler 98b480 7 10038 -1 Attempt to initiate
a new SQL Server operation with results pending. (null)
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() Err
in dbsqlexec 98b480
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() End
Wait on 98b480 select * from CurrencyTable (NOLOCK)
2002:11:05-21:55:37:343: 0x0152: Warning:
DataBaseConnectionClass::ErrorHandler 98b480 7 10038 -1 Attempt to initiate
a new SQL Server operation with results pending. (null)
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() Err
in dbsqlexec 98b480
2002:11:05-21:55:37:343: 0x0152: Warning: DataBaseConnectionClass::Sql() End
Wait on 98b480 select * from UserCategoryTable (NOLOCK)

I am at my wits end, is there anyone out there that can help me?

Regards,

2. Oracle 7 Stored Procedures

3. dblibrary help: dbsqlexec...

4. dynamic sql

5. dblibrary for c: DBSQLEXEC won't wait....

6. Auditing UPDATE activity on a table

7. Err in dbsqlexec

8. DTS Errors

9. SQL Web Assistant failed on dblib command dbsqlexec (#16817)

10. dblibrary and multiple UPDATE/DELETEs in a single dbsqlexec

11. dbsqlexec() core dump

12. dbsqlexec

13. dbsqlexec buffer limit?