Go Up to Procedures and Triggers
Comment syntax allows programmers to add comments to procedure and trigger code or SQL scripts.
There are two different types of comments that you can use:
The simple comment: A comment that starts with a special symbol and ends with a new line.
- Note: The simple comment syntax is only available starting with database engine version InterBase 2017.
-- comment text
The bracketed comment: A comment that starts and ends with a special symbol. It may be multi-line.
/* comment text more comment text another line of comment text */
Regardless of the type of comment that you use, you may start a comment anywhere in a line, but with a simple comment you need to keep in mind that the comment area stops after new line. In order to use the simple comment syntax for a multi-line comment, you need to start each line with the special symbol. For example:
A multi-line bracketed comment:
/* my multi-line comment is this text */
A multi-line simple comment:
-- my multi-line -- comment is this -- text
You can place comments on the same line as code, which makes them inline comments.
It is good programming practice to state the input and output parameters of a procedure in a comment preceding the procedure. It is also often useful to comment local variable declarations to indicate what each variable is used for.
Examples The following
isql samples illustrate some ways to use comments:
/* * Procedure DELETE_EMPLOYEE : Delete an employee. * * Parameters: * employee number * Returns: * -- */ CREATE PROCEDURE DELETE_EMPLOYEE (EMP_NUM INTEGER) AS DECLARE VARIABLE ANY_SALES INTEGER; -- Number of sales for emp. BEGIN . . .
/* This script sets up Change Views Subscriptions on the EMPLOYEE table. */ CONNECT "emp.ib" USER 'SYSDBA' password 'masterkey'; COMMIT; CREATE SUBSCRIPTION sub ON EMPLOYEE FOR ROW (INSERT, UPDATE, DELETE); COMMIT;
-- Create a subscription on Employee table CREATE SUBSCRIPTION sub1 ON EMPLOYEE FOR ROW (INSERT, UPDATE); COMMIT;
- Simple comment followed by another SLC
-- One more comment CREATE SUBSCRIPTION sub2 ON EMPLOYEE FOR ROW (INSERT); COMMIT;
- Simple comment followed by another SLC with leading whitespace
-- One more comment followed by leading whitespace before CREATE below CREATE SUBSCRIPTION sub3 ON EMPLOYEE FOR ROW (INSERT, UPDATE, DELETE); COMMIT; SHOW SUBSCRIPTIONS; SELECT COUNT(*) -- inline comment 1 FROM RDB$DATABASE; SELECT COUNT(*) -- inline comment 2 FROM RDB$DATABASE; COMMIT; SET TERM ^;
- Create a stored procedure with inline comments
CREATE PROCEDURE test_proc ( p1 INTEGER, -- Param 1 p2 VARCHAR(68) -- Param 2 ) RETURNS (op1 INTEGER) -- Output param AS DECLARE variable v1 INTEGER; DECLARE variable v2 VARCHAR(150); -- Variable 2 BEGIN -- sample comment 1 -- sample comment 2 -- return input value multiplied by 10 v1 = p1 * 10; op1 = v1; SUSPEND; END^ SET TERM ;^ COMMIT; SHOW PROCEDURE test_proc; SELECT op1 FROM test_proc (2, NULL);