ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQLRPGLE program to execute SQL statement on remote DB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQLRPGLE program to execute SQL statement on remote DB

    Hello All,

    I want to connect to another ISeries DB2 database using SQLRPGLE program to do some calculation on it. What I did shows bellow, but I can?t compile this code & thoughts something very wrong in my code.
    Is it possible? Any idea please..

    Code:
    /free                                                           
       *Inlr = *On;                                                 
       Exec SQL SET OPTION                                          
                   Naming    = *Sys,                                
                   Commit    = *None,                               
                   UsrPrf    = *User,                               
                   DynUsrPrf = *User,                               
                   Datfmt    = *iso,                                
                   CloSqlCsr = *EndMod;                             
                                                                    
       Exec SQL  CONNECT TO LIVEDB USER myname USING 'mypass';  
                                                                    
       Exec SQL DECLARE CSR1 CURSOR FOR                             
                SELECT * FROM myLib/myFILE1;                       
                                                                    
       Exec SQL OPEN CSR1;        
    ?..
    ??
    ?? 
       Exec SQL CLOSE CSR1;      
                              
       Exec DISCONNECT LIVEDB;
    Code:
    SQL0084  30      17  Position 36 SQL statement not allowed.
    Thanks
    dhanuxp

  • #2
    Re: SQLRPGLE program to execute SQL statement on remote DB

    nice...now which line of code is line 17? i'm guessing it's the CONNECT statement. IIRC the user and password must be host variables, not strings...
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: SQLRPGLE program to execute SQL statement on remote DB

      Originally posted by tomholden View Post
      nice...now which line of code is line 17? i'm guessing it's the CONNECT statement. IIRC the user and password must be host variables, not strings...
      Thanks Tom gr8!!!

      Yes, it was a problem of CONNECT statement & i change it to;
      Code:
      Exec SQL CONNECT TO :RDBAX USER :USERX USING :PASSX;
      Thanks again tom !!

      dhanuxp

      Comment

      Working...
      X