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

后端 未结 4 981
轮回少年
轮回少年 2021-01-29 05:21

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

4条回答
  •  生来不讨喜
    2021-01-29 05:23

    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.

提交回复
热议问题