(sans sujet)

RPG (3 et 4, free), CL, SQL, etc...
Répondre
Lundi400
Messages : 8
Enregistré le : dim. 24 janv. 2016, 10:19:47

(sans sujet)

Message par Lundi400 »

Bonjour à tous

je souhaite tracer les requêtes SQL transitant par ODBC. J'essaie de mettre en oeuvre l'exit point QIBM_QZDA_SQL2 avec le format ZDAQ0200. J'arrive à extraire les premiers champs mais pas la requête SQL. Quelqu'un a-t-il un exemple d'utilisation de cet exit point?

Merci

thomas.barberot
Messages : 58
Enregistré le : jeu. 12 avr. 2012, 14:50:53

(sans sujet)

Message par thomas.barberot »

Il y a quelques temps, j'avais fait des programmes de points d'exit. J'ai retrouvé celui-ci.
Je ne sais pas si ça peut aider.

Table qui va contenir le requêtes :

Code : Tout sélectionner

--‚-----------------------------------------------------------------------------
--‚Historique des passages dans les points d'exit QIBM_QZDA*
--‚-----------------------------------------------------------------------------

create table ZDALOG (

  -- Champs d'identification
  Id                  integer          generated always as identity ,
  Timbre              timestamp        not null with default ,
  Exit_Point          char( 20 )       not null with default ,

  -- Champs communs
  Profile             char( 10 )       not null with default ,
  Server              char( 10 )       not null with default ,
  Format              char( 8 )        not null with default ,
  Function_char       char( 8 )        not null with default ,
  Function_text       char( 30 )       not null with default ,

  -- Champs ZDAI0100 (déduits)
  Ip                  char( 15 )       not null with default ,

  -- Champs ZDAD0100
  File                char( 128 )      not null with default ,
  Library             char( 10 )       not null with default ,
  Member              char( 10 )       not null with default ,
  Authority           char( 10 )       not null with default ,
  File_Based          char( 128 )      not null with default ,
  Library_Based       char( 10 )       not null with default ,
  File_Override       char( 10 )       not null with default ,
  Library_Override    char( 10 )       not null with default ,
  Member_Override     char( 10 )       not null with default ,

  -- Champs ZDAR0100
  Long_Library        char( 20 )       not null with default ,
  Database            char( 36 )       not null with default ,
  Long_Package        char( 20 )       not null with default ,
  Long_File           char( 256 )      not null with default ,
  Long_Member         char( 20 )       not null with default ,
  Long_Format         char( 20 )       not null with default ,

  -- Champs ZDAR0200
  Primary_Library     char( 10 )       not null with default ,
  Primary_File        char( 128 )      not null with default ,
  Foreign_Library     char( 10 )       not null with default ,
  Foreign_File        char( 128 )      not null with default ,

  -- Champs ZDAQ0100 et ZDAQ0200
  Statement           char( 18 )       not null with default ,
  Cursor              char( 18 )       not null with default ,
  Prepare_Option      char( 2 )        not null with default ,
  Open_Attributes     char( 2 )        not null with default ,
  Package             char( 10 )       not null with default ,
  Package_Library     char( 10 )       not null with default ,
  Drda_Indicator      integer          not null with default ,
  Commitment_Control  char( 10 )       not null with default ,
  Default_Collection  char( 10 )       not null with default ,
  Statement_Text      char( 2048 )     not null with default ,

  -- Champs ZDAD0200
  Libraries_Number    integer          not null with default ,
  Libraries_List      char( 2550 )     not null with default ,

constraint ZDALOG_PK primary key ( Id ) ) ;

label on table ZDALOG is
'QIBM_QZDA* - Historique appel';


Programme associé au point d'exit :

