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: Leigh Moncher <dvor at voicenet dot com>
Subject: RE: Error when checking "if exists"
Date: Jun 1 1998 10:55PM

However more fault tolerant (if you're writing for distribution) is the
update.  All it takes is one missing primary key constraint to really mess
up your day.  (I work in a support department so I've had to deal with it).
At 11:27 AM 6/1/98 +0100, you wrote:
>Its much faster to do an insert, and trap the error return. If the row
exists then do an update. Alternatively if you expect the row to be there
more frequently than not, do the update first, and insert on fail.
>Peter Collard 
>Sybase Database Administrator
>"The views expressed in this correspondence are mine and not necessarily
those of Rabobank International"
>-----Original Message-----
>From:	Rashmi Anand []
>Sent:	Monday, June 01, 1998 10:55 AM
>To:	SybPerl Discussion List
>Subject:	Error when checking "if exists"
>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
Leigh Moncher