retrieving databases server name
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Platform-Specific Issues
This is a multi-part message in MIME format.
------=_NextPart_000_0019_01BF0C06.C81C53E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi ,I=B4m working with Informix Dynamic Server Version 7.30.FC7 in =
HP-UX systems , Is possible to retrieve all remote databases servers =
names using 4gl ?
sample :=20
when I use dbaccess ( connect option ) there is a list of all =
databases I can connect to like this :=20
SELECT DATABASE SERVER >>
Select a server with the Arrow Keys, or enter a name, then press Return.
----------------------- database@maintcp -------- Press CTRL-W for Help =
--------
store1tcp
store2tcp
store3tcp
store4tcp
.......
PS : I can=B4t use esql-c , there is no compiler for esql-c=20
Tanks
Antonio Roque=20
------=_NextPart_000_0019_01BF0C06.C81C53E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi ,I=B4m working with Informix Dynamic Server =
Version 7.30.FC7=20
in HP-UX systems , Is possible to retrieve all remote databases =
servers=20
names using 4gl ?</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>sample : </FONT></DIV>
<DIV><FONT size=3D2> when I use dbaccess ( connect option ) =
there is a=20
list of all databases I can connect to like this : </FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>SELECT DATABASE SERVER >><BR>Select a server =
with the=20
Arrow Keys, or enter a name, then press Return.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>----------------------- database@maintcp -------- =
Press CTRL-W=20
for Help --------</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>store1tcp</FONT></DIV>
<DIV><FONT size=3D2>store2tcp</FONT></DIV>
<DIV><FONT size=3D2>store3tcp</FONT></DIV>
<DIV><FONT size=3D2>store4tcp</FONT></DIV>
<DIV><FONT size=3D2>.......</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>PS : I can=B4t use esql-c , there is no compiler for =
esql-c=20
</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2> Tanks</FONT></DIV>
<DIV><FONT size=3D2> Antonio Roque </FONT></DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_0019_01BF0C06.C81C53E0--
António Roque schrieb:
> Hi ,I=B4m working with Informix Dynamic Server Version 7.30.FC7 in =
> HP-UX systems , Is possible to retrieve all remote databases servers =
> names using 4gl ?
Hi Antonio,
you could perform the following query:
select name
from sysmaster:informix.sysdatabases
where name not matches "sys*"
order by 1
You would have to prepare, declare and fetch into
a local array, then display with "display array".
Hope this helps,
Chris
Second try...
There is no hidden table where you can get all database servers from
(as far as I know). Nevertheless, here is a possible solution for you.
You have to execute the Stored Procedure (added below) in
your 4GL Code (Prepare and this stuff...)
Execute once as DBA in the database mydatabase:j -- change to what you want
to
-- DROP TABLE informix.which_server;
CREATE TABLE informix.which_server (name VARCHAR(16,0));
GRANT ALL ON informix.which_server TO PUBLIC; COMMIT WORK;
-- DROP PROCEDURE informix.get_server;
CREATE PROCEDURE informix.get_server() RETURNING VARCHAR(16,0);DEFINE local_name CHAR(16);
BEGIN
ON EXCEPTION
RAISE EXCEPTION 100;
END EXCEPTION
SYSTEM '/home/scripts/server.scr'; -- change path as you want
FOREACH
SELECT name
INTO local_name
FROM mydatabase:informix.which_server
RETURN local_name WITH RESUME;
END FOREACH;
END
END PROCEDURE;
GRANT EXECUTE ON informix.get_server TO PUBLIC AS "informix";
------------------------------------------------------------------------------
Create the file "server.scr" in the path given in the upper SYSTEM-call.
>/tmp/server.unl
for i in `grep -iv "#" /usr/informix/etc/sqlhosts|sort -u|cut -d " " -f 1`
do
echo $i"|" >>/tmp/server.unl
done
dbaccess mydatabase <<ENDE
LOAD FROM "/tmp/server.unl" INSERT INTO informix.which_server; COMMIT WORK;
ENDE
rm /tmp/server.unl
I think that might work for your purposes.
Good night,
Chris
Second try...
There is no hidden table where you can get all database servers from
(as far as I know). Nevertheless, here is a possible solution for you.
You have to execute the Stored Procedure (added below) in
your 4GL Code (Prepare and this stuff...)
Execute once as DBA in the database mydatabase:j -- change to what you want
to
-- DROP TABLE informix.which_server;
CREATE TABLE informix.which_server (name VARCHAR(16,0));
GRANT ALL ON informix.which_server TO PUBLIC; COMMIT WORK;
-- DROP PROCEDURE informix.get_server;
CREATE PROCEDURE informix.get_server() RETURNING VARCHAR(16,0);DEFINE local_name CHAR(16);
BEGIN
ON EXCEPTION
RAISE EXCEPTION 100;
END EXCEPTION
SYSTEM '/home/scripts/server.scr'; -- change path as you want
FOREACH
SELECT name
INTO local_name
FROM mydatabase:informix.which_server
RETURN local_name WITH RESUME;
END FOREACH;
END
END PROCEDURE;
GRANT EXECUTE ON informix.get_server TO PUBLIC AS "informix";
------------------------------------------------------------------------------
Create the file "server.scr" in the path given in the upper SYSTEM-call.
>/tmp/server.unl
for i in `grep -iv "#" /usr/informix/etc/sqlhosts|sort -u|cut -d " " -f 1`
do
echo $i"|" >>/tmp/server.unl
done
dbaccess mydatabase <<ENDE
LOAD FROM "/tmp/server.unl" INSERT INTO informix.which_server; COMMIT WORK;
ENDE
rm /tmp/server.unl
I think that might work for your purposes.
Good night,
Chris
Related threads
- Conversion to differeent characters sets
- Problem in changing locale via dbexport/dbimport
- RE: openlink error "Unable to load locale categories"