Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Problem repeating a query within an ADO Transaction

Reply
Thread Tools

Problem repeating a query within an ADO Transaction

 
 
CJM
Guest
Posts: n/a
 
      04-03-2007
I have a fairly simple ASP application talking to an Oracle 10g DB using a
mixture of ADO (OraOLEDB) and OO4O - the query here concerns some ADO code.

One part of the application records PartNo/SerialNo combinations; the user
specifies a PartNo, a SerialNo and the parent PartNo - the parent takes the
SerialNo from the child object - and the application INSERTs these as
records into the DB.

Amongst the validation, is a check to confirm that each PartNo/SerialNo
combination has not be used before. This code seems to work fine.
Clearly, if the user enters the same PartNo for both the child and parent
items, the DB would ordinarily complain:

"ORA-00001: unique constraint (IFSAPP.PART_SERIAL_CATALOG_PK) violated
ORA-06512"

However, I'm expecting the validation routines to handle this clash before
the INSERT statement is attempted. Unfortunately, in this type of scenario
this is not the case - the validation routine responds that the parent
PartNo/SerialNo has not been used before, and thus the INSERT is attempted
and the unique constraint error occurs.

I assume that this is because previous INSERTs were not committed since the
whole operation is wrapped up within an ADO transaction. However, I would
have expected that the validation code would have taken an changes made
within the transaction into account, but it doesn't appear to be the case.

Is my logic wrong, or should I be expecting the validation to consider
previous statements within the same transaction? If my expectations are
correct, where might I be going wrong?

Thanks in advance

Chris


Selected code snippets:
- ASP:

Function SerialExists (sSerialNo, sPartNo)
Dim iResult, bResult

With oDB
.Parameters.Add "sPartNo", sPartNo, ORAPARM_INPUT, 1
.Parameters.Add "sSerialNo", sSerialNo, ORAPARM_INPUT, 1
.Parameters.Add "iResult", 0, ORAPARM_OUTPUT
.Parameters("iResult").serverType = 1

.ExecuteSQL ("declare iResult VARCHAR2(100); Begin :iResult :=
IFSAPP.PART_SERIAL_CATALOG_API.CHECK_EXIST(:sPartN o, :sSerialNo); end;")

SerialExists = .Parameters("iResult").Value

.Parameters.Remove "sPartNo"
.Parameters.Remove "sSerialNo"
.Parameters.Remove "iResult"

End With
End Function


- Oracle:

FUNCTION Check_Exist___ (
part_no_ IN VARCHAR2,
serial_no_ IN VARCHAR2 ) RETURN BOOLEAN
IS
dummy_ NUMBER;
CURSOR exist_control IS
SELECT 1
FROM PART_SERIAL_CATALOG_TAB
WHERE part_no = part_no_
AND serial_no = serial_no_;
BEGIN
OPEN exist_control;
FETCH exist_control INTO dummy_;
IF (exist_control%FOUND) THEN
CLOSE exist_control;
RETURN(TRUE);
END IF;
CLOSE exist_control;
RETURN(FALSE);
END Check_Exist___;


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Form and ADO.NeT Transaction Lit ASP .Net 6 08-10-2007 03:20 PM
Win2003 SP1 error: "New transaction cannot enlist in the specified transaction coordinator" Vencz Istv?n ASP General 2 05-02-2005 05:53 AM
Translating Oracle Package Call from ADO to ADO.Net dmiratsky@yahoo.com ASP .Net 0 02-14-2005 10:39 PM
Transfer ADO Code to ADO.NET ronaldlee ASP .Net 1 12-17-2004 04:08 PM
Accessing an ADO Recordset or Record from ADO.NET nita ASP .Net 1 11-20-2004 07:06 AM



Advertisments