Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253

    Unanswered: Termination Characters

    I'm at thwe end of my rope. Hopefully someone can provide some direction....

    I'm trying to run just a basic SQL script:

    DECLARE @intPower INTEGER
    DECLARE @intCounter INTEGER
    DECLARE @intBITMAP INTEGER
    SET @intCounter = 0;
    WHILE @intCounter <= 10
    BEGIN
    SELECT @intPower = POWER(2,@intCounter);
    SELECT @intBITMAP = db2admin.BITAND(256, @intPower);
    IF @intBITMAP = @intPower
    BEGIN
    SELECT VALUES @intBITMAP;
    END

    SET @intCounter = @intCounter + 1;
    END

    The problem I'm getting is with the statement termination character. I've tried running it with the semi-colon turned off and kept getting the "End of file reached error". When I run the script above I get the "Unexpected token END-OF-STATEMENT" error.

    Please help - I'm sure I'm missing something very obvious.

    Thanks!

    Anthony




    --select 79 & 64
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Termination Characters

    The normal practice when writing SQL PL (like Triggers, stored procs etc) is to have @ as the delimiter because ; is the default one for PL ..

    In that case, we do

    CREATE PROCEDURE ....
    ------
    -------
    SELECT col1 into :abc from tab1 ;
    -----
    ----
    END @

    ,save in a file file1.sql and do
    db2 -td@ -f file1.sql

    td@ indicates that the deliniter is semi-colon ...

    I'm sure you can apply this explanation to your scenario

    Sathyaram


    Originally posted by ansonee
    I'm at thwe end of my rope. Hopefully someone can provide some direction....

    I'm trying to run just a basic SQL script:

    DECLARE @intPower INTEGER
    DECLARE @intCounter INTEGER
    DECLARE @intBITMAP INTEGER
    SET @intCounter = 0;
    WHILE @intCounter <= 10
    BEGIN
    SELECT @intPower = POWER(2,@intCounter);
    SELECT @intBITMAP = db2admin.BITAND(256, @intPower);
    IF @intBITMAP = @intPower
    BEGIN
    SELECT VALUES @intBITMAP;
    END

    SET @intCounter = @intCounter + 1;
    END

    The problem I'm getting is with the statement termination character. I've tried running it with the semi-colon turned off and kept getting the "End of file reached error". When I run the script above I get the "Unexpected token END-OF-STATEMENT" error.

    Please help - I'm sure I'm missing something very obvious.

    Thanks!

    Anthony




    --select 79 & 64
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Aug 2003
    Location
    Italy
    Posts
    33
    Is there a way to set the delimiter character in the script itself?
    Example:

    Select * from employee;
    ------
    -----
    set delimiter = @

    begin atomic
    for c1 as
    select code as cd from codes
    do
    insert into mycodes values (cd);
    end for;
    end@

    set delimiter = ;
    --------
    -------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •