Is it possible to have two connects in the same rexx script to
different DB's?
I have to get data form on DB (with specifics selects and filter out
some values with RExx) and save the results into another DB?
I know from Wscripts and MS-Sql that you can build just two objects
but I did not see something like that in REXX.
Thanks in advance for your help
With Rexx/SQL it certainly is (and to different database platforms),
but it might depend on what operating system you are on and what the
database platforms are. But based on the subject line it doesn't look
like you are using Rexx/SQL.
Cheers, Mark
Hi Mark,
It is rexx (obj rexx) and DB2 on Windows I know in z/os it would look
like
"ADDRESS DSNREXX "CONNECT" SUBSYS
IF SQLCODE ^= 0 THEN CALL SQLCA "
Along that line, is it possible to initiate an application remotely.
For example, a DLL or EXE resides on a server and is accessible as a
network shared drive. Is there a method of initiating the DLL or EXE
from the client such that it executes on the server (normally, the OS
would copy it locally)?
--
Gary Scott
mailto:garylscott@sbcglobal dot net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
If you want to do the impossible, don't hire an expert because he knows
it can't be done.
-- Henry Ford
And I can vouche for that ability. It will be part of one of my
Rexx/SQL presentations at this year's Symposium (next week). I'm not
dealing with different database platforms, but I do make connections
to 2 different MySql databases in the same application. If the
internet connection is good enough in the conference room, I'll even
demostrate connecting to MySQL databases on different servers in the
same application.
BTW: I will demostrate this ability using both procedural coding and
object oriented coding. If you've ever wondered exactly what
"Encapsulation" was in regards to ooRexx, this oo demo should clarify
it. :-)
Going to miss seeing you Mark! But be assured I've got nothing but
GOOD to say about Rexx/SQL - well maybe one thing I don't like, but
who's counting. :-)
Lee
Whichever method you use, you MUST Catalog your NODE and DB via the CATALOG
command. BTW, run your rexx in the DB2CLP window.
This is how I normally do it.
a. Create a generic rexx routine with 2 arguments, dbname and sql such that
the routine simply connects to the db (read a file containing passwords for
each db likely to be used so you know what password to pass to the Connect
statement). The generic routine would then either issue the prepare and
either EXECUTE IMMEDIATE depending on whether the sql is doing SELECT or
UPDATE/INSERT./DELETE). Result sets are saved onto stem variables which are
returned by the generic routine and lastly DISCONNECT is issued.
b. Any rexx program can then just call this multi-purpose generic routine
pointed to different databases irrespective of where they are and manipulate
the data accordingly. Using this method, it was so easy doing a COMPARE 2
databases script finding differences between dev and prod structures simply
by querying the sysibm catalogues with the same SQL on the different servers
saving the data onto different stems and then comparing the two stems for
variances....
HTH,
Ven
<cbe...@gmail.com> wrote in message
news:1177151608.5...@q75g2000hsh.googlegroups.com...
Here my code:
CONNECTVAR.0 = 1 /* ONLY SETTING ONE OPTION */
CONNECTVAR.1 = 2 /* TYPE 1 CONNECT */
CALL RXFUNCADD 'SQLDBS',
'SQLAR','SQLDBS'
CALL RXFUNCADD
'SQLEXEC','SQLAR','SQLEXEC'
CALL RXFUNCADD
'SQLDB2','SQLAR','SQLDB2'
CALL SQLDBS 'START DATABASE
MANAGER'
/
*
// INITIALIZE GLOBAL
VARIABLES
*/
DBNAME = 'METADB1'
DBNAME1 = 'METADB'
SAY "SETTING CLIENT CONNECT TYPE 2 "
CALL SQLDBS 'SET CLIENT USING :CONNECTVAR'
CALL SQLEXEC 'CONNECT TO' DBNAME
CALL SQLEXEC 'CONNECT TO' DBNAME1
CALL SQLEXEC 'SET CONNECTION' DBNAME
SQLCMD = "SELECT *
"
SQLCMD = SQLCMD || "FROM USER01.GRP_MEMBERS
"
CALL SQLEXEC "DECLARE C1 CURSOR FOR
S1"
CALL SQLEXEC "PREPARE S1
FROM :SQLCMD"
CALL SQLEXEC "DESCRIBE S1
INTO :OUTSQLDA"
CALL SQLEXEC "OPEN
C1"
OUTSTEM.0 =
1
DO UNTIL(SQLCA.SQLCODE <>
0)
CALL SQLEXEC "FETCH C1 USING
DESCRIPTOR :OUTSQLDA"
IF SQLCA.SQLCODE = 0 THEN
DO
SAY SEP || OUTSQLDA.1.SQLDATA || SEP SEP || OUTSQLDA.
2.SQLDATA || SEP SEP ||OUTSQLDA.3.SQLDATA || SEP
END
END
CALL SQLEXEC "CLOSE
C1"
CALL SQLEXEC 'SET CONNECTION' DBNAME1
SQLCMD1 = "SELECT *
"
SQLCMD1 = SQLCMD || "FROM
USER01.TCEOCLASSES"
CALL SQLEXEC "DECLARE C1 CURSOR FOR
S1"
CALL SQLEXEC "PREPARE S1
FROM :SQLCMD1"
CALL SQLEXEC "DESCRIBE S1
INTO :OUTSQLDA"
CALL SQLEXEC "OPEN
C1"
OUTSTEM.0 =
1
DO UNTIL(SQLCA.SQLCODE <>
0)
CALL SQLEXEC "FETCH C1 USING
DESCRIPTOR :OUTSQLDA"
IF SQLCA.SQLCODE = 0 THEN
DO
say SEP || OUTSQLDA.1.SQLDATA || SEP SEP || OUTSQLDA.
2.SQLDATA || SEP SEP ||OUTSQLDA.3.SQLDATA || SEP
END
END
CALL SQLEXEC "CLOSE
C1"
CALL SQLEXEC "CONNECT RESET"
EXIT
I GOT THIS ERRORS...
SQL0843N The server name does not specify an existing connection.
SQLSTATE=08003
ANY IDEA?