473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access and Oracle sequence issue

Issue: I am inserting an Oracle record containing insert trigger via
Access 2002 using the code below. The issue is that the sequence from
the acSaveRecord is not reflected after the insert so the insert into
the second table section: ' Copy LOB entries now. fails on unique
index constraint (understandable because it has the orig rate_id).

The strange thing is that it works fine for new records that have
beend added and then cloned using the source below but not for
acess-to-oracle converted records.
Is there a way so save the seq value to a variable? I need to make
sure it is the one I just assigned via the Oracle trigger.

Table relationship: CMPLY_FUND_RATE _DETAIL (1) ---
CMPLY_FUND_LOB( Many)

Source:
Private Sub cmdNewRate_Clic k()
On Error GoTo Err_cmdNewRate_ Click

Dim txtAccount As String
Dim txtFundName As String
Dim lRateID As Long
Dim txtSQLStatement As String

If (Me![EXP_DATE] <= Me![EFF_DATE]) Then
MsgBox "Please confirm Effective and Expiration Dates. The
Expiration Date is prior or equal to the the Effective Date.",
vbInformation + vbOKOnly
Me![EXP_DATE].SetFocus
GoTo Exit_cmdNewRate _Click
End If
lRateID = Me![RATE_ID]
txtAccount = Me![ACCOUNT]
txtFundName = Me![FUND_NAME]
DoCmd.GoToRecor d , , acNewRec

' Set Key Fields and copy over existing LOB from current rate
Me![FUND_NAME] = txtFundName
Me![ACCOUNT] = txtAccount

' Need to Save the keys info prior to copying LOB's
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
--->>> *** this should generate a new rate_id (insert trigger
on CMPLY_FUND_RATE _DETAIL which
the form is tied to)

' Copy LOB entries now.
txtSQLStatement = "INSERT INTO CMPLY_FUND_LOB ( RATE_ID,
[LINE_OF_BUSINES S] )"
txtSQLStatement = txtSQLStatement & " SELECT RATE_ID ,
LINE_OF_BUSINES S"
txtSQLStatement = txtSQLStatement & " FROM CMPLY_FUND_LOB WHERE
RATE_ID = " & lRateID

DoCmd.RunSQL txtSQLStatement , True

Me![lstActiveLOB].Requery
Me![RATE].SetFocus

Exit_cmdNewRate _Click:
Exit Sub

Err_cmdNewRate_ Click:
MsgBox Err.Description
Resume Exit_cmdNewRate _Click

End Sub

Nov 13 '05 #1
7 3944
pe*********@cna .com wrote:
Is there a way so save the seq value to a variable? I need to make
sure it is the one I just assigned via the Oracle trigger.

Source:
Private Sub cmdNewRate_Clic k()
On Error GoTo Err_cmdNewRate_ Click

Dim txtAccount As String
Dim txtFundName As String
Dim lRateID As Long
Dim txtSQLStatement As String

If (Me![EXP_DATE] <= Me![EFF_DATE]) Then
MsgBox "Please confirm Effective and Expiration Dates. The
Expiration Date is prior or equal to the the Effective Date.",
vbInformation + vbOKOnly
Me![EXP_DATE].SetFocus
GoTo Exit_cmdNewRate _Click
End If

lRateID = Me![RATE_ID]
txtAccount = Me![ACCOUNT]
txtFundName = Me![FUND_NAME]
So, it seems that you already have a current record in the Oracle table.
Perhaps selected on a form or dta sheet or even a list box? And you
are trying to copy this record?
DoCmd.GoToRecor d , , acNewRec
Here comes the new record....
' Set Key Fields and copy over existing LOB from current rate
Me![FUND_NAME] = txtFundName
Me![ACCOUNT] = txtAccount ' Need to Save the keys info prior to copying LOB's
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
Now, you're taking the previous values and putting them into a new
record. This is where the Oracle trigger kicks in and creates a new ID
for RATE_ID.

All fine, so far.
--->>> *** this should generate a new rate_id (insert trigger
on CMPLY_FUND_RATE _DETAIL which
the form is tied to)
Correct, as per my above comments.
' Copy LOB entries now.
txtSQLStatement = "INSERT INTO CMPLY_FUND_LOB ( RATE_ID,
[LINE_OF_BUSINES S] )"
txtSQLStatement = txtSQLStatement & " SELECT RATE_ID ,
LINE_OF_BUSINES S"
txtSQLStatement = txtSQLStatement & " FROM CMPLY_FUND_LOB WHERE
RATE_ID = " & lRateID

DoCmd.RunSQL txtSQLStatement , True


This looks like an SQL statement which does exactly the same as the
steps you've done above. You're inserting into CMPLY_FUND_LOB with a
select statement from CMPLY_FUND_LOB. So you're trying to create a new
record, twice?

It seems to me the reason this insert is failing is because you are
trying to insert a value for RATE_ID. If there is a trigger for this
value, I would think Oracle might cough at this, especially if the
trigger involves "before insert". With "after insert", it might be OK,
just change the value of the field, but I'm not sure.

Secondly, is RATE_ID a PK? Does it have a primary key constraint? This
is the same as a primary key in Access/Jet. If this is so, your
statement is failing because you're trying to enter the same primary key
value, let alone forcing a value where a trigger performs the function.

I personally prefer to do this sort of thing with Oracle Pass-through
queries, myself, using DAO methods (though I'm soon going to venture
into DSNless land with ADO). If you can tell me exactly what you're
trying to do, I can write some code that will do this - it's pretty
straightforward .

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #2
....Copy LOB entries
this code inserts record into cmply_Lob with the rate_id(unique
key rate_id + LOB) using the rate_id from cmply_fund_deta il(from before
insert trigger). The lRATEID is the rate_id from the orig record that
I am trying to clone in the LOB table.

