【发布时间】:2021-12-25 07:00:20
【问题描述】:
下面的代码是创建一个传递一些值的过程,然后在_no_tiers次发生插入操作
CREATE OR REPLACE PROCEDURE INSERT_TIER_INFO(in_lp_code IN VARCHAR2 , in_tier IN VARCHAR2 , in_pts_reqd IN VARCHAR2 , in_multiplier IN VARCHAR2 , in_no_tiers NUMBER)
AS
low_bound NUMBER := 0 ;
current_tier VARCHAR2(32) ;
current_points NUMBER ;
current_multiplier NUMBER ;
upper_bound NUMBER := in_no_tiers ;
curr_level NUMBER := 0 ;
seperator VARCHAR2(2) := "," ;
BEGIN
FOR j IN low_bound..upper_bound LOOP
current_tier := split(in_tier , seperator , j) ;
current_points := TO_NUMBER(split(in_pts_reqd , seperator , j)) ;
current_multiplier := TO_NUMBER(split(in_pts_reqd , seperator , j)) ;
INSERT INTO TIERED_LOYALTY_PROGRAM(LP_CODE, STATE,TIER1,POINTS_REQUIRED, MULTIPLIER, LEVEL1)
VALUES (in_lp_code , 0 , current_tier , current_points , current_multiplier , j) ;
END LOOP;
END;
此过程调用另一个自定义函数 split ,它将以字符串形式获取值,例如: 'R1 , R2 , R3 ' 并根据 func 中的第三个参数是否为 0 返回 'R1' 或 'R2' 或 'R3' , 1 或 2. 此函数运行正常,但程序抛出许多错误
Errors: PROCEDURE INSERT_TIER_INFO
Line/Col: 9/12 PL/SQL: Item ignored
Line/Col: 9/28 PLS-00201: identifier ',' must be declared
Line/Col: 13/2 PL/SQL: Statement ignored
Line/Col: 13/35 PLS-00320: the declaration of the type of this expression is incomplete or malformed
Line/Col: 14/3 PL/SQL: Statement ignored
Line/Col: 14/51 PLS-00320: the declaration of the type of this expression is incomplete or malformed
Line/Col: 15/2 PL/SQL: Statement ignored
Line/Col: 15/54 PLS-00320: the declaration of the type of this expression is incomplete or malformed
【问题讨论】:
-
请检查the documentation:' ' 是两个单引号,它们开始和结束文本文字
标签: sql oracle stored-procedures plsql procedure