BookmarkSubscribeRSS Feed
SS_B
Fluorite | Level 6

Hello,

Could you please help me to check the Oracle SQL definition (including null exception) with SAS EG? We don't have access to Oracle that's why unable to check null exception in oracle. 

 

Below SAS EG query not return sql exception.

 

proc sql;

describe table abc;

run; 

3 REPLIES 3
gwootton
SAS Super FREQ
Its unclear to me what you are asking here. It sounds like you are getting an error when trying to access an Oracle table. Can you provide the exact error you are receiving?
How are you connecting to Oracle from SAS? Are you issuing a libname statement or is this library defined / preassigned in SAS Management Console? If you're issuing a libname statement, what is it? If preassigned, can you try assigning manually using a libname statement and see if you get the same issue?

Documentation on the Oracle LIBNAME engine statement can be found here:

LIBNAME Statement for the Oracle Engine
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p1qft7bzdij79zn1bxh59mc3w8xj.htm
--
Greg Wootton | Principal Systems Technical Support Engineer
Sajid01
Meteorite | Level 14

What I understand is that you can connect to oracle through SAS code, but cannot access using SQL developer or some other tool. Happens when the code is executed through a generic ID and SAS ins running on a server (no local install).

Now NULL means nothing. In other words no values is associated with the variable in that observation. If that variable is being used in an operation requiring a value and it encounters null, then there is a null exception.

There could be multiple approaches to handle the presence of Null depending what is needed.

The Oracle functions NVL and NVL2 can be used in expressions to handle NULL.
Oracle function NVL(Var, some_value)., assigns  'some_value' to the variable to the expression if  Var is NULL..
The oracle function NVL2(Var, value1,value2) assigns value1 to the expression if the value of Var is null otherwise it assigns Value2..

I

 

Patrick
Opal | Level 21

It makes a developer's life harder if one can't directly access a DB via a client. IF you've got the credentials the SAS library uses to access Oracle then the easiest way would be to get a client like DBeaver or SQL Developer. There are portable versions around so it's software you can just download and use even if you can't install software on your local machine.

 

If you're using a pre-assigned SAS library and though might not know the credentials then you can still query Oracle directly.

 

Let's assume the libref of your pre-assigned library a blah.

The following statement writes the library definition to your SAS log - one component of it is the Oracle schema name.

libname bla list;

You can also determine the schema name with below syntax.

%let ora_schema=;
proc sql noprint;
  select sysvalue into :ora_schema trimmed
  from dictionary.libnames
  where 
    libname="BLAH"
    and sysname='Schema/Owner'
  ;
quit;
%put &=ora_schema;

You can issue explicit Oracle SQL syntax out of SAS  to query Oracle dictionary tables and so derive the DDL of a table.

proc sql;
  connect using blah;
  select * from connection to bla
  (
    <Oracle SQL syntax to be Googled>
  );
  disconnect from blah;
quit;

How the Oracle syntax needs to look like so it works for you (also dependent on the permissions your Oracle user has) is something you need to Google. A very quick try led me to this link.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 537 views
  • 0 likes
  • 4 in conversation