Menu

#433 Add support for SET TERMINATOR inline

open
DB2 Plugin (12)
5
2024-11-30
2011-08-05
Jeff
No

After quite a bit of searching, I found where to set the SQL terminator character (under session properties) so I could define a stored procedure.

It would be nice if the plugin allowed the standard in the SQL window like this:

--#SET TERMINATOR !

(procedure definition here) !

--#SET TERMINATOR ;

Is it possible for the DB2 plugin to support this?

Thanks,

Jeff Bowles

Discussion

  • Ilya Basin

    Ilya Basin - 2015-06-23

    Unlike db2 CLP, IBM DataStudio now has its own hint "ScriptOptions". IMO, squirrel should support both.

    Example:

    --<ScriptOptions statementTerminator="^"/>
    --#SET TERMINATOR ^
    -- hint for data studio and hint for clp/Control center
    -- DROP FUNCTION xtabcols^
    
    CREATE FUNCTION xtabcols (
    @TBNAME varchar(128),
    @TBCREATOR_ varchar(128)
    )
        RETURNS varchar(4000)
    F1: BEGIN ATOMIC
        declare @S, @RSLT varchar(4000);
        declare @COLNO INT DEFAULT 0;
        declare @TBCREATOR varchar(128);
    
        -- end decl
        SET @TBCREATOR = @TBCREATOR_;
        IF @TBCREATOR_ IS NULL or @TBCREATOR_ = '' THEN
            SET @TBCREATOR = CURRENT_SCHEMA;
        END IF;
    
        L1: while(1=1) do
            SET @S = ( SELECT NAME
            FROM SYSIBM.SYSCOLUMNS
            WHERE 1=1
            AND TBNAME = @TBNAME
            AND COLNO = @COLNO
            AND TBCREATOR = @TBCREATOR
            );
            if (@S IS NULL) then
                leave L1;
            end if;
    
            SET @RSLT = coalesce( @RSLT || ',' , '') || @S;
    
            set @COLNO = @COLNO + 1;
        end while;
    
        RETURN 
        values @RSLT;
    END
    ^
    
     
  • Gerd Wagner

    Gerd Wagner - 2024-11-30

    Pull request https://github.com/squirrel-sql-client/squirrel-sql-code/pull/51 is committed and will be available in future snapshots and versions

    Excerpt from change log:

    '#433 | Pull request: https://github.com/squirrel-sql-client/squirrel-sql-code/pull/51
    To change the statement separator during SQL execution, use the following command on a separate line:
    --#SET TERMINATOR <separator>
    This command does not change the separator permanently but for a single SQL execution only.
    See also menu File --> New Session Properties --> tab SQL --> section "Statement separator"
    Thanks to Roland Tapken for the pull request</separator>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.