TCL help required

  • Creator
    Topic
  • #51340
    Yasir Hamza
    Participant

    I’ connecting to a database in the start mode of a switch statment.

    Cloverleaf executes the start mode only  while initiallizing/starting the concerned thread.

    I need to check the connectivity in the run mode and if the connectivity  is lost, I need to reconnect from the run mode.

    Can anyone help me in this?

    The code for connecting in the start mode is quite simple:

        switch -exact — $mode {

          start {

            # Perform special init functions

            # N.B.: there may or may not be a MSGID key in args

    global logon_handle stmt_enc_handle stmt_pat_handle   sql_encounter

    sql_patient

    global stmt_pat_del_handle stmt_enc_del_handle stmt_pat_fileid_handle

            # Connecting to Database

            set logon_handle [oralogon $db_id/$db_pw@$db_cs]

            set stmt_enc_handle [oraopen $logon_handle]

            set stmt_pat_handle [oraopen $logon_handle]

            set stmt_pat_del_handle [oraopen $logon_handle]

            set stmt_enc_del_handle [oraopen $logon_handle]

            set stmt_pat_fileid_handle [oraopen $logon_handle]

          }

    The reson I’m connecting in the start mode and not in the run mode is  becuase I don’t want to recreate a session/connection for each message if  the connection is valid. I need to check the status of the connection with  each message and re-connect only if required/disconnected before sending that  message in the run mode.

    Thanks

    Yasir

Viewing 3 reply threads
  • Author
    Replies
    • #69790
      David Barr
      Participant

      You should probably take all of the code that you added to the “start” block and put it in a procedure.  Then you can call that procedure from the start block and from the run block if your connectivity test fails.

    • #69791
      Yasir Hamza
      Participant

      How do I check the connectivity status? Is there a return handle value for the connection? What would be the condition for checking the connectivity status?

    • #69792
      David Barr
      Participant

      I don’t use Oracle very much, but I think that you’d just do a simple select that should always succeed.  Maybe “select date(‘now’)” would work.  Run the select and check for errors.

    • #69793
      Yasir Hamza
      Participant

      Thanks. Ijust found a way to achieve it. The logon handle return 0 for a sucessfull connectivity. I’m now checking the handle status and if it’s not zero, I’m re-executing the connect scripts from the run mode.

Viewing 3 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10