Home > database >  Oracle stored procedure string concatenation, use in the query
Oracle stored procedure string concatenation, use in the query

Time:09-26

Procedure CS is
V_PRPSPERSON varchar2 (100);
V_count NUMBER;
The BEGIN
V_PRPSPERSON:="' 172506213" '| |', '| |', '172506211' ' '.

SELECT COUNT (*) INTO v_count from PRPSperson WHERE a a.u sercode IN (V_PRPSPERSON);
End CS;


Oracle stored procedure joining together the string, in way, why not ask god for help! Urgent urgent

CodePudding user response:

Can only be used in constant or variable list, cannot be used for splicing of string,

CodePudding user response:

If just want to use the string, can only write the dynamic SQL,

CodePudding user response:

Want to use dynamic SQL, or cursor loop to deal with

CodePudding user response:

Ok, thank you

CodePudding user response:

reference sxq129601 reply: 3/f
to use dynamic SQL, or cursor loop to handle

Write a dynamic SQL, don't need to use a cursor, and then execute immediate execution,

CodePudding user response:

Procedure CS is
V_PRPSPERSON varchar2 (100);
V_count NUMBER;
V_sqlstr varchar2 (1000);
The BEGIN
V_PRPSPERSON:="' 172506213" '| |', '| |', '172506211' ' '.
V_sqlstr:='SELECT COUNT (*) from PRPSperson WHERE a a.u sercode IN (' | | V_PRPSPERSON | |') '.
The execute immediate V_sqlstr INTO v_count;
End CS;
  • Related