home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / oracle / 2185 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.4 KB  |  50 lines

  1. Newsgroups: comp.databases.oracle
  2. Path: sparky!uunet!think.com!spool.mu.edu!umn.edu!csus.edu!netcom.com!tssmith
  3. From: tssmith@netcom.com (Tim Smith)
  4. Subject: Re: Yoo Hoo--are you still there?
  5. Message-ID: <1992Nov12.131112.12964@netcom.com>
  6. Keywords: ping
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  8. References: <51455@seismo.CSS.GOV>
  9. Date: Thu, 12 Nov 1992 13:11:12 GMT
  10. Lines: 38
  11.  
  12. In article <51455@seismo.CSS.GOV> jean@seismo.CSS.GOV (Jean Anderson) writes:
  13. >What's the cheapest way to tell from OCI if a frontend database connection 
  14. >is still alive? I want to do something like this:
  15. >
  16. >    if(db_dead()==TRUE)
  17. >    {
  18. >        -- do something reasonable, maybe re-establish connection
  19. >    }
  20. >
  21. >I'm looking for a cheap ping for db_dead(), maybe a "select 'x' from dual",
  22. >although I'd like to avoid a select.
  23. >
  24. >Is there a better way to check, maybe already a hook I don't know about?
  25. >
  26. >thanks,
  27. >
  28. > -jean
  29.  
  30. Why not just try to oopen a new cursor using that LDA?  Something like
  31.  
  32. if (!oopen(&dummy_cursor, &dubious_lda, ...))
  33. {
  34.     printf("I'm still here!\n");
  35.     oclose(&dummy_cursor);
  36. }
  37. else  /* you'll get ORA-01012 if it's dead */
  38. {
  39. /* do what's needed to re-establish the connection */
  40. }
  41.  
  42. Or, you could try a parse of "select 'x' from dual" using a cursor
  43. open on that connection, if you have a cursor to spare.  Make sure you
  44. oparse in non-deferred mode.
  45.  
  46. --Tim (tssmith@netcom.com)
  47.  
  48.  
  49.  
  50.