Db2

Db2

Where DBAs and data experts come together to stop operating and start innovating. Connect, share, and shape the AI era with us.


#Data


#Data
#Databases
#Operatingsystems
#Db2
#Databasesolutions
 View Only
  • 1.  errors during creating function

    Posted 12/16/20 09:09 AM

    Hello,

    Probably there is something what I just can't recognize...

    What's my problem? I try to create some function, below script:

    CREATE FUNCTION unhex(in VARCHAR(32000) FOR BIT DATA)

    RETURNS VARCHAR(32000)

    LANGUAGE SQL

    CONTAINS SQL

    DETERMINISTIC

    NO EXTERNAL ACTION

    BEGIN ATOMIC

    RETURN in;

    END

    Nothing special, but when I run #db2 -tvf script_with_function, a have such error:

    db2 -tvf unhex_function

    CREATE FUNCTION unhex(in VARCHAR(32000) FOR BIT DATA)

    RETURNS VARCHAR(32000)

    LANGUAGE SQL

    CONTAINS SQL

    DETERMINISTIC

    NO EXTERNAL ACTION

    BEGIN ATOMIC

    RETURN in

    DB21034E The command was processed as an SQL statement because it was not a

    valid Command Line Processor command. During SQL processing it returned:

    SQL0104N An unexpected token "END-OF-STATEMENT" was found following "N ATOMIC

    RETURN in". Expected tokens may include: "JOIN <joined_table>". LINE

    NUMBER=8. SQLSTATE=42601

    DB21007E End of file reached while reading the command.

    Any ide waht I do wrong?

    Best Regards

    Sebastian





    #Db2
    #Db2forLUW
    #Support
    #SupportMigration


  • 2.  RE: errors during creating function

    Posted 01/07/21 01:11 AM

    Try this.

    [db2inst1]$ db2 -td_function

    CREATE FUNCTION unhex(in VARCHAR(32000) FOR BIT DATA)

    RETURNS VARCHAR(32000)

    LANGUAGE SQL

    CONTAINS SQL

    DETERMINISTIC

    NO EXTERNAL ACTION

    BEGIN ATOMIC

    RETURN in;

    END

    DB20000I The SQL command completed successfully.

    Here, I used '' as a statement termination character.

    Ref. Command line processor optionshttps://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0010410.html





    #Db2
    #Db2forLUW
    #Support
    #SupportMigration


  • 3.  RE: errors during creating function

    Posted 01/07/21 06:21 AM

    Thank You very much,

    Now it works :).





    #Db2
    #Db2forLUW
    #Support
    #SupportMigration