list2sql

Formats a list of field values into a SQL IN predicate.

Syntax

void    list2sql(list-name,list-field);
list    list-name
expr    list-field

Description

list-name

identifies the name of the list to navigate.

list-field

specifies the values to put in the IN predicate.

list2sql() was created to format an IN predicate from a list of chemical structures or sample numbers. Duplicate values are ignored. Finally, the IN predicate is assigned to G.query_buf and used in the window query trigger.

Example

This trigger is deployed under the File menu in the Open Hit List item. It offers a list of files with structure numbers identified by the suffix no. The file selected by the user is opened and the list of structure numbers is formatted into an IN predicate which is assigned to G.query_buf. The query is executed automatically by assigning key_F1, the query key, to G.key.

In this example, the files of hit lists are stored on the application server in the users directory and the appropriate environmental variables are assigned in an initialization file:

 server_os 1 #nt=0, unix=1, vms=2
 user_dir /usr2/trim # user hit lists; username appended in main.trg 

These variables are read by get_parms() as global variables. Finally, the username is appended to G.user_dir making its value /usr2/trim/username/ .

 {
 char fld[20];
 char suffix[3];
 list user_list;

 user_list= file2list(G.server_os,G.user_dir,"no");
              /* User chooses & opens file*/
 if (user_list){
   suffix= lower(substr(G.fname,instr(G.fname,".")+1,2));/* get suffix */
   fld= decode(suffix,"no","NO");                /* suffix = field name */
   list2sql(user_list,fld);  /* format/assign predicate to G.query_buf */
   G.key= key_f1;           /* Execute query using G.query_buf */
   }
 }


Updated 19 May 1999. Copyright DataAspects Corp. 1998-1999