如何使用IF和ELSE语句定义基于“深度INTEGER”运行的存储过程的数量? (例如,如果用户使用1表示深度周长,则仅处理第一部分)
--#SET TERMINATOR /
CREATE PROCEDURE STOREP2(IN str_in VARCHAR(1), IN depth INTEGER )
LANGUAGE SQL MODIFIES SQL DATA
DYNAMIC RESULT SETS 1
CRSUBJ: BEGIN
DECLARE C1 CURSOR WITH RETURN FOR
SELECT T1.COLUMN1, T1.COLUMN2 FROM TABLE1 AS T1 WHERE T1.COLUMN1=str_in
UNION
SELECT T2.COLUMN1, T2.COLUMN2 FROM TABLE1 AS T1, TABLE1 AS T2 WHERE T1.COLUMN1=str_in AND T2.COLUMN1=T1.COLUMN2
UNION
SELECT T3.COLUMN1, T3.COLUMN2 FROM TABLE1 AS T1, TABLE1 AS T2, TABLE1 AS T3 WHERE T1.COLUMN1=str_in AND T2.COLUMN1=T1.COLUMN2 AND T3.COLUMN1=T2.COLUMN2
UNION
SELECT T4.COLUMN1, T4.COLUMN2 FROM TABLE1 AS T1, TABLE1 AS T2, TABLE1 AS T3, TABLE1 AS T4 WHERE T1.COLUMN1=str_in AND T2.COLUMN1=T1.COLUMN2 AND T3.COLUMN1=T2.COLUMN2 AND T4.COLUMN1=T3.COLUMN2;
OPEN C1;
RETURN;
END CRSUBJ/
谢谢:)
答案 0 :(得分:0)
答案 1 :(得分:0)
更具体地说:在你的例子中 - 你不能。你实际执行的是对TABLE1的四个查询,并返回结果光标,使其显示为调用者的一个表。这将有助于了解更多的表结构以及您尝试实现的目标,以帮助您解决问题。