EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

SQL Update a Table with a dot

  • 1.  SQL Update a Table with a dot

    Posted Tue May 03, 2016 10:10 AM

    Hi,

    in our historically grown database (DB2 IBM i V7R1) we have some tables which contain dots in their names.

    Ausw. Objekt     Art         Attribut     FA.ART5     *FILE       PF-DTA       FA.ART5_S   *FILE       PF-DTA       FA.ART6     *FILE       LF           FA.ART7     *FILE       PF-DTA       FA.ART9     *FILE       PF-DTA       FA.ART9_CG  *FILE       PF-DTA       FA.ART9_FE  *FILE       PF-DTA       FA.ART9_S   *FILE       PF-DTA 

     

    How to select or update them with SQL ?

    This doesn't work:

     

            replace satz                with #sql{                        update QS36F.FA.ART5                        set                                A5LFM = :A0LFM                                where                                A5AUFU = :A0AUF                 };

     

     

     

    Kind Regards!

    Marcel-D


  • 2.  Re: SQL Update a Table with a dot

    Posted Tue May 03, 2016 10:12 AM

    have you tried

            replace satz                with #sql{                        update QS36F."FA.ART5"                        set                                A5LFM = :A0LFM                                where                                A5AUFU = :A0AUF                 };

     

    Bram_Callewaert


  • 3.  Re: SQL Update a Table with a dot

    Posted Tue May 03, 2016 10:25 AM

    Thanks for your reply Bram.

     

    I tried this, but that doesn't work.

    EGL0504E REPLACE: Data truncation[sqlstate:22001][sqlcode:-99999] EGL0002I Der Fehler ist in KAPAZ_010_service bei der Verarbeitung der Funktion save_FAART10_A0LFM aufgetreten.

     

    Marcel-D


  • 4.  Re: SQL Update a Table with a dot

    Posted Tue May 03, 2016 02:48 PM

    There is a simple work around: use the long name (more then 10 characters!) possibility. 

    rename table  QS36F."fa.test" to FA_TEST_LONG_NAME 
    rename table  QS36F.FA_TEST_LONG_NAME TO SYSTEM NAME "FA.TEST"             

    After that you can use both select statements as beneath:
    SELECT * FROM  QS36F."FA.TEST" 
    SELECT * FROM  QS36F.FA_TEST_LONG_NAME 

    j.w.a.


  • 5.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 03:50 AM

    Hi,

    thanks for your suggestion.

    But thats not possible because there are some logical files on the physical file...

     

     

     





    Kind Regards!

     

     

    Marcel-D


  • 6.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 03:59 AM

    An other alternative: CREATE VIEW...

     

    And logicals depends on system_table_name so I still think this is a possible solution:

    RENAME TABLE xxxxx/"fa.test" TO FA_TEST_LONG_NAME FOR SYSTEM NAME "fa.test"  

     

    Kind Regards

    Jan Willem.                                                     

    j.w.a.


  • 7.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 04:07 AM

    Ok sorry,

    you are right the rename works.

     

    But I've got still the DATA TRUNCATION error.

     

            replace satz                with #sql{                                update QS36F.FA_ART5_LONG_NAME                                set                                        A5LFM = :A0LFM                                        where                                        A5AUFU = :A0AUF                         };

     

     

    EGL0504E REPLACE: Data truncation[sqlstate:22001][sqlcode:-99999] EGL0002I Der Fehler ist in KAPAZ_010_service bei der Verarbeitung der Funktion save_FAART10_A0LFM aufgetreten.

     

    Marcel-D


  • 8.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 04:09 AM

    I have the same data truncation error on 1 file. It happens very sporadic, and I can't reproduce it.

    If you find a solution or cause for it, i'm very interested in hearing about it.

    Bram_Callewaert


  • 9.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 08:03 AM

    Seems that value of A0LFM has to many characters.....  And keep in mind that some characters take 2 positions. For example ü will use 2 positions for CCSID=37.

    j.w.a.


  • 10.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 08:13 AM

    Hi,

    Thanks again for your reply.

    But that's unfortunately not the problem... Frown

     

    Marcel-D


  • 11.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 10:15 AM

    Hi,

    just one thing I noticed and maybe it is the problem.

     

    In the where clause you have A5AUFU = :AOAUF      Looking at your screen shot, the A5AUFU column s defined as num(2) and the host variable AOAUF is defined as NUM(5).   Did you mean to use the column A5AUF since that is what you had highlighted?  Or is your function argument incorrect?

     

    Mark

    markevans


  • 12.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 10:34 AM

    Thanks Mark....

    thats embarrassing....

     

    Kind Regards!

    Marcel-D


  • 13.  Re: SQL Update a Table with a dot

    Posted Wed May 04, 2016 10:36 AM

    Believe me... I completely understand...done that type of thing many times.

     

    Glad it works and the help from the others on how to get the table name resolved.

    markevans