I am using DB2 LUW, but got error when try to create the function...
[Code: -104, SQL State: 42601] An unexpected token "END-OF-STATEMENT" was found following "END". Expected tokens may include: "JOIN <joined_table>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.28.11
CREATE OR REPLACE FUNCTION FUNC_TT ()
RETURNS TABLE (ID CHAR(1))
LANGUAGE SQL
READS SQL DATA
NO EXTERNAL ACTION
DETERMINISTIC
BEGIN ATOMIC
RETURN
SELECT '1'
FROM SYSIBM.SYSDUMMY1;
END
This is a frequently asked question.
Currently shipping versions of DBVisualizer allow by default SQL Block Identifiers (characters you use to specify the start and the end of a block) , and DbViZ also allows the @delimiter command to let you choose a character (or two characters) to temporarily-indicate the end of a block.
Read the Dbvis docs carefully.
See the documentation here https://www.dbvis.com/docs/ug/working-with-sql/executing-complex-statements/
But take care. If you plan to deploy scripts using a different automated tool (different from Dbvisualizer) then you need a different method. This will depend on the tool you use for such deployments. Most people use the command-line and scripting, in which case the Db2 CLP (command line processor) is very script friendly. It supports specifying the delimiter within the SQL script via the --#SET TERMINATOR
method, and also allows to specify the block terminator on the command-line via options (-td
...) . For example to use the @ symbol to indicate the end of a block when using the Db2 command-line-processor to submit the SQL, you can use either --#SET TERMINATOR @
inside the script (you can use it as many times as you like inside a script, including to revert back to the default ; when you want to use non-block simple statements again), or as alternate you can specify -td@
on the command-line in which case that delimiter will apply to every statement inside the script being executed as a script via db2 -tf your_script.sql -td@