[ciapug] Adodb -> mssql, grabbing from a result set

David Champion ciapug@cialug.org
Mon, 15 Dec 2003 13:30:55 -0600


Can you disable the insert trigger, then do the same thing manually in 
PHP, and see what happens?

I would guess that it is a latency issue of some sort - that MS-SQL has 
a transaction in progress from the insert trigger, so your 2nd query 
doesn't return anything. If that's the case, you might have to look into 
wrapping the insert in a transaction, and end the transaction before 
doing the 2nd query. If this is the case, doing a sleep(9 billion 
seconds) would'nt make any difference...

Ask one of your MS-SQL people about transactions, that might ring a bell 
with them.

-dc

Chris Hettinger wrote:

>My script does a insert into a MsSQL table, the insert is done in mssql with a trigger that grabs a generated id, does the insert then writes the id it used to the 'urlastgenid' table, tagged by my userid 'encwebtools'. The next statement in my script the query for the lastgenid (below).
>
>The odd thing is that in my script if I comment out the execution of the insert, and run the script it grabs the value in that lastgenid field just fine. However when following the insert it fails, The SQL returns False. I even considered the possibility of latency, allowing SQL the time complete its processing... so I used a sleep(5) (5 second pause) ... still failed.
>
>---------- Here the segment of the script ------------------
>
>...
>
>$sql = "INSERT INTO QTII_UR.dbo.case_ (patientid,calldate,callername,callerphon,follow,callertype) VALUES ( '5986075', '2003-12-15 09:38:50', 'Hettinger, Chris', '5152055711', '5152055711', '2')";
>
>$result = $qtdb->Execute($sql);
>if($result === false) die('Failed');
>
>
>$sql = "SELECT LastGenID FROM QTII_UR.dbo.urlastgenid WHERE userid = 'encwebtools'";
>$rsCaseID = $qtdb->Execute($sql);
>if($rsCaseID === false) die('CaseID lookup Failed');
>
>$caseID = $rsCaseID->fields['LastGenID'];
>
>...
>
>-----------------------------------------------
>
>
>-----Original Message-----
>From: Chris Hettinger 
>Sent: Monday, December 15, 2003 10:15 AM
>To: Ciapug (E-mail)
>Subject: [ciapug] Adodb -> mssql, grabbing from a result set
>
>
>Those that are familiar with ADODB...
>	
>	$sql = "SELECT LastGenID FROM QTII_UR.dbo.urlastgenid WHERE userid = 'encwebtools'";
>        	$rsCaseID = $qtdb->Execute($sql);
>
>  
>
>>>Succeeds, Returns 1 record with the value '3281608'
>>>      
>>>
>
>        	$caseID = $rsCaseID->fields['LastGenID'];
>
>$caseID is empty... Though my select is succeeding the assignment is not grabbing the value of the field. I have also tried the assignement like this:
>
>	$caseID = $rsCaseID->fields[0]; // still nothing.
>
>I have review the Adodb manual, but not sure if I need to do this assignment differnet since I am querying a Mssql DB ???
>  
>