Connecting to a remote DB on a UNIX server with SQL
0
Q:
Connecting to a remote DB on a UNIX server with SQL
I am trying to connect to a remote DB on a UNIX server. I am using embedded SQL statements to achieve this task. I have a file that contains DB name, ID & PW that I pass to the connect statement, rather than hardcoding the info to the program (for security reasons).

C EstConnect BegSr
*
C Eval NumAtmpts = 0
C Eval Connected = No
*
C DoW NumAtmpts <= 3
*

THIS CODE ERRORS OUT IN DEBUG SQLCOD = SQL0113 or SQL0188

C/EXEC SQL
C+ CONNECT TO :Db USER :Id USING :Pw
C/END-EXEC
*
THIS CODE ERRORS OUT IN DEBUG SQLCOD = SQL0113 or SQL0188


I ALSO TRIED SUBSTRINGING THE CONNECT STATEMENT AS:

CONNCT = “CONNECT TO QATMDM USER EDITST USING xxxxxxx” WITH THE SAME ERROR RESULT
DOES THE PASSWORD NEED TO BE ENCRYPTED, AND IF SO HOW IS THAT DONE???


C If SQLCOD = NoSqlError OR
C SQLCOD = Con_Exists
C Eval Connected = Yes
C Leave
C EndIf
*
C Eval NumAtmpts = NumAtmpts + 1
*
C Enddo
C *INZSR BegSr
C Move ' ' WRTHDR 1
*
C *ENTRY Plist
C Parm INVALS 23
C Parm GIS 1
C Parm RTNCDE 1
C Parm TYPE 2
C Parm APPC 20
*
C MDMKEY KLIST
C KFLD TRXST 5
*
C VNDKEY KLIST
C KFLD TYPE
C KFLD APPC
*
C SQLKEY KLIST
C KFLD TRXST
C KFLD APPC
C KFLD TYPE
*
C Movel '852' TRXST
C MOVEL INVALS INVAL
C MDMKEY CHAIN EMDMCTL
C IF %FOUND
C Qte CAT EMCPW WrkPw
C CAT Qte:0 WrkPw
C Eval WrkPw = %Trim(WrkPw)
C Eval Pw = WrkPw
C Eval Db = EMDBNM
C ENDIF
C If GIS = 'Y'
C OPEN EO852GIS
C Else
C OPEN E852HDRX
C OPEN E852DTLX
C OPEN E852ZAX
C OPEN E852SDQX
C Endif
C EndSr
****************** End of data ****************************************

Here is the code that I put in to concatenate the CONNCT string...


C IF %FOUND
C CONECT CAT EMDBNM:1 CONNCT
C CAT 'USER':1 CONNCT
C CAT EMCID:1 CONNCT
C CAT 'USING':1 CONNCT
C CAT Qte:0 WrkPw
C CAT EMCPW:0 WrkPw
C CAT Qte:0 WrkPw
C CAT WrkPw:0 CONNCT

The code below that is COMMENTED OUT was the first attempt to get this to work.
C* Eval Db = EMDBNM
C* Qte CAT EMCID:0 WrkId
C* CAT Qte:0 WrkId
C* Eval WrkId = %Trim(WrkId)
C* Eval Id = WrkId
C* Qte CAT EMCPW:0 WrkPw
C* CAT Qte:0 WrkPw
C* Eval WrkPw = %Trim(WrkPw)
C* Eval Pw = WrkPw
C ENDIF
ASKED: Nov 4 2008  7:35 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Last Answered: Nov 4 2008  7:35 PM GMT by AS400 - Ask the Expert   395 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0