home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / oracle / 2764 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  3.1 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!bogus.sura.net!howland.reston.ans.net!spool.mu.edu!umn.edu!gaia.ucs.orst.edu!gaia.ucs.orst.edu!news
  2. From: mickel@OES.ORST.EDU (Paul M. Mickel)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: How to save the query from the form and re-use it later?
  5. Date: 12 Jan 1993 05:50:08 GMT
  6. Organization: Oregon Extension Service, Oregon State University, Corvallis, Or.
  7. Lines: 65
  8. Message-ID: <1itm6gINNmqp@gaia.ucs.orst.edu>
  9. References: <107@timer1.UUCP>
  10. NNTP-Posting-Host: oes.orst.edu
  11. Keywords: Oracle Form, Query by Form
  12.  
  13. In article <107@timer1.UUCP> john@timer1.UUCP (john) writes:
  14. >Hello, World:
  15. >
  16. >We are implementing a form to access customer database. So, it is kind of
  17. >basic like name, address, phone numbers and titles etc.
  18. >
  19. >Oracle Sql*Form 3.0 provides query by form (kind of nice). We would like to
  20. >use this feature but we also want to save the query for future use because
  21. >some queries can be so complicated and our users don't want to re-type it 
  22. >over and over again. In addition to that, we also like to dump the results
  23. >not only on the screen but also into a file so we can use it with mail
  24. >merger of word processor.
  25. >
  26. >Is there any one out there who can give us a little guide, instruction or
  27. >pointer on how to implement this mechanism ?
  28.  
  29. You can create a POST-QUERY trigger to do this, having the following body:
  30.  
  31. declare hoststr    char(256);
  32.  
  33. begin
  34.   hoststr := 'echo "' || :system.last_query || '" > /tmp/filename_here';
  35.   host(hoststr,NO_SCREEN);
  36.   redisplay;
  37. end;
  38.  
  39.  
  40. The idea here is simple, take the last query entered, put the 'echo' string 
  41. together (containing the :system.last_query), then use it in the 'host' 
  42. function, which executes the 'echo' command and dumps the output to a file.
  43. There are a couple of things to think about:
  44.  
  45. 0. The :system.last_query stores the query used to populate the last block. 
  46.    Hence, if you have a multi-block form, you will have to create/modify the
  47.    triggers for these blocks to store the last_query from that block before
  48.    moving on. If you have a master-detail relatoinship, you can do this 
  49.    storage before executing the 'query_details' code (at least this was 
  50.    given to us when we created forms w/ master-detail relationships).
  51.  
  52. 1. Related to (0.), if you store the last_query in a global variable, you are
  53.    restricted to 256 characters. This is a real pain in the neck if you are
  54.    trying to pass this last_query to a report writer to do a query 
  55.    dynamically (without knowing beforehand which fields get filled during
  56.    'enter-query' mode). Our solution was to parse the 'where' clause from
  57.    the last_query, store it in a global variable (and hope it still isn't 
  58.    too long) and pass this to the report writer.
  59.  
  60.  
  61. The example code is an adaptation of what I have written for work and is in
  62. active use.  There may be better ways to do it, but this will work.
  63.  
  64. Hope that helps.
  65.  
  66. >Any help will be highly appreciated.
  67. >
  68. >
  69. >John Y. Chan
  70.  
  71. -pmm
  72.  
  73. -- 
  74. Paul M. Mickel                     Internet:mickel@oes.orst.edu
  75. Sysadmin, Oregon Extension Service       Corvallis, OR 97331
  76. Database Programmer, Teledyne Wah Chang    Albany, OR 
  77. Disclaimer: Neither employer has *ever* claimed any of my opinions.
  78.