home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / oracle / 1082 < prev    next >
Encoding:
Text File  |  1992-07-21  |  2.2 KB  |  62 lines

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!rde!andy
  3. From: andy@homebase.vistachrome.com (Andy Finkenstadt)
  4. Subject: Re: Referencing a SEQUENCE from a trigger...
  5. Message-ID: <1992Jul21.115013.14305@homebase.vistachrome.com>
  6. Reply-To: andy@homebase.vistachrome.com
  7. Organization: Vista-Chrome Incorporated
  8. References: <1992Jul20.195514.8085@unixg.ubc.ca>
  9. Date: Tue, 21 Jul 1992 11:50:13 GMT
  10. Lines: 50
  11.  
  12. george@unixg.ubc.ca (George chow) writes:
  13. >
  14. >Hello,
  15. >I've got a situation where I need to insert rows into a table in a 
  16. >ON-VALIDATE-FIELD trigger. For these rows, I need a serial no which I'm
  17. >getting from a SEQUENCE. However, I can't seem to reference the SEQUENCE.
  18.  
  19. I've struggled with this problem as well.  I tried to use the same
  20. method as the default value method and get the same error.  The way
  21. to do it is to do
  22.  
  23.    SELECT V_REF_NO_SEQ.NEXTVAL into :new_ref FROM DUAL;
  24.  
  25. If you have any other 'select' statements guaranteed to return one
  26. and only one row you can "piggyback" it onto that select statement
  27. instead of generating a seperate one.
  28.  
  29. I've given this some thought and have decided that there is a rationale
  30. for this "extra" select statement:  Sequence values are stored in the
  31. RDBMS, not in the form.  You need to be talking to the RDBMS to get the
  32. nextval .  Forms 3.0, when presented with :sequence.sequence_name.nextval
  33. converts that to a SELECT statement ON-NEW-RECORD-INSTANCE (in effect).
  34.  
  35. >I'm doing something like:
  36. >
  37. >  new_ref := :SEQUENCE.V_REF_NO_SEQ.NEXTVAL;
  38. >
  39. >which gets me the error messages:
  40. >
  41. >  PL/SQL error 49 at line 10, column 16:
  42. >     bad bind variable 'sequence.v_ref_no_seq'
  43. >
  44. >I've gone through the _SQL Language Reference_ and _SQL*Forms Designer 
  45. >Reference_ and I can't find anything useful there. Is the ":SEQUENCE."
  46. >syntax only valid for use with default value? 
  47. >
  48. >George
  49. >george@unixg.ubc.ca
  50. >
  51.  
  52. Hope that helps.
  53.  
  54. -Andy
  55.  
  56. PS - I don't work for Oracle, but I wouldn't mind.  <GRIN>
  57. -- 
  58. Andrew Finkenstadt       | Vista-Chrome, Inc.   |    NIC Handle: AF136
  59. GEnie Unix Sysop/Manager | The Printing House   |   ...!uunet!rde!andy
  60. +1 904 222 2639 home     | 1600 Capital Cir SW  |  andy@GEnie.geis.com
  61. +1 904 575 0189 work     | Tallahassee FL 32310 | andy@vistachrome.com
  62.