FOR I = 1 TO 10
tRESNUM = ALLTRIM(STR(I))
tRESCAS = 'tRESCAS'+tRESNUM
&tRESCAS = 0.00
ENDFOR
I am converting this fox-pro code to MySQL Stored Procedure.
In Foxpro tRESCAS = 'tRESCAS'+tRESNUM gives tRESCAS1, tRESCAS2,.. and &tRESCAS gives the value which is tRESCAS1 or tRESCAS1 or ... something else.
For example
if I =1 =>
FOR I = 1 TO 10
tRESNUM = ALLTRIM(STR(1))
tRESCAS = 'tRESCAS'+1
tRESCAS1 = 0.00
ENDFOR
If I =2 =>
FOR I = 1 TO 10
tRESNUM = ALLTRIM(STR(2))
tRESCAS = 'tRESCAS'+2
tRESCAS2 = 0.00
ENDFOR
&tRESCAS Automatically take the tRESCAS value tRESCAS1 or tRESCAS2 like this.
In Stored Procedure How Can i get this type of Value?. (is any Special variable in stored procedure like & this?)
Is this details enough?.
Have a look at this procedure -
PROCEDURE procedure1()
BEGIN
DECLARE tRESCAS VARCHAR(255) DEFAULT '';
DECLARE i INT DEFAULT 0;
DROP TEMPORARY TABLE IF EXISTS t;
CREATE TEMPORARY TABLE t(num INT, column1 VARCHAR(255));
WHILE i < 10 DO
INSERT INTO t VALUES(i, CONCAT('tRESCAS', i));
SET i = i + 1;
END WHILE;
-- Try to get fifth value
SELECT column1 FROM t WHERE num = 5;
END
All values are stored into temporary table.
Execute the procedure:
CALL procedure1;
+----------+
| column1 |
+----------+
| tRESCAS5 |
+----------+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.