Page 1 of 1 1
Topic Options
#121053 - 2004-06-10 07:58 PM Using DBCommand() To return a recordset
Pooja Offline
Fresh Scripter

Registered: 2004-06-04
Posts: 5
I am using DBCommand() for a select statement to MSSQL server. 1) If the record exists, I have to do Update on one of the fields in the record. 2)If the record does not exist, I have to Insert the entire record into the table.

DBCommand () Returns an Array to the return Value if the record exists otherwise returns an empty string if the record doesn't exist.

My Question: How do I check for the return Value in the script that calls DBCommand().
This is my command:
$retCode = DBCommand($DSNConn, $sSQL)

I tried checking for $retCode[0,0], but the script errors out in case there is no record found.
likewise, If i check for an empty string, the script errors out if the record exists.

I tried this check:
IF (ubound($retCode, 1) = -1)
where the value is -1 in case there are no records,

THis seemed to work. But i am not sure if this is a good condition to check for empty records.

Thanks,
Pooja


Top
#121054 - 2004-06-10 10:06 PM Re: Using DBCommand() To return a recordset
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
$returnstuff = dbcommand("blaah")
if @error "error, probably no data in there" endif

_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.049 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org