473,287 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem repeating a query within an ADO Transaction

CJM
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___;
Apr 3 '07 #1
0 1388

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim Geissman | last post by:
Help, please. I am trying to update a table with this structre: CREATE TABLE Queue (PropID int, EffDate smalldatetime, TxnAmt int) INSERT Queue (PropID) SELECT 1 INSERT Queue (PropID)...
1
by: gordongekko | last post by:
Hi! I'm writing a program that interacts with a db2 database through jdbc. I frequently need to run a quite query q1 that involves several full outer join of a table with itself. Once q1 is...
4
by: Prabhat | last post by:
How do I lock a particular record that one user has opened for editing? If I use the pessimistic type, can other users view the record (but not edit it) and return a message telling that another...
3
by: Sean Shanny | last post by:
To all, We are running postgresql 7.4.1 on an G5 with dual procs, OSX 10.3.3 server, 8GB mem, attached to a fully configured 3.5TB XRaid box via fibre channel. I think we have run into this...
1
by: Matik | last post by:
Hello 2 all, Maybe my question can be very stupid, but I'm a little confused. When I run sp_who on my database, I see one process (accessing remotely my database from another database on another...
2
by: Tony O'Bryan | last post by:
I am normally the admin for our PostgreSQL servers, but someone else tried to kill a runaway query while I was out sick. Unfortunately, he tried killing the runaway query by killing the...
14
by: Jim Michaels | last post by:
mysql_query("START TRANSACTION", $link2); $q2=mysql_query("SELECT pictures.pid AS pid FROM pictures,counter WHERE pictures.pid>counter.pid LIMIT 1", $link2); if ($row2=mysql_fetch_assoc($q2)) {...
0
by: Matik | last post by:
Hi, MSSQL 2000 booth servers. Booth running DTC. Now, the client application, is starting in DB1 a procedure. The connection open to db, is within the transation opened from client. In the...
6
by: Wheeler2008 | last post by:
Hi All, I am currently running a query on a MS Access table, in which I want to be able to compare and total the difference in dates between records. I only have one date field within the table. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.