Disconnecting the database does not disconnect the database gracefully

sathish

New Member
I need to disconnect the database(ld-wsl) in runtime and need to connect to similar Replication database(logicaldbname-repl_wsl) with differnt logical name into the same session during runtime.
The disconnected database is not shown any more in the datadictionary but the problem is the disonnected database still hold in memory and present in the session.

Two database logical are
1. wsl
2.repl-wsl

Plese find the example of the error.
example:

for each databasename.tablename no-lock.
disp database name.tablename.tablefield.
end.

It gives the compile error saying :
Table tablename is in database wsl and rep-wsl (425)
Table tablename is in database wsl and rep-wsl (425)
Unknown or ambiguous table job. (725)
** Could not understand line 1. (196)


Can anyone advice what needs to be done to disconnec the database gracefully ?
 
Are you doing the connect/disconnect in a top level procedure and then running a program that does the actual access? You must, you know.
 
Thanks Tamhas for your reply!

I am using the three different procedure one for disconnecting the database("wsl")
and another one for connecting the another database("rep-wsl") and then
another procedure for running a program which has to use the database ("rep-wsl")

Please let me know if you require anything more information.

Awaiting for your reply.

-
sathish
 
The issue is the nesting. One has to connect in one procedure and then call a program where the database is accessed, then return to the first program to disconnect.
 
You cannot connect or disconnect a database in the same procedure which you want to reference it.

Create "a.p" like this:
Code:
display dbname.
pause.
Then run:
Code:
connect "sports2000".
run "./a.p".
disconnect "sports2000".
run "./a.p".
 
Tamhas ,
I have tried it but that was not succesfull.

May be i will clear explain the problem i am facing again
I am strating my application with the 4 database
1-a
2-b
3-c
4-d
At certain point of time during some printing operation in the applciation i have to disconnect the 1-a and just after that i need to connect the similar database of 1-a i.e
5-e which contains all the table of 1-a
Disconnection and the connection happens exactly correct but when i use my programme where i have use my logic to print , i have refernced the tablename without the prefix of databasename
it gives the following error.
my programme :
for each databasename.tablename no-lock.
disp database name.tablename.tablefield.
end.
Error:
It gives the compile error saying :
Table tablename is in database 1-aand 5-e (425)
Table tablename is in database 1-aand 5-e (425)
Unknown or ambiguous table tablename. (725)
** Could not understand line 1. (196)
The 1-a database name does not shown in the dictionary after disconnection but it is referncing to some memory

For you refernce i have tried the connection disconnection in same proedure and different procedure.
I think it is clear , if i am not please let me know i will be providing some more information.
Any help will be apprciated.
_
Sathish.
 
it would be helpful if you posted actual code snippets ... me may see things differently than you do.....
 
Code might help, but it is not clear that you have tried
1. Do the connection
2. Run a subprogram
3. Access the database in the subprogram.

This is the only way it works. Database connections have to be established *before* a program is run that accesses the database. With your whole session, the database connections on the command line are created and *then* your startup procedure is run. With dynamic connections, all access must be in a subprogram to the program creating the connection.
 
If the issue is disconnects then the problem may be that other programs higher up in the call stack (or being run persistently) may still have lingering references to the disconnected database.
 
I have tried with two methods
Method - 1
Created x.p
-------------------------------------------------------------------------------------
content:
DISCONNECT VALUE("1-a").
CONNECT -pf VALUE("c:\5-E.pf") .
parameter file(c:\5-E.pf) values
-db 1-5
-ld rep-wsl
-N TCP
-S pornumber
-H hostname
-U demo
Run ./checkdb.p
In the checkdb.p the code is
For each area no-lock.
Disp area.area-code.
End.
--------------------------------------------------------------------------------------
Method - 2
---------------------------
Created x.p

Run ./Discnt.p
Run ./Connt.p
Run ./checkdb.p
------------------------------

Discnt.p
DISCONNECT VALUE("1-a").

Connt.p
CONNECT -pf VALUE("c:\5-E.pf") .
parameter file values
-db 1-5
-ld rep-wsl
-N TCP
-S pornumber
-H hostname
-U demo

Checkdb.p
For each area no-lock.
Disp area.area-code.
End.
------------------------------------------------------------------------------------------------

This is the sample code i have been executing may be this could be helpfull what i am doing
_
SATHISH
 
Tom,

Thanks for your help.
I have checked once again in my application and your correct the reference of the diconnected database still avilable as some files runs persistently before this actually disconnect happens

IS there any way that i can remove the refernce of the disconnected database completely to avoid this kind of error.


Can you please advice.

_
Sathish.
 
Remove or move the reference. If you have persistent procedures which reference the database, you have to get rid of them before the disconnect.

This is all a question of scope. Do all of your connects and disconnects at a top level and then go to a lower level to do any work. When you return to the top level to change the connection, clean up anything you have created. Just good practice.
 
Back
Top