Code : Tout sélectionner

       //‚==========================================================================================
       //‚Programme du point d'exit QIBM_QZDA_SQL2 au format ZDAQ0200
       //‚==========================================================================================

      /include zdamsgpr
      /include qsysinc/qrpglesrc,ezdaep

       //‚==========================================================================================
       //‚Format ZDAQ0200 pour le point d'exit QIBM_QZDA_SQL2
       //‚==========================================================================================

       //‚Décomposition
     d ZDAQ0200...
     d                 ds                  qualified
     d                                     inz
     d  Profile...
     d                               10
     d  Server...
     d                               10
     d  Format...
     d                                8
     d  Function...
     d                                9b 0
       //
     d  Statement...
     d                               18
     d  Cursor...
     d                               18
     d  PrepareOption...
     d                                2
     d  OpenAttributes...
     d                                2
     d  Package...
     d                               10
     d  PackageLibrary...
     d                               10
     d  DrdaIndicator...
     d                                4b 0
     d  CommitmentControl...
     d                                1
     d  DefaultSqlCollection...
     d                               10
     d  Reserved...
     d                              129
     d  SqlStatementTextLen...
     d                                9b 0
     d  SqlStatementText...
     d                             2048

     d FunctionChar    s              8    inz( *blank )
     d FunctionText    s             30    inz( *blank )

       //‚==========================================================================================
       //‚PARAMETRES
       //‚==========================================================================================

     d P_Response...
     d                 s              1
     d P_Parm...
     d                 ds                  likeds( ZDAQ0200 )
     d P_Parm2...
     d                 ds                  likeds( ezdSqlF2 )

     c     *entry        plist
     c                   parm                    P_Response
     c                   parm                    P_Parm

       //‚==========================================================================================
       //‚EXECUTION
       //‚==========================================================================================

      /free

       monitor ;
          //MsgDta = P_Parm ;
          //EnvoiMsg( PgmName : MsgDta ) ;

          exec sql
            set :FunctionChar = char( hex( :P_Parm.Function ) ) ;

          select ;
          when FunctionChar = '00001800' ;
             FunctionText = 'Prepare' ;
          when FunctionChar = '00001803' ;
             FunctionText = 'Prepare and describe' ;
          when FunctionChar = '00001804' ;
             FunctionText = 'Open/Describe' ;
          when FunctionChar = '00001805' ;
             FunctionText = 'Execute' ;
          when FunctionChar = '00001806' ;
             FunctionText = 'Execute immediate' ;
          when FunctionChar = '00001809' ;
             FunctionText = 'Connect' ;
          when FunctionChar = '0000180C' ;
             FunctionText = 'Stream fetch' ;
          when FunctionChar = '0000180D' ;
             FunctionText = 'Prepare and execute' ;
          when FunctionChar = '0000180E' ;
             FunctionText = 'Open and fetch' ;
          when FunctionChar = '0000180F' ;
             FunctionText = 'Create package' ;
          when FunctionChar = '00001810' ;
             FunctionText = 'Clear package' ;
          when FunctionChar = '00001811' ;
             FunctionText = 'Delete package' ;
          when FunctionChar = '00001812' ;
             FunctionText = 'Execute or open' ;
          when FunctionChar = '00001815' ;
             FunctionText = 'Return package info' ;
          other ;
             FunctionText = '* Inconnu *' ;
          endsl ;

          exec sql
            insert into zdalog
              (
               timbre ,
               exit_point ,

               profile ,
               server ,
               format ,
               function_char ,
               function_text ,

               Statement ,
               Cursor ,
               Prepare_Option ,
               Open_Attributes ,
               Package ,
               Package_Library ,
               Drda_Indicator ,
               Commitment_Control ,
               Default_Collection ,
               Statement_Text
              )

            values
              (
               current_timestamp ,
               'QIBM_QZDA_SQL2' ,

               :P_Parm.Profile ,
               :P_Parm.Server ,
               :P_Parm.Format ,
               :FunctionChar ,
               :FunctionText ,

               :P_Parm.Statement ,
               :P_Parm.Cursor ,
               :P_Parm.PrepareOption ,
               :P_Parm.OpenAttributes ,
               :P_Parm.Package ,
               :P_Parm.PackageLibrary ,
               :P_Parm.DrdaIndicator ,
               :P_Parm.CommitmentControl ,
               :P_Parm.DefaultSqlCollection ,
               substr( :P_Parm.SqlStatementText ,
                       1 ,
                       :P_Parm.SqlStatementTextLen )
              ) ;

       on-error ;
          return ;
       endmon ;

       return ;

      /end-free                                                                                    

Lundi400
Messages : 8
Enregistré le : dim. 24 janv. 2016, 10:19:47

(sans sujet)

Message par Lundi400 »

Grand merci

C'est exactement ce que je souhaitais.

Bonne journée

Répondre