ex. if the orig rate_id = 10 and the new = 10O then any record in LOB
with rate_id 11 will now be inserted into cmply_LOB table with rate_id
100.

Nov 13 '05 #3
pe*********@cna .com wrote:
...Copy LOB entries
this code inserts record into cmply_Lob with the rate_id(unique
key rate_id + LOB) using the rate_id from cmply_fund_deta il(from before
insert trigger). The lRATEID is the rate_id from the orig record that
I am trying to clone in the LOB table.

ex. if the orig rate_id = 10 and the new = 10O then any record in LOB
with rate_id 11 will now be inserted into cmply_LOB table with rate_id
100.


But peter, it seems to me that this SQL:

txtSQLStatement = "INSERT INTO CMPLY_FUND_LOB ( RATE_ID,
[LINE_OF_BUSINES S] )"
txtSQLStatement = txtSQLStatement & " SELECT RATE_ID ,
LINE_OF_BUSINES S"
txtSQLStatement = txtSQLStatement & " FROM CMPLY_FUND_LOB WHERE
RATE_ID = " & lRateID

Comes out to an SQL statemet which says:

INSERT INTO CMPLY_FUND_LOB ( RATE_ID, [LINE_OF_BUSINES S] ) SELECT
RATE_ID, LINE_OF_BUSINES S FROM CMPLY_FUND_LOB WHERE RATE_ID = <long>

And <long> is the same rate_ID that was the rate_id from the originally
selected record. I must be missing something. In your last post, you
say you're inserting into CMPLY_LOB, but the above shows you're
inserting into CMPLY_FUND_LOB from CMPLY_FUND_LOB.

The lRateID has not changed from the originally selected record. Is the
original selection in another table? I wouldn't be so confused if your
SQL had the select clause coming from CMPLY_LOB....

Sorry 8(

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #4
I was actually trying to figure out why the existing access code using
assaverecrod does not always return the new seq number. I was hoping
it was related to oracle.

I guess I may just have to code my own insert using a pass thru..

I was able to to the pass thru but how do I get the new seq...it
appears that
txtSQLDetail = "INSERT INTO CMPLY_FUND_DETA IL ( RATE_ID) VALUES
(CMPLY_FUND_RAT E_DETAIL_SEQ.NE XTVAL)"
txtSQLDetail = txtSQLDetail & " returning RATE_ID into :" & nRateId

inserts the record bu I don't get the rate_id sequence back

Nov 13 '05 #5
I meant to type cmply_fund_LOB.
From the source the lrateid is the curret rateid on the screen from the

original record. This rateid is the one that is used to create cloned
records in the cmply_fund_LOB table with a new rateid(assigned from an
insert trigger on the cmply_fund_LOB table).

Nov 13 '05 #6
Strange....I recompiled the before insert trigger on the
CMPLY_FUND_RATE _DETAIL table and all appears to be working. Any
suggestion as to why this will appear to fix the issue.

Nov 13 '05 #7
I lied. that didn't fix all records. I quess I will need to write my
own insert into the cmply_fund_rate _detail table. Is there a way to
bring back the sequence number I just used?

Nov 13 '05 #8

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

Similar topics

13
3327
by: BigDaDDY | last post by:
Um yeah....In case you haven't figured it out, Microsoft sucks. I'm going to be kicked back in my chair eating popcorn and watching football 10 years from now, while all you clowns are scrambling to rewrite all your code because Microsoft upgraded all their crap and nothing you wrote 10 years earlier works. It doesn't take a rocket scientist to figure out that Microsoft is unreliable. Try opening an Excel 95 spreadsheet you wrote in...
11
17061
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the Ford Fairlane. I need this info to complete a school project. Thanks.
64
5260
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. Any comments? Thanks
17
2496
by: DaveG | last post by:
Hi all I am planning on writing a stock and accounts program for the family business, I understand this is likely to take close to 2 years to accomplish. The stock is likely to run into over a thousand items and the accounting side will be used for hopefully many years so the entries are likely to be vast. The delema is what is best to use ase the DB engine, Access I have as part of Office 2002 or should I really be looking at SQL...
10
2375
by: Hank | last post by:
We have just recently migrated the data from our Access 2000 backend to Postgres. All forms and reports seem to run correctly but, in many cases, very slowly. We do not want to switch over until we can speed things up. We would like to start implementing Stored Procedures so we can do Server-Side processing. Can anyone recommend a book that would help us learn how to use sprocs or pass-through queries? I apologize if my terminology...
2
4239
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with this. Also - the citrix folks do not want us to keep the FE in Access as the queries and other activities consume a lot of power. The users will be in 3 different offices across the globe all accessing the 1 Oracle DB in Citrix. Does anyone have...
3
6042
by: Eitan M | last post by:
Hello, How can I make sequence for access db ? (the same like Oracle sequence). Thanks :)
1
5209
by: reliance | last post by:
Using Oracle Migration Workbench, I migrated ms-access 2003 database to oracle 9i. The memo datatype in ms-access mapped to clob datatype in oracle. I have created a system dsn to access oracle tables through ms-access so that the front-end will remain in ms-access. While fetching clob datatype fields - I get ODBC error ODBC--call failed. Function sequence error(#0) System Info : Windows 2003 SP-2 MS-Office 2003 MS-ACCESS 2003 but...
0
2259
by: mail2sanand | last post by:
Hi all, I am facing a new issue with oracle and rails. I feel rails is expecting a sequence name associated with all the tables. The actual question is that how can we make rails understand that there is no sequence associated with a model. Coz when I am running RSpecs for some models (connected to oracle database) without sequences, Itz giving an error that ...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10005
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8887
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.