简体   繁体   中英

Oracle procedure all input variables to be set in upper case

I have a scenario where I need to convert all input parameter for a Oracle SP to upper case before processing:-

procedure Name (
v_Param1 in number,
v_Param2 IN varchar2,
v_Para3 IN VARCHAr2,
v_Param4 IN VARCHAr2,
v_MID IN VARCHAr2)

The inputs can be of lower, upper or camel case but I need to match it with records in table with uppercase, which is a costly operation at database end in recursive calls. Is there a way I can convert these values before hand at once so the input parameters are converted at uppercase.

You can declare and set new variables:

procedure Name ( v_Param1 in number, v_Param2 IN varchar2, v_Para3 IN VARCHAr2, v_Param4 IN VARCHAr2, v_MID IN VARCHAr2
               )
as
    v_param2_upper varchar2(4000);
    v_param3_upper varchar2(4000);
    v_param4_upper varchar2(4000);
    v_param5_upper varchar2(4000);
begin
    v_param2_upper := upper(v_param2);
    v_param3_upper := upper(v_param3);
    v_param4_upper := upper(v_param4);
    v_param5_upper := upper(v_param5);

    . . .
end;

I do have no idea how the case of strings would result in recursive calls, however.

by using directly upper/lower function on variable you can achieve this:-

procedure Name (
   v_Param1 in number,
   v_Param2 IN varchar2,
   v_Para3 IN VARCHAr2,
   v_Param4 IN VARCHAr2,
   v_MID IN VARCHAr2)
as BEGIN
   v_Param2 := upper(v_Param2);
   v_Para3 := upper(v_Para3);
   v_Param4 := upper(v_Param4);
   v_MID := upper(v_MID);
......
END;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM