BookmarkSubscribeRSS Feed
etl_tool
Calcite | Level 5

Hi ,

I'm joining a sybase table and a sas data set to insert/update data using a table loader in oracle. The table ID needs to be loaded using a sequence which resides in oracle. Can you please let me know how to use an oracle sequence to generate a ID column? I tried adding a dummy column to the same oracle table joined it to the result set and tried specifying seqname.nextval in a expression editor but getting an error:

ERROR: Unresolved reference to table/correlation name seqname.

7 REPLIES 7
Patrick
Opal | Level 21

The approach I would take:

- Join the Sybase & SAS table creating a SAS WORK table.

- Bulk-load this SAS Work table into an Oracle staging table (either a global temporary table or simply a new Oracle table).

     - What I would do: First drop the staging table (just in case) using Proc Datasets with NOLIST NOWARN, then create the table using explicit SQL pass-through, then bulk-load into the table using a table loader.

- Load the Oracle staging table into the existing target Oracle table using pass-through SQL (the SQL EXECUTE transformation). Loading Tables

- Drop the staging table (using Proc Datasets).

etl_tool
Calcite | Level 5

Thanks partick. So there is no easy way to do it using just SAS Datasets and transformations? We can do that easily using other ETL tools like talend and Informatica

etl_tool
Calcite | Level 5

I took an approach of creating staging tables and then inserting or updating using SQL execute transformation.

LinusH
Tourmaline | Level 20

I used the IGNORE_READ_ONLY_COLUMNS libname option when we had a similar issue with SQL Server.

But unfortunately, it's available on all DBMS ACCESS except Oracle... 😞

Data never sleeps
etl_tool
Calcite | Level 5

Thanks Linus. So if you select that option , how does it read the sequence from SQL server. Just for knowledge sake.

LinusH
Tourmaline | Level 20

As I recall it, when we did a append /insert libname style it ignored the seq Id column (which was defined with a automatic constraint ).

Data never sleeps
Patrick
Opal | Level 21

That's the approach I would have taken as well because it allows you to bulk-load into the staging table.

I've played now a bit with the sequence object so here the options I found working:

- Fully implement the sequencing in the database by using a before insert trigger. If done so then even a proc append works (you need to set options nowarn/force as you won't pass in the key field from source).

- Use pass-through SQL as you've done it.

- Query the sequence object from within SAS to retrieve the current value for LAST_NUMBER, then increment the key within SAS and populate the key field on the source side, then ALTER the sequence object to set LAST_NAME to the new key value - and load the source table into Oracle.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 3197 views
  • 2 likes
  • 3 in conversation