Re: Determining what database your connected to in a SP
Posted in 1998
David,
Try the sysmaster database. The following will give you info on the
instance you're running on:
select * from sysmaster:sysconfig
where cf_name = 'DBSERVERNAME'
This one will tell you which database you're connected to:
select sqs_dbname
from sysmaster:syssqlstat
where sqs_sessionid+0 = dbinfo('sessionid');
Don't ask me why you need the +0 in the sql above. It doesn't seem to
work without it.
Hope this helps
Cheers,
Gabor
D. Sandmann wrote:
>
> I have a stored procedure that is distributed accross many databases
> (development, testing, certification, training and production). The
> development and testing db reside on the same box in two different
> instances. The certification and training database reside on the same
> box on the same instance. The production database resides on its own
> system and instance.
>
> The stored procedure makes a system call that runs a shell script which
> then calls a 4GL program to generate a report.
>
> 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.
>
> I do not want to hardcode that information into the stored procedure
> because we sometimes take a snapshot of the production database and
> place the snapshot on the other databases.
>
> Any help!!
>
> Thanks in advance,
> David S.