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

    Unanswered: Comments in stored procedures

    I just want to insert some comments at the beginning of a stored procedure that will be a running history of changes madfe to the proc. I've got the right comment marks and in the right place.

    In my SQL editor the comments even appear green (means it's a comment). Here's just a portion of the SQL:

    /* this is where a comment will go*/
    /* and another one */

    CREATE PROCEDURE AIM.CreateAIMRetrievedItem (IN decArchiveRetrievalID DECIMAL(13,0),
    IN strArchiveDocumentID VARCHAR(36),
    IN strAIMDocumentID VARCHAR(256),
    IN dateCaptureDate DATE)
    LANGUAGE SQL
    RESULT SETS 1
    P1: BEGIN
    etc. etc.

    The procedure won't compile with comments. When I take them out, it works just fine.

    What gives?
    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
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Comments in stored procedures

    Originally posted by ansonee
    I just want to insert some comments at the beginning of a stored procedure that will be a running history of changes madfe to the proc. I've got the right comment marks and in the right place.

    In my SQL editor the comments even appear green (means it's a comment). Here's just a portion of the SQL:

    /* this is where a comment will go*/
    /* and another one */


    I don't think you can use C-style comments in SQL code. Try "--" as single-line comment markers

  3. #3
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    Tried the dash-dash comment marker. got the following error:

    Create stored procedure returns -198.
    [IBM][CLI Driver][DB2/6000] SQL0198N The statement string of the PREPARE or EXECUTE IMMEDIATE statement is blank or empty. SQLSTATE=42617

    AIM.CreateAIMRetrievedItem - Build failed.

    This is all I did:

    --comment

    CREATE PROCEDURE AIM.CreateAIMRetrievedItem (IN decArchiveRetrievalID DECIMAL(13,0),
    IN strArchiveDocumentID VARCHAR(36), etc.

    Can you PUT comments in the beginning of stored procedures?

    If I put that same comment smack in the middle of the SQL, compiles just fine. I have a hard tiome believing you can't put comments in stored procedures. Putting comments after the BEGIN just doesn't make any sense.
    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..."

  4. #4
    Join Date
    Dec 2003
    Posts
    78
    Hello,
    i put a comment with
    --comment
    using stored procedure builder.
    The build is successful, but what it did was to move the comment just below CREATE PROCEDURE ....
    statement.

    It does not want it at the top, i suppose
    IBM DB2 Stored Procedure Builder defaultly puts comment like this:

    CREATE PROCEDURE DB2ADMIN.EXAMPLE ( )
    SPECIFIC DB2ADMIN.EXAMPLE
    RESULT SETS 1
    LANGUAGE SQL
    ------------------------------------------------------------------------
    -- SQL Stored Procedure
    ------------------------------------------------------------------------
    P1: BEGIN

  5. #5
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    I feel like an idiot

    Thanks a bunch....!!
    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..."

Posting Permissions

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