~~Title: Knowledge Base: Setting SQL Command Delimiters~~
~~NOTOC~~

<html><font color=#990000 size="+2"><b>Knowledge Base: TruView Application Workbench (SQL)</b></font></html>

\\

===Setting SQL Command Delimiters:  How to set a delimiter for SQL commands that span multiple lines or have special characters.===

\\

The SQL Workbench environment allows users to set a **DELIMITER** character that will be used to terminate a line.  This
is actually part of the standard NetBeans capability and can be done in the following way:

<code sql>

DELIMITER #

CREATE PROCEDURE ST_GET_NEXT_JFT_SEQUENCE_ID(IN sequenceName VARCHAR(100), OUT sequenceId BIGINT)
BEGIN
    UPDATE st_jft_Sequence SET sequence_id = sequence_id+1 WHERE sequence_name = sequenceName;
    SELECT sequence_id INTO sequenceId FROM ST_JFT_SEQUENCE WHERE sequence_name = sequenceName;

    IF sequenceId IS NULL
    THEN
      INSERT INTO ST_JFT_SEQUENCE (sequence_name,sequence_id) VALUES (sequenceName,1);
      SET sequenceId = 1;
    END IF;
END
#
</code>

In this example we are creating a stored procedure in DB2 and require the use of semicolon as a line separator inside the stored procedure body.
To accomplish this, set the delimiter to something other than semicolon and don't forget to terminate the command with the new delimiter.
