on 07-15-2015 7:41 AM
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 = (😛 + 1) * 6;
c = :i;
END;
END FOR;
t = SELECT * FROM TBL;
SELECT COUNT(*) INTO a FROM :t;
b = 😛 + :a + 1;
d = MONTH(CURRENT_DATE);
IF :d > 6
THEN
c = :c + 1;
ELSE
c = :c + 2;
END IF;
END;
Thanks
That's explicitly mentioned in the SQLscript reference!
If you want to access the value of the variable, then use :var
in your code.
If you want to assign a value to the variable, then use var in your code
Check the documentation that comes with your SAP HANA studio (F1!):
SAP HANA SQLScript Reference > Imperative SQLScript Logic
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.