home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / database / oracle / 1282 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  3.1 KB

  1. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!tethys.SLAC.Stanford.EDU!ian
  2. From: ian@tethys.SLAC.Stanford.EDU (Ian A. MacGregor)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Re: Forms3 Delete a char of the field data
  5. Message-ID: <5082@unixhub.SLAC.Stanford.EDU>
  6. Date: 13 Aug 92 16:39:02 GMT
  7. References: <1992Aug12.162132.278@falcon.navsses.navy.mil>
  8. Sender: news@unixhub.SLAC.Stanford.EDU
  9. Lines: 53
  10. Nntp-Posting-Host: tethys.slac.stanford.edu
  11.  
  12. In article <1992Aug12.162132.278@falcon.navsses.navy.mil>, huynh@falcon.navsses.navy.mil writes:
  13. |> Greetings,
  14. |> 
  15. |> I am using sqlforms version 3.0.
  16. |> I have a problem which I don't even know where to start.  I want to delete a
  17. |> char of the enter data into a field.  
  18. |> eg. Let 's say I have a field that requires data
  19. |> HULL: _________; where the users will enter something like HULL: LST-1183,
  20. |> I want to delete the "-" sign/char.
  21. |> I want the data to be in the form of 'LST1183', but because of the way our data
  22. |> bases are set up, the users will enter the HULL in the form of 'LST-1183'. I
  23. |> want to delete the "-" sign/char, and also at the time somehow join the 
  24. |> LST 1183 together so that it is like the user had just entered 'LST1183' and
  25. |> not 'LST-1183'.
  26. |> I need to convert 'LST-1183' into 'LST1183', so that it corresponds with the
  27. |> database HULL to do the query.
  28. |> 
  29. |> I hope I have made myself clear.  Anyone who is interested, but didn't quite
  30. |> undertand me, please feel free to ask.  I will be more than happy to make
  31. |> myself clear.  
  32. |> 
  33. |> Any comments or suggestions will be appreciated.  Thanks in advance.
  34.  
  35. How far along are you on this project?  There appears to be a basic error in
  36. design in that the HULL field is not atomic, but includes two different pieces
  37. of information; the class of ship and its hull number.  These should be separate
  38. fields.  This will make queries looking for all LST's, DDG's, FF's, etc. easier.
  39. You can concatenate the two fields on output or to store the class/hull number
  40. combination in another database field. 
  41.  
  42. If your database design is immutable and you need to strip out the '-' character,
  43. the following trigger will do the trick.
  44.  
  45.  BEGIN                                                                       
  46.     IF (INSTR(:NAVY.HULL,'-') > 0) THEN                                 
  47.       :NAVY.HULL := SUBSTR(:NAVY.HULL,1,                          
  48.       INSTR(:NAVY.HULL,'-') -1)||                                       
  49.       SUBSTR(:NAVY.HULL,INSTR(:NAVY.HULL,'-')+1,                  
  50.       LENGTH(:NAVY.HULL));                                              
  51.     END IF;                                                                  
  52.  End;  
  53.  
  54.  
  55. This code should be placed in an on-validate-trigger on the class_hull field
  56. and on a pre-query trigger on the block.
  57.  
  58. Note: the use of this code will result in the '-' disappearing from the screen
  59. field as well.  
  60.  
  61.                             Ian MacGregor
  62.                             Stanford Linear Accelerator Center
  63.                             IAN@SLAC.STANFORD.EDU
  64.                             (415) 926-3528     
  65.