How to specify a variable expression list in a Pro*C query?

情到浓时终转凉″ 提交于 2019-12-02 08:38:25

Probably this AskTom article can help you.

You can't do this without Oracle Dynamic SQL. You will have to build your IN clause at runtime and EXECUTE IMMEDIATE. At least you can use Method 1, based on your queries.

I have used a table before composed of an ID and a set of rows where the rows are the permutation of the possible values in the "in" list. Then I join to the table based on the ID and it gives me the results I need.

create table permute (
  id number,
  lang char(2)
);
create index permute_p1 on permute ( lang, id );
insert into permute ( id, lang ) values ( 1, 'en' );
insert into permute ( id, lang ) values ( 2, 'en' );
insert into permute ( id, lang ) values ( 2, 'fr' );
...

All you have to do then is pick the correct "ID" value 2, 3, 4 ... and put that into the join.

... Main String:= 'Select * FROM table WHERE id=:uniqid AND language IN'; -- can split into two to accomadate :uniqd ... Select Language_code into v_string from x_table; loop Copy & Concat v_string to LanCode_String and with ' ', ; end loop; .. Concat Lancode to Main String. .. Prepare and execute the Main String.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!