1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] In GENERATE_SPREADSHEET SQL on IBM i there are problems if a $ character is present in...

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 9, 2024 às 12:23.

  1. Stack

    Stack Membro Participativo

    If you have a library that begins with a $, such as $BASDTA it seems to throw off the GENERATE_SPREADSHEET scalar function when used in embedded SQL (i.e. exec sql...). At runtime it does not recognise a qualified file name in the SPREADSHEET_QUERY parameter using such a library.

    Minimal example is below: First some setup..

    CRTLIB $MYLIB
    CRTPF FILE($MYLIB/MYFILE) RCDLEN(10)
    RUNSQL SQL('insert into $MYLIB.MYFILE VALUES (''Hello'')') COMMIT(*NONE)


    Source code below. Member type is SQLRPGLE

    ctl-opt DFTACTGRP(*NO);
    dcl-s returncode zoned(5);
    exec sql set :returncode = SYSTOOLS.GENERATE_SPREADSHEET(
    PATH_NAME => '/home/tmcneil/mysheet',
    SPREADSHEET_QUERY => 'select * from $MYLIB.MYFILE',
    SPREADSHEET_TYPE => 'xlsx' ,
    COLUMN_HEADINGS => 'COLUMN')
    ;
    return;


    Results from terminal session when running above...

    WARNING: Could not create system preferences directory. System preferences ar
    e unusable.
    MSGDB0036 - Server returned SQL error
    ([SQL0104] Token . was not valid. Valid tokens: ( NEW FINAL TABLE UNNEST
    LATERAL XMLTABLE JSON_TABLE <IDENTIFIER>.)
    Press ENTER to end terminal session.


    It's complaining about the period in the qualified name as above but after exploration I'm sure that it's the $ sign in the library name that throws it. Doing the same thing with no $ in the name works fine. The SELECT statement above works fine in an ACS or STRSQL session but not here. I'm on V7R4. CCSID for jobs and source file is 37 but system CCSID is 65535, if that's relevant. Any suggestions for a workaround would be most welcome. Thanks in advance. Tony

    Continue reading...

Compartilhe esta Página