472,145 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Problem repeating a query within an ADO Transaction

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

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

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 :=

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,
dummy_ NUMBER;
CURSOR exist_control IS
WHERE part_no = part_no_
AND serial_no = serial_no_;
OPEN exist_control;
FETCH exist_control INTO dummy_;
IF (exist_control%FOUND) THEN
CLOSE exist_control;
CLOSE exist_control;
END Check_Exist___;
Apr 3 '07 #1
0 1355

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by gordongekko | last post: by
4 posts views Thread by Prabhat | last post: by
3 posts views Thread by Sean Shanny | last post: by
1 post views Thread by Matik | last post: by
2 posts views Thread by Tony O'Bryan | last post: by
14 posts views Thread by Jim Michaels | last post: by
reply views Thread by Matik | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.