473,382 Members | 1,658 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,382 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 1391

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

Similar topics

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)...
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...
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...
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...
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...
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...
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)) {...
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...
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. ...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.