1 The system does not prepare sentences automatically which can not be reused

In the XSQL-Script programs the sentences executed against the database are prepared by default at least that the programmer indicates explicitly otherwise through the attribute prepare='false'.

As of October 2013, the statements executed from XSQL-SCRIPTS which contains elements which causes that can not be prepared, automatically they will not be prepared.

This change has been performed to avoid the unnecessary consommation of memory in the cache of the database session which uses cursors that ara variables because they are not reusable. The following example shows a SELECT which does not have sense to store in the cache of statements of the database session. Due to the use of NVL, the variables should be parsed without being able to be set from the prepared.

Copy
<select prefix='m_'>
  <columns>estado, fecbaj</columns>
  <from table='gartclie' />
  <where>
    codcli = <p_third /> AND
    codart = <p_codart /> AND
    (<nvl>udmven, <whitespace /></nvl> = <nvl><p_udmven />, <whitespace /></nvl> OR udmven IS NULL)
  </where>
  <order>varlog DESC, udmven DESC</order>
</select>

In this case, the select would be preparable performing the substitution of the variables in the NVL tag. If the sentence is prepared and transformed to Informix, it would be: Si la sentencia se prepara, transformada a Informix sería:

Copy
SELECT estatus, date
  FROM gartclie
 WHERE codcli = ? AND
       codart = ? AND
       (NVL(udmven, '') = NVL('KG', '') OR udmven IS NULL)
ORDER BY varlog DESC, udmven DESC

Where the values of "p_udmven" should be parsed, they can not be prepared. If the statement is prepared like this, it is stored in the cache of the Informix session. For differents values of "p_udmven", variable statements which are not reusables would be cached with the consequent unnecessary consommation of memory.

For this, the system does not prepare automatically this type of sentences to avoid from being cached in the database session.

Through the command of informix:

Copy
onstat -g stm ses_id

The opened cursors of a session can be seen and during the execution of the script, the active cursors are shown. And with the command:

Copy
onstat -g ses ses_id

All the information relative to the session is shown.

Here is a complete example.

Copy
<xsql-script name='test_memory'>
   <body>
      <foreach>
         <select prefix='p_'>
            <columns>
               gvenpedl.udmven, garticul.udmbas, gvenpedl.codart, gvenpedl.varlog,
               gvenpedh.empcode, gvenpedh.fecha, gvenpedh.cambio, gvenpedh.tercer,
               gvenpedh.delega, gvenpedh.depart
            </columns>
            <from table = 'gvenpedh'>
               <join table = 'gvenpedl' type = 'inner'>
                  <on>gvenpedh.cabid = gvenpedl.cabid</on>
                  <join table = 'garticul' type = 'inner'>
                     <on>gvenpedl.codart = garticul.codigo</on>
                  </join>
               </join>
            </from>
         </select>
         <do>
           <set name='m_varlog' type='string'><ifnull><p_varlog /><string /></ifnull></set>
            <foreach>
                <select prepare-cache='true' prefix='x_'>
                    <columns>estado, fecbaj</columns>
                    <from table='gartclie' />
                    <where>
                        codcli = '#p_tercer' AND
                        codart = <p_codart /> AND
                        (<nvl>udmven, <whitespace /></nvl> = <nvl><p_udmven />, <whitespace /></nvl> OR udmven IS NULL) AND
                        (<nvl>varlog, <whitespace /></nvl> = <nvl><p_varlog />, <whitespace /></nvl> OR varlog IS NULL)
                    </where>
                    <order>varlog DESC, udmven DESC</order>
                </select>
                <do>
                    <foreach.exit/>
                </do>
            </foreach>
         </do>
      </foreach>
   </body>
</xsql-script>

The system will issue the following message to indicate taht the second SELECT would not be prepared because it contains variable elements which are not reusable and thus avoid the unnecessary use of memory of the database session: disabled prepare-cache cause statement contains variables as strings or NVL .