BookmarkSubscribeRSS Feed
OscarBoots2
Calcite | Level 5

HI,

 

Can anyone show me how how to convert my connection string into a Libname statement?

 

As you can see below, I have the HOST, PORT, SERVICE NAME, USER & PASSWORD.

 

I want to use these credentials to create a Libname statement & use in a Pass Thru query to Oracle, any suggestions?

 

libname mylib oracle  ;

 

connect to oracle as ora (path="(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)
(HOST = xxxxxxxxxxxxxxx.com)(PORT = 1234))
(CONNECT_DATA = (SERVICE_NAME=xxxxxxx)))
user=xxxxxxx pw=xxxxxxxx);
8 REPLIES 8
Damo
SAS Employee

Hi @OscarBoots2

 

Did you get a chance to review LIBNAME Statement Specifics for Oracle ?

 

It shows you can use, for instance:

libname x oracle user=myusr1 pw=mypwd1 
  path="(DESCRIPTION= 
          (ADDRESS_LIST=
            (ADDRESS= (PROTOCOL=TCP)(HOST=pinkfloyd)(PORT=1521))
             )
              (CONNECT_DATA= 
       "  	     (SID=alien)
       "   )
       " )
       " ";

Hope that helps.


Cheers,
Damo

OscarBoots2
Calcite | Level 5

Thanks Damo,

 

I've tried to adapt this to my settings, which currently work in other queries, but I get a

 

libname mylib oracle user=XXXXXX pw=XXXXXX 
path="(DESCRIPTION=
		(ADDRESS = (PROTOCOL = TCP) 
			(HOST = XXXXXXXXXXX.com)(PORT = 1234))
				(CONNECT_DATA = (SERVICE_NAME=XXXXXX)))";

proc sql noprint;

create table TABLE1 as select * from connection to mylib 
( 
select DISTINCT 
ID

FROM DBC.TABLE2

WHERE ROWNUM < 50
)
;QUIT;

The error is below but doesn't make sense as my credentials are correct?

 

ERROR: The MYLIB engine cannot be found.
ERROR: A Connection to the mylib DBMS is not currently supported, or is not installed at your site.
ballardw
Super User

@OscarBoots2 wrote:

Thanks Damo,

 

I've tried to adapt this to my settings, which currently work in other queries, but I get a

 

libname mylib oracle user=XXXXXX pw=XXXXXX 
path="(DESCRIPTION=
		(ADDRESS = (PROTOCOL = TCP) 
			(HOST = XXXXXXXXXXX.com)(PORT = 1234))
				(CONNECT_DATA = (SERVICE_NAME=XXXXXX)))";

proc sql noprint;

create table TABLE1 as select * from connection to mylib 
( 
select DISTINCT 
ID

FROM DBC.TABLE2

WHERE ROWNUM < 50
)
;QUIT;

The error is below but doesn't make sense as my credentials are correct?

 

ERROR: The MYLIB engine cannot be found.
ERROR: A Connection to the mylib DBMS is not currently supported, or is not installed at your site.

Show the code from the LOG with error message.

The error would make me think the actual submitted code used:

libname oracle mylib ...

The engine, such as oracle, when used should follow the libref

OscarBoots2
Calcite | Level 5

Thanks ballardw,

 

The code submitted is in the order I posted.

 

such as;

libname mylib oracle user=XXXXXX pw=XXXXXX 
path="(DESCRIPTION=
		(ADDRESS = (PROTOCOL = TCP) 
			(HOST = XXXXXXXXXXX.com)(PORT = 1234))
				(CONNECT_DATA = (SERVICE_NAME=XXXXXX)))";

Any ideas as what may be wrong otherwise?

 

Thanks

Damo
SAS Employee

Hi @OscarBoots2

 

 

If you want to reuse a previously defined library, I think you have to use "connect using libref".

 

In your case, it would look like this.

 

Libname mylib oracle ...;

PROC SQL;
  CONNECT USING mylib;
  ...;
DISCONNECT FROM MYLIB;
QUIT;

 

This is new with SAS 9.3.

 

Hope that helps.

 

Cheers,
Damo

OscarBoots2
Calcite | Level 5

Hi Damo,

 

It's strange but the word CONNECT is coloured Orange?

 

If I remove the ';' after 'proc sql noprint' it goes back to black as it should be?

 

Any ideas?

Damo
SAS Employee

Hi @OscarBoots2

 

Can you post the entire code and its log ?

Did you try to apply an existing sample code to your case, just to see the result ?

 

Cheers,
Damo

SASKiwi
PROC Star

@Damo - I tried this in EG 7.1 and I can reproduce the orange colour error. It appears EG doesn't colour code CONNECT USING correctly. The code runs fine though.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2057 views
  • 0 likes
  • 4 in conversation