libname function not disconnecting

Reply
Occasional Contributor
Posts: 17

libname function not disconnecting

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..

Respected Advisor
Posts: 3,124

Re: libname function not disconnecting

"

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

Occasional Contributor
Posts: 17

Re: libname function not disconnecting

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 ?

Respected Advisor
Posts: 3,124

Re: libname function not disconnecting

Occasional Contributor
Posts: 17

Re: libname function not disconnecting

thank you..

Valued Guide
Posts: 3,206

Re: libname function not disconnecting

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 --<-----
Occasional Contributor
Posts: 17

Re: libname function not disconnecting

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.


Valued Guide
Posts: 3,206

Re: libname function not disconnecting

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 --<-----
Valued Guide
Posts: 3,206

Re: libname function not disconnecting

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 --<-----
Ask a Question
Discussion stats
  • 8 replies
  • 394 views
  • 0 likes
  • 3 in conversation