3 Replies Latest reply on Mar 26, 2009 10:54 PM by Sdas-Oracle

    Can you dynamically create rules indexes or virtual models in plsql?

      I am writing a plsql utility that loads data into a new model offline. Once the load is finished, I need to create a new rules index based upon the definition of an existing rules index. Once that is done, I then need to drop my existing virtual model and recreate it to include the new model I just loaded. I realize that I could hard-code both create statements in my plsql, but I would much rather dynamically construct the model lists for "sem_apis.create_entailment" and "sem_apis.create_virtual_model" so that I don't have to modify code every time I add new models to my environment (i.e. with this capability, I can add new models to the rule indexes and vitual models manually and my load utilty would automatically include them in the next load execution).

      How can I pass the list of models into each of these APIs? The documentation indicates that both accept a "models_in" parameter of type SEM_MODELS, which it further explains has a definition of TABLE OF VARCHAR2(25).

      I have created variables of said types in my utility and intialized them with valid models. However, whenever I try to execute the API in my plsql using these variables I get the following error:

      PLS-00306: wrong number or types of arguments in call to 'CREATE_VIRTUAL_MODEL'

      I have attached the sample code below:

      TYPE model_T IS TABLE OF VARCHAR2(25);
      model_list model_T;
      model_list := model_T('M1','M2');
      for i in model_list.first .. model_list.last loop
      dbms_output.put_line(i||' = '||model_list(i));
      end loop;

      Has anyone successfully done this before? Any ideas how I might be able to get this to work?