home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / ingres / 2378 < prev    next >
Encoding:
Text File  |  1993-01-28  |  3.9 KB  |  93 lines

  1. Newsgroups: comp.databases.ingres
  2. Path: sparky!uunet!tpghq!sfc
  3. From: sfc@tpghq.com (Steve Caswell)
  4. Subject: Re: Ingres error handling
  5. Message-ID: <1993Jan28.143155.9712@tpghq.com>
  6. Organization: Palmer & Associates, Inc., Norcross, GA
  7. References: <1993Jan26.194422.25457@athena.mit.edu>
  8. Date: Thu, 28 Jan 1993 14:31:55 GMT
  9. Lines: 82
  10.  
  11. In article <1993Jan26.194422.25457@athena.mit.edu> thomasl@mtl.mit.edu (Thomas J Lohman) writes:
  12. >I am having some difficulty unearthing all of the different ways
  13. >you can trap Ingres EQUEL/ESQL errors for the C language.
  14. >
  15. >I will try to summarize my thoughts and would like people to tell me
  16. >how they think it works (I am most likely wrong anyhow).
  17. >
  18. >Ways to capture/get errors in EQUEL
  19. >-----------------------------------
  20. >
  21. >(1) Use the IIseterr function to define an error handler which will be
  22. >    called by Ingres if there is an Ingres error.
  23. >
  24. >(2) Issue the inquire_ingres (inquire_equel) command to find out the 
  25. >    error number and deal with it.  This option would have to be used
  26. >    in a case by case basis.
  27. >
  28. >Now, my question is, will option (2) suppress msgs going to stdout, unless
  29. >I explicitly tell it to output error messages?
  30. >
  31. >Ways to capture/get errors in ESQL
  32. >-----------------------------------
  33. >
  34. >(1) Declare the SQLCA structure, and check the sqlcode member in a case
  35. >    by case basis.
  36. >
  37. >(2) Declare the SQLCA structure and use the "whenever" statement deal with
  38. >    warnings, or errors.  This also enables you to call your a user
  39. >    defined function, and it is only valid for the SQL statements which follow
  40. >    it's definition inside the source module.
  41. >
  42. >(3) Define an error trapping routine which can then be set using the 
  43. >    set_sql command. I think that the SQLCA shouldn't be defined.
  44. >
  45. >(4) You can use the inquire_sql statement to find out the error, although
  46. >    it does say this does not suppress messages to the screen.
  47. >
  48. >(5) You can use the IIseterr function, like above.
  49. >
  50. >
  51. >SQL seems to have more variety but the documentation doesn't really 
  52. >do a great job of defining what you can do.  It seems that under ESQL,
  53. >option (1) should really be used as well as option (2).  Option (3)
  54. >seems to the equivalent of (5) which seems to be the equivalent of 
  55. >EQUEL's option (1).
  56. >
  57. >I would like to know what I've screwed up in the above ramblings, and 
  58. >I'd be interested in knowing how people handle error checking in 
  59. >ESQL especially for C.
  60. >
  61. >thanks,
  62. >
  63. >
  64. >--tom
  65. >
  66. Error handling in INGRES applications can be a complex task.  In fact, I've
  67. seen applications where the developers spent as much time on the error handling
  68. as with anything else in the app.  You are correct that ESQL gives you more
  69. options, but along with those options comes more things to consider.  In our
  70. application development, we primarily use the WHENEVER directive to call a
  71. general error handler package that we have written.  This error handler takes
  72. care of writing to log files, sending mail, etc., as well as setting some
  73. flags the program can then look at and decide what action to take.  On
  74. certain types of errors, the error handler will simply stop the program, but
  75. that is also tunable.
  76.  
  77. We use the WHENEVER directive approach because it lets us concentrate more
  78. on the real functionality of the application.  The developer doesn't have
  79. to worry about remembering to put in the call to inquire_ingres.
  80.  
  81. Option (3) may not be a good solution if you want the error handler to do
  82. automatic rollback/commits, because no database statement is allowed to be
  83. executed from the error handler routine.
  84.  
  85. I don't really think there is a "right way" or "wrong way" to do error handling,as long as you are doing it.  The only "wrong way" is to not do any.
  86.  
  87.  
  88. -- 
  89.  
  90. Steve Caswell           |   (404) 448-7727    |  "The opinions expressed are my
  91. Principal Consultant    |   sfc@tpghq.com     |   own.  They may not be perfect,
  92. The Palmer Group        |   uunet!tpghq!sfc   |   but they're all I've got."
  93.