Re: Determining what database your connected to in a SP
Posted in 1998
Jonathan Leffler wrote:
>
D. Sandmann wrote:
>
> <Snip>
>
> I would like the stored procedure to tell my shell script which
> database/instance it is being called from. Based on that information the
> shell would then know what environment variables to set up and what 4gl
> program to call.
>
> On Mon, 19 Oct 1998 Sujit.Pal@alltel.com wrote:
> > To find the instance name, you could use the following SQL:
> >
> > SELECT cf_effective INTO currinstname
> > FROM sysmaster:sysconfig
> > WHERE cf_name = "DBSERVERNAME";
> >
> > To find the database name, I could think of only this. Maybe somebody
> > could come up with something simpler?
> >
> > [...]
>
> How about:
>
> CREATE PROCEDURE current_database() RETURNING VARCHAR(64);>
> <Snip>
That's all good and dandy, but what about the instance? I haven't seen
an answer to that yet. If we use your SP Jonathan, how about:
SELECT TRIM(sysmaster:current_database()) || "@" || SITENAME
FROM systables
WHERE tabid = 1
Or simply select the two as separate fields.
Cheers,
--
Mark.
+----------------------------------------------------------+-----------+
|Mark D. Stock - Informix SA http://www.informix.com |//////// /|
|mailto:mdstock@informix.com http://www.informix.com/idn |///// / //|
|http://www.iiug.org +-----------------------------------+//// / ///|
| Tel: +27 11 807 0313 |If it's slow, the users complain. |/// / ////|
| Fax: +27 11 807 2594 |If it's fast, the users keep quiet.|// / /////|
|Cell: +27 83 250 2325 |Therefore, "No news: travels fast"!|/ ////////|
+----------------------+-----------------------------------+-----------+