SQLreq Module - Feb 98 - by Christophe LOREK
-----------

The function of this module is to provide an access to a SQL Database. The parameters necessary to
access the Database must be provided in the editor interface (DMI). The required parameters are :
   Database name : the name of the Database defined in ODBC.
   Login         : The name of the user to access the database, if omitted, "Admin" is used by 
                   default.
   Password      : the password corresponding to the Login, "" by default.

---------------------------------------------------------------------------------------------------

Two actions :
- SqlDMIParamDMI   : You must provide two action names in the reply, specifying them as a linebuild
                     of a [S r1].
                      * The first action of the list will be the action that will receive the result
                        as the param (if no name has been provided, the result is sent to the event
                        "Result")
                      * The second action of the list will be the action that will receive the SqlCod
                        as the param (if no name has been provided, the SqlCod is sent to the event
                        "SqlCod")
                        
                     It uses the SQL request and the parameters specified in the DMI file, in the form :
                     + SQL Request :
                      must contain the SQLRequest according to SCOL syntax for SQL (parameters
                      appears in the Request in the form of question marks "?").
                     + Parameters :
                      contain one parameter by line, each line containing the SQLParam type and the
                      value of the parameter.
                      Example : SQL_CHAR Toto
                                SQL_NUMERIC 0140201212                                
                                
- SqlDMIParamSent  : NOT IMPLEMENTED YET.                              
                                
- SqlSentParamSent : You must provide two action names in the reply, specifying them as a linebuild
                     of a [S r1].
                      * The first action of the list will be the action that will receive the result
                        as the param (if no name has been provided, the default action name is "Result")
                      * The second action of the list will be the action that will receive the SqlCod
                        as the param (if no name has been provided, the default action name is "SqlCod")
                        
                     With the action, you must also provide the SQL request to be executed, and the 
                     parameters to be used. It must be passed as a param with the action. 
                     The param must be a string produced by a strbuild of an [[S r1] r1] list, the
                     first line containing the string of the SQLrequest, and the following lines
                     containing a type of SQLParam and a value.
                     the list must be of the form :
                       (SQLRequest::nil)::
                       (SQLParamtype::SQLValue::nil)::
                        ...
                       (SQLParamtype::SQLValue::nil)::nil
                       
                     example :
                     
                     strbuild ( ("SELECT Login,Password,Tel FROM User WHERE Password=? AND Tel=?;"::nil)::
                                ("SQL_CHAR"::"Toto"::nil)::
                                ("SQL_NUMERIC"::"0140201212"::nil)::nil )
                                
                     which produces the string :
                     
                     "SELECT Login,Password,Tel FROM User WHERE Password=? AND Tel=?;\nSQL_CHAR Toto\nSQL_NUMERIC 0140201212\n"                             

- SqlSentParamSentWithErr:
		   Only one reply name, the error codes are sent within the result ([S r1] r1):
		    (SqlCod::ODBCErr::NativeErr::Msg::NbL::ResultSQLS::nil)::nil
		    ResultSQL is the true result, and is a ([S r1] r1 )
		    
		    Useful function, to extract the result:
		    fun ExtrParamFromSQLRep(param)=
			  let strextr param -> [[SqlCod [ODBCErr [NativeErr [Msg [NbL [ SQLRep  _] _] in
   			  [ atoi SqlCod ODBCErr atoi NativeErr Msg atoi NbL SQLRep]
;;


- SqlSentParamDMI   : NOT IMPLEMENTED YET.

----------------------------------------------------------------------------------------------------

Three events :
- log        : Server status of the request.
- Result     : when no action name has been provided in the reply for the result, the result of the
               request is sent through this event.
- SqlCod     : when no action name has been provided in the reply for the SqlCod, the SqlCod of the
               request is sent through this event.               

----------------------------------------------------------------------------------------------------
Result of the SQL request :
  The result of the SQL request will be sent to the action of the calling module (DMI) specified in
  the reply.
  This is sent as the param of the action specified in the reply (if omitted, the result is sent in 
  the event "Result").
  It's a string of the form : (strbuild of an [[S r1] r1]) 

  example : (result of the SQLrequest above)
               
    "Christophe Toto 0140201212\n"
               
    if you apply strextr to the result string, you'll get :
               
    ("Christophe"::"Toto"::"0140201212"::nil)::nil

Returned SqlCod :
  The SqlCod giving the status of the SQL request (SQL_SUCCESS,SQL_NO_DATA, SQL_ERROR) will be sent
  to the action of the calling module (DMI) specified in the reply.
  This is sent as the param of the action specified in the reply (if omitted, the SqlCod is sent in
  the event "SqlCod")
  it's a string containing an integer.
