Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

errors during creating function

  • 1.  errors during creating function

    Posted Wed December 16, 2020 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 Thu January 07, 2021 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 Thu January 07, 2021 06:21 AM

    Thank You very much,

    Now it works :).





    #Db2
    #Db2forLUW
    #Support
    #SupportMigration