totn Access

MS Access 2003: Create a pass-through query to retrieve the nextval from an Oracle sequence

This MSAccess tutorial explains how to create a pass-through query to retrieve the NextVal from an Oracle sequence in Access 2003 (with screenshots and step-by-step instructions).

Question: I can get nextval from sequence in Oracle with this command:

SELECT seq_name.nextval FROM dual;

Is there any way to get nextval from the Oracle sequence through Access 2003/XP/2000/97 when docmd.runsql("select seq_name.nextval from dual") doesn't work?

I need to insert nextval (the same value) into two tables.

Answer: To get the nextval from an Oracle sequence, you will need to use a pass-through query in Access.

To create a pass-through query, create a new query. Select Design View and click on the OK button.

Microsoft Access

When the Show Table window appears, do not add any tables. Click on the Close button.

Microsoft Access

Select SQL View from the toolbar.

Microsoft Access

Enter your SQL statement. In this example, we're selecting the next value from the Oracle sequence called supplier_seq.

Microsoft Access

Finally, under the Query menu, select SQL Specific > Pass-Through.

Microsoft Access