473,396 Members | 2,029 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,396 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 1392

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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.