Re: Get active database name at runtime
Posted in 2004
Sorry, Timothy, I need a syntax that works in SE too.
A.
----- Original Message -----
From: <timothy.a.brown@marconi.com>
To: <deangeli@florence-sculptures.it>
Cc: <informix-list@iiug.org>; <owner-informix-list@iiug.org>
Sent: Tuesday, October 12, 2004 1:26 PM
Subject: Re: Get active database name at runtime
>
>
> select odb_dbname
> from sysmaster:sysopendb
> where odb_sessionid=dbinfo('sessionid')and odb_iscurrent="Y">
>
>
>
>
> "Andrea De Angeli"
> <deangeli@florence-scul To:
<informix-list@iiug.org>
> ptures.it> cc:
> Sent by: Subject: Get active
database name at runtime
> owner-informix-list@iiu
> g.org
>
>
> 10/12/2004 06:48 AM
>
>
>
>
>
>
> Hello, folks.
>
> I am currently writing a library function in 4gl for an application that
> must run both in IDS and SE.
>
> Now, the function must perform some actions on a database but can be
called
> by several modules that open and work on other databases.
> Something like:
>
> ---begin module ----
> DATABASE somedb
> DEFINE somerecord LIKE sometable.*
> MAIN
> --- do stuff ---
> CALL library_function(params)
> ---- do other stuff on somedb ---
> END MAIN
> ---end of module----
>
> --- begin library module ----
> DATABASE library
> DEFINE somerecord LIKE sometable.*
> FUNCTION library_function(params)
> DATABASE library # it won't work otherwise: it will be connected to
> somedb!
> --- do stuff on library database
> RETURN somevalue
> END FUNCTION
> --- end library module ---
>
> Problem comes when after the return the application is connected to
library
> db, not the original one. Runtime error.
>
> In IDS there is a nice solution, using explicit database names in selects
> in library_function (SELECT library:sometable ...)
> but that won't work in SE (would it?).
>
> So I need a way to know what db is open when I call library_function: the
> source will become
> --- begin library module ----
> DATABASE library
> DEFINE somerecord LIKE sometable.*
> FUNCTION library_function(params)
> LET saved_database_name = GET_CURRENT_DB_NAME()
> DATABASE library # it won't work otherwise: it will be connected to
> somedb!
> --- do stuff on library database
> DATABASE saved_database_name
> RETURN somevalue
> END FUNCTION
> --- end library module ---
>
> Any hint on the GET_CURRENT_DB_NAME function ?
>
> Thanks to all
>
> Andrea
>
>
>
>
>
> sending to informix-list
sending to informix-list