ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Embedded remote SQL with no SQL Package?

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

  • Embedded remote SQL with no SQL Package?

    If I am on SystemA, and I have an SQLRPGLE program with this remote access SQL:

    Code:
      exec sql
        insert into SystemB/myLib/MyTable
       values(1,2,3);
    Then I know I need an SQL Package for this program on SystemB.

    If I was to run this SQL using RUNSQL, RUNSQLSTM, or STRSQL, then of course I don't need an SQL Package.

    Now I thought, you could do this from SQLRPGLE with no SQL Package, if you used PREPARE and EXECUTE

    Code:
      sql = 'insert into SystemB/myLib/MyTable values(1,2,3)';
      exec sql
        prepare RemoteWrite from :sql;
      exec sql
        execute RemoteWrite;
    or EXECUTE IMMEDIATE

    Code:
      sql = 'insert into SystemB/myLib/MyTable values(1,2,3)';
      exec sql
        execute immediate :sql;
    And I am sure I have done this before and it has worked. But now it's failing saying no SQL Package found.

    Has something changed to make this not work any more? Or did I imagine it and it's actually never worked?

  • #2
    I realised my error. This type of dynamic SQL will attempt to create the required SQL package on the remote system if it doesn't already exist, and the SQL Package library the program was compiled with does not exist on SystemB

    However, I think it might be a bug with execute immediate that no error is being returned to the RPGLE program: the statement completes with SQLSTT = 00000 even though it failed.

    Comment

    Working...
    X