1 sql.toTEXT

Generate a table in text mode with the values obtained from:

  • select (or union) in XSQL.
  • select in native SQL indicated netween the tags nativesql.
  • vtable.
  • A xml of a sqlresponse.

<sql.toTEXT>
    <in> ?
        <vtable /> *
        <soapsqlresponse /> *
    </in>
    <union /> ?
    <select /> ?
    <nativesql /> ?
</sql.toTEXT>

Exceptions

sql exception ...

Error of sql.

Example

Query sql through writing on tags.

Copy
<xsql-script name='sql_sql2text_sample1'>
    <body>
        <println>
            <sql.toTEXT>
                <select>
                    <columns>code, namdia</columns>
                    <from table='cdiary' />
                </select>
            </sql.toTEXT>
        </println>
    </body>
</xsql-script>

Generate the following output:

Copy
+------+---------------------+
|code  |namdia               |
+------+---------------------+
|DC    |CASH DIARY           |
|DV    |SALES DIARY          |
|DG    |GENERAL DIARY        |
|DL    |SETTLEMENT DIARY     |
|CA    |CASH                 |
|AM    |ADMINISTRATION       |
|01    |01 TEST              |
|00    |00 TEST              |
+------+---------------------+
Example

Query sql in native code.

Copy
<xsql-script name='sql_sql2text_sample2'>
   <body>
       <println>
           <sql.toTEXT>
               <nativesql>SELECT gcompedh.third FROM gcompedh</nativesql>
           </sql.toTEXT>
       </println>
   </body>
</xsql-script>
Example

Query sql in native code.

Copy
<xsql-script name='sql_sql2text_sample2'>
   <body>
       <println>
           <sql.toTEXT>
               <nativesql>SELECT gcompedh.third FROM gcompedh</nativesql>
           </sql.toTEXT>
       </println>
   </body>
</xsql-script>
Example

Creation of a XML structure through a vtable.

Copy
<xsql-script name='sql_sql2text3'>
   <body>
       <vtable name='v1'>
           <column name='code' type='char' unique='true' />
           <column name='name' type='char' size='25' />
           <column name='number' type='integer' />
           <column name='balance'  type='decimal' scale='2' editable='true' />
       </vtable>

       <vtable.insert name='v1'>
           <column name='code'>A</column>
           <column name='name'>Name AA</column>
           <column name='number'>0</column>
           <column name='balance'>12.9</column>
       </vtable.insert>

       <vtable.insert name='v1'>
           <column name='code'>B</column>
           <column name='name'>Name BB</column>
           <column name='number'>1</column>
           <column name='balance'>-17.99</column>
       </vtable.insert>

       <println>
           <sql.toTEXT>
               <in>
                   <v1/>
               </in>
           </sql.toTEXT>
       </println>
   </body>
</xsql-script>

Generate the following output:

Copy
+------+---------+------+------+
|code  |name     |number|balance |
+------+---------+------+--------+
|A     |Name AA  |     0| 12.90  |
|B     |Name BB  |     1|-17.99  |
+------+---------+------+--------+
Example

Create a table in html with the data obtained of the result of a soap call.

Copy
<xsql-script name='sql_sql2text4'>
   <body>
       <set name='m_response'>
           <soap.call
               url='http://localhost:80/soap/servlet/rpcrouter'
               uri='urn:SOAPSQLServer'
               method='executeSQL'
               user='demo'
               password='abcdemo'
               >
               <parameters>
                  <parameter name='database'>demo_sports1</parameter>
                  <parameter name='sqlstmt'>SELECT * FROM cdiary</parameter>
               </parameters>
           </soap.call>
       </set>

       <println>
           <m_response />
       </println>

       <println>
           <sql.toTEXT>
               <in><m_response/></in>
           </sql.toTEXT>
       </println>
   </body>
</xsql-script>