Re: Determining Server/Client Version at RunTime
Posted in 1999
I would like to add actual code to my message. See below.
Vardan Aroustamian <Vardan.Aroustamian@chase.com> wrote:
> Jake Colman <colman@ppllc.com> wrote:
>
> >
> > When I type this into dbaccess I get
> >
> > "Unknown first argument of dbinfo(version)"
>
> Well, I thought it is in 7.x, but it is in 7.3. Sorry for that.
> Anyway it's a good idea to mention your server version and OS
> in the question.
>
> >
> > Also, where in the docs did you find this?
>
> dbinfo( 'version', ... ) documented in 7.3 SQL: Syntax p. 4-66>
> sysmaster:syssqscb is not documented (besides sysmaster.sql :-)
>
> Documented way, I suppose, should be some stored procedure with
> system call and your shell script will analyze output of onstat
> and create temporary table that you can check.
>
Here we are.
-- Just draft version. Please, don't check the quality
-- But opinions how to achieve the original goal better are welcomed
-- SQL first
create table versions (
sid int,
server char(64),
client char(10)
);
-- Don't ask me why char(64) and (10). Let it be 64 and 10.
create procedure get_version( this_sid int )
returning char(64), char(10);
define s_this_sid char(16);
define s_server char(64);
define s_client char(10);
let s_this_sid = this_sid;
delete from versions where sid = this_sid;
system 'get_version.sh ' || s_this_sid;
select server, client into s_server, s_client
from versions where sid = this_sid;
return s_server, s_client;
end procedure;
-- ## then shell script ##################
#!/bin/ksh
TEMPFILE=/tmp/tmp_versions
this_sid=$1
onstat -g sql > $TEMPFILE
server=$(head -2 $TEMPFILE | awk -e '/Informix/ { print $1" "$2" "$3" "$4"
"$5; }')
client=$(cat $TEMPFILE | awk -e '{ if ( $1 == '$this_sid' ) { print $8; }
}')
(
dbaccess vardan - <<!
insert into versions values ( $this_sid, "$server", "$client" );!
) > /dev/null 2>&1
rm $TEMPFILE
#######################
-- then just
execute procedure get_version( dbinfo( 'sessionid' ) );
--
I'm assuming you have 'vardan' database on each instance ;-)
Take care
Vardan
> AFAIK onstat -g sql returns 'F.E. Vers' column in 7.2x
> so you can get that info. I don't remember is it in 7.1x
>
> Best regards
>
> Vardan Aroustamian
>
> >
> > Thanx!
> >
> > ...Jake
> >
> >
> > >>>>> "Vardan" == Vardan Aroustamian <Vardan.Aroustamian@chase.com>
> writes:
> >
> > Vardan> Jake Colman <colman@ppllc.com> wrote:
> > >>
> > >> Is there a way for me to determine at runtime the client version
I
> am
> > Vardan> running
> > >> and the version of server to which I am connecting?
> >
> > Vardan> Yes (assuming your server is 7.x)
> >
> > Vardan> select dbinfo( 'version', 'full' ) server,
> > Vardan> scb_feversion client
> > Vardan> from sysmaster:syssqscb
> > Vardan> where scb_sessionid = dbinfo( 'sessionid' );
> >
> > >>
> > >> Thanx!
> > >>
> > >> --
> > >> Jake Colman
> > >>
> > >> Principia Partners LLC Phone: (201) 946-0300
> > >> Harborside Financial Center Fax: (201) 946-0320
> > >> 902 Plaza II Beeper: (800) 505-2795
> > >> Jersey City, NJ 07311 E-mail: colman@ppllc.com
> > >> E-mail: jcolman@jnc.com
> > >> web: http://www.ppllc.com
> > >>
> >
> > Vardan> Vardan
> >
> > Vardan> --
> > Vardan> vaar@geocities.com
> >
> > --
> > Jake Colman
> >
> > Principia Partners LLC Phone: (201) 946-0300
> > Harborside Financial Center Fax: (201) 946-0320
> > 902 Plaza II Beeper: (800) 505-2795
> > Jersey City, NJ 07311 E-mail: colman@ppllc.com
> > E-mail: jcolman@jnc.com
> > web: http://www.ppllc.com
> >
>
> --
> vaar@geocities.com
>
>