Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Using : before variable in procedures

$
0
0

Hello All,

I have a question related to the use of ":" before variables in procedures,

i highlighted some of the variables in the example below, do we need to use ":" before these variables and when we have to use them and when we should not and how can it affect the result.

For example :

 

CREATE PROCEDURE DUMMY

LANGUAGE SQLSCRIPT AS

BEGIN

            DECLARE a, d, i INT;

            DECLARE b INT = 0;

            DECLARE c INT DEFAULT 0;

            DECLARE n VARCHAR(20) DEFAULT 'this code is junk';

            CREATE GLOBAL TEMPORARY TABLE TBL (COL INT);

            FOR i in 1..3 DO

                        INSERT INTO TBL VALUES (:i);

                        BEGIN

                                   DECLARE d INT;

                                   b = (:b + 1) * 6;

                                   c =:i;

                        END;

            END FOR;

            t = SELECT * FROM TBL;

            SELECT COUNT(*) INTO a FROM :t;

            b = :b + :a + 1;

            d = MONTH(CURRENT_DATE);

            IF :d> 6

            THEN

                        c = :c + 1;

            ELSE

                        c = :c + 2;      

            END IF;

END;

 

 

Thanks


Viewing all articles
Browse latest Browse all 5653

Trending Articles