BookmarkSubscribeRSS Feed
sasbeginner_us
Calcite | Level 5

Hi,

We have a libname function as below and it is connecting & provides 0 return code. But the problem is, it is not disconnecting (i think), it leaves idle sessions on the teradata side. Just want to know what exactly this function does ? whether it connects & disconnects to/from teradata ? or Do i need to explicitly specify how to disconnect from teradata ?

rc_libname = libname(teradata_libname, ,unix_engine   , " server='&com_dbserver' schema='&com_db' user='"||trim(teradata_userid)||"' password='"||trim(teradata_password)||"'" );

To add to that, we have a dsid function statements after rc_libname return code check... not sure if it impacts the teradata connection..

dsid=open(trim(teradata_libname)||"."||trim(teradata_table)||trim(teradata_where), "IS");  

rc_close    = close(dsid);

Thanks in advance..

8 REPLIES 8
Haikuo
Onyx | Level 15

"

The LIBNAME function assigns or deassigns a libref from a SAS library. When you use the LIBNAME function with two or more arguments, SAS attempts to assign the libref. When you use one argument, SAS attempts to deassign the libref. Return codes are generated depending on the value of the arguments that are used in the LIBNAME function and whether the libref is assigned."

SAS(R) 9.3 Functions and CALL Routines: Reference

sasbeginner_us
Calcite | Level 5

Thank you... i will check this. Can you please explain me what dsid=open() does ? is it like a read/select statement but it wont establish a connection ?

sasbeginner_us
Calcite | Level 5

thank you..

jakarman
Barite | Level 11

Your libname is starting a session. As I see a Teradata being mentioned pleas use shared connections. It is some special RDMS behaving a litrle bit different as other OLTP DBMS systems
The dsid open opening a table that is mire like a transaction at the Teradata site.

These are advanced  functions not for beginners when you are a beginner it more appropriate to use the more common easy statements of a beginners approach.

---->-- ja karman --<-----
sasbeginner_us
Calcite | Level 5

Hi, I know it is an advacned function but I am trying to put a fix to this existing code. The problem with the above stmt is that it is not disconnecting from teradata as this code loops till a certain time. I tried to use rc_libname = libname(teradata_libname); to disconnect but getting an error

"ERROR: Unable to clear or re-assign the library TERAlib_ because it is still in use.". Please assist me in this.


jakarman
Barite | Level 11

As long as there is some TD processing going on you cannot break interrupt that.

What could be done is killing the Sas session that started that TD process completely with an OS cmd like kill pid.

That will signal the TD process also. Do not use the -9 option but let it gracefully ending.

---->-- ja karman --<-----
jakarman
Barite | Level 11

Your error message is telling the session has been made and connected. As you can view open tables with eguide that opening can be the lock on the libname

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1392 views
  • 0 likes
  • 3 in conversation