I have a problem with a Pro*C query I\'m trying to optimise.
To explain, our application searches for rows in a huge database. These rows exist in several languages and
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.
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.
Probably this AskTom article can help you.
... 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.