home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / database / oracle / 2586 < prev    next >
Encoding:
Text File  |  1992-12-21  |  3.9 KB  |  92 lines

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!mcsun!sunic!ugle.unit.no!ugle.unit.no!oysteing
  3. From: oysteing@garm.idt.unit.no (Oystein Groevlen)
  4. Subject: Re: Passing query results from a user exit to SQL*Forms 3.0
  5. In-Reply-To: mjw@mailbox.eng.ufl.edu's message of 15 Dec 92 17:04:02 GMT
  6. Message-ID: <OYSTEING.92Dec19125734@garm.idt.unit.no>
  7. Sender: news@ugle.unit.no (NetNews Administrator)
  8. Organization: Div. of CS & Telematics, Norwegian Institute of Technology
  9. References: <1992Dec15.170402.28872@eng.ufl.edu>
  10. Date: 19 Dec 92 12:57:34
  11. Lines: 79
  12.  
  13. In article <1992Dec15.170402.28872@eng.ufl.edu> mjw@mailbox.eng.ufl.edu (Mike Wohlgemuth) writes:
  14.  
  15.    I need to run a select query in a user exit, and have the query
  16.    results show up in a multi-record block.  I would like to be able
  17.    to open the cursor, fetch the records, and then assign them to
  18.    sucessive rows in the block.  As I understand it, IAF PUT will
  19.    put values into the fields of the current record in the block.
  20.    So, how do I create new rows and navigate to them within a user
  21.    exit?
  22.  
  23. I have made an user exit for performing queries which presents the
  24. query result in Forms. 
  25.  
  26. The reason for making this user exit was that I needed to be able
  27. execute queries which combines criteria on fields from different
  28. tables (and blocks.) This was an query application, so I could have
  29. used a view, but the performance of such a view with an outer join
  30. over 28 tables is extremely poor on a Microvax. In addition queries
  31. executed in Forms are compiled when the application is compiled
  32. (before the values of the Forms fields used in the query are known).
  33. Thus, Oracle will often not use indexes even if it is possible.
  34.  
  35. In the master block of the form, I made query fields for all fields of
  36. the details blocks which it should be possible to put search criteria
  37. on. These fields is displayed when the user enter query mode of the
  38. master block.
  39.  
  40. For each of the query fields, I wrote queries which returned the
  41. primary key of the master block for the records which satisfied the
  42. criteria on that field. The queries are stored in a file which is read
  43. by the user exit. Before a query from that file is compiled and
  44. executed by the user exit each occurences of Forms field names in the
  45. query is replaced with the contents of that field with the help of IAF
  46. GET.
  47.  
  48. The user-exit will store the primary key of the records satisfying all
  49. the queries executed in a table called QUERY_SET. The table QUERY_SET
  50. contains 2 fields: KEY which is the primary key of the master block,
  51. and SEARCH_ID which identify this particular execution of the user
  52. exit. SEARCH_ID is stored in the primary key field of the master block
  53. by IAF PUT.
  54.  
  55. The user exit is called in the PRE-QUERY trigger. The parameters to
  56. the user exit is the name of the file containing the queries, and a
  57. list indentifying the queries to be executed (line numbers in file).
  58. This way only the queries for fields which is non-empty is executed.
  59.  
  60. When the user exit returns, the primary key field contains the
  61. reference to the table QUERY_SET. To have Forms restrict the search to
  62. the queries found by the user_exit, the following code has to be
  63. executed (The primary key field is here DOC.DATID):
  64.  
  65.    search_id := name_in('DOC.DATID');
  66.    query_string := '#in (select KEY from QUERY_SET where SEARCH_ID = ' ||
  67.                    search_id;
  68.    copy(query_string, 'DOC.DATID');
  69.  
  70. Then Forms performs a search as usual to get the records satisfying
  71. the criteria on the base table fields.
  72.  
  73. Hope this gave some ideas on how to solve your problem.
  74.  
  75. I will be away on christmas vacation until January 4, so mail me if
  76. you have any comments as the postings will have been deleted from our
  77. news server by then. 
  78.  
  79. Oystein Groevlen 
  80. Division of Computer Systems and Telematics
  81. The Norwegian Institute of Technology
  82. The University of Trondheim
  83. Email: oysteing@idt.unit.no
  84.  
  85.  
  86. --
  87. Oystein Groevlen 
  88. Division of Computer Systems and Telematics
  89. The Norwegian Institute of Technology
  90. The University of Trondheim
  91. Email: oysteing@idt.unit.no
  92.