Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Raja Sambamurty" <rajags at hotmail dot com>
Subject: Re: Error when checking
Date: May 26 1998 6:57PM


I don't think the sql line you have with (if exists...) is the problem. 
I use this all the time and often end the sub with a $dbh->sql ($sqlcmd) 
where sqlcmd actually has the whole "if .." logic in it. I think you 
might have some pending results with any of your prior sql commands. 
This is another reason I like to use the ->sql command as opposed to 
dbexec+dbresults+nextrow combo. my $0.2 worth


>From Tue May 26 10:16:21 1998
>Received: from localhost (localhost [])
>	by (8.8.7/8.8.7) with SMTP id MAA28184;
>	Tue, 26 May 1998 12:59:32 -0400 (EDT)
>Received: from ( 
>	by (8.8.7/8.8.7) with SMTP id MAA28110
>	for ; Tue, 26 May 1998 12:57:54 -0400 (EDT)
>Message-ID: <>
>Received: from [] by send1b; Tue, 26 May 1998 09:57:24 PDT
>Date: Tue, 26 May 1998 09:57:24 -0700 (PDT)
>From: Rashmi Anand 
>Subject: Error when checking "if exists"
>To: SybPerl Discussion List 
>MIME-Version: 1.0
>Content-Type: text/plain; charset=us-ascii
>X-Listprocessor-Version: 8.2.06 -- ListProc(tm) by CREN
>I am trying to check for the existance of a row and if it exists, send
>an update otherwise, send an Insert statement:
>if exists (select * from ... where ...)
>   begin 
>     Update ... where ...
>   end
>   begin 
>     Insert ...
>   end
>and I get the following error:
>DB-Library error: Attempt to initiate a new SQL Server operation with
>results pending.
>I don't think the above SQL is returning any results, and I am not
>expecting any, then why is dblib throwing the above error?
>Any help will be appreciated.
>Thanks in advance
>Get your free address at

Get Your Private, Free Email at