ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

EXTNAME in SQLRPGLE

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

  • Vectorspace
    replied
    I'm assuming this is formatted incorrectly because the whitespaces were removed by the forum:
    D CBP91259Ds E DS Extname(CBP9125901)
    D Template qualified

    And it should actually look like this:
    Code:
    D CBP91259Ds    E DS                  Extname(CBP9125901)
    D                                     Template qualified
    The template keyword means a variable is not actually in the program at run time and so cannot be used. It only exists as a definition at compile time, so other variables can be declared as like() that variable.
    If you want to use CBP91259Ds at run time, you need to remove the template keyword

    Leave a comment:


  • B.Hauser
    replied
    The file name must be embedded in quotes in the EXTNAME keyword:
    Code:
    D CBP91259Ds    E    DS               Extname('CBP9125901')
    BTW why do you need dynamic SQL?
    In this case it is not necessary and static SQL would be (at least for performance issues) the better option.
    With static SQL the ODP (Open Data Path) is reusable and can be kept opened. For sub-sequent execution a full optimization is not needed, only the data in the ODP is updated.
    With dynamic SQL each time the SQL-Statement is performed, a FULL OPEN (full optimization is required)

    Also CLOSQLCSR=*ENDMOD is not a very good idea. Each time the module is left (ended), the ODP is deleted, i.e. even if you use static SQL with reusable ODPs, each time you open the module for executing your SQL statement a FULL OPEN has to be performed and not only for a single SQL statement, but for all SQL Statements.
    ... just in case you'd use Activation Group *NEW it would also be not a good idea, because the ODPs get deleted at the program's end. So each time your program is called a FULL OPEN is required.

    Birgitta
    Last edited by B.Hauser; August 11, 2019, 11:45 PM.

    Leave a comment:


  • Iceberg
    replied
    is this correct 'Exec Sql Fetch WkCrsr INTO :CBP91259Ds' or should i use qualified name for each field...
    Exec Sql Fetch WkCrsr INTO :CBP91259L1Ds_t.C9BKNM

    Leave a comment:


  • Iceberg
    started a topic EXTNAME in SQLRPGLE

    EXTNAME in SQLRPGLE

    Hi,
    Pls let me what wrong with below code,same is giving error as Position 40 Variable CBP91259DS not defined or not usable...

    D CBP91259Ds E DS Extname(CBP9125901)
    D Template qualified

    D CB912592 PI
    D ReturnCode 10
    D COBANK 3S 0
    D COACCT 12S 0

    /Free
    Exec Sql Set Option datfmt=*ISO, closqlcsr=*endmod, commit=*none;
    SqlStmt = 'SELECT * FROM CBP9125901 +
    WHERE C9BKNM = ? AND COACCT = ?';

    Exec Sql Prepare Stmt from :SqlStmt;
    Exec Sql Declare WkCrsr Cursor for Stmt;
    Exec Sql Open WkCrsr Using :COBANK, :COACCT;
    Exec Sql Fetch WkCrsr INTO :CBP91259Ds;
Working...
X