Add SQL datasets

<< Click to Display Table of Contents >>

Current:  System Integration > WebAPI 

Add SQL datasets

Previous pageReturn to chapter overviewNext page

Request address

http://ip:port/bi/api?action=saveSQLQuery&token=xxxx

Request message

Request parameter

required parameter:xmlData (required)

<?xml version="1.0" encoding="UTF-8"?>

<info>

   <path>test</path>

   <dbsource>mysql_test</dbsource>

   <sql>SELECT * FROM TEST;</sql>

   <material>true</material>

   <cols>

       <col>

           <name>Date</name>

           <alias>date</alias>

       </col>

       <col>

           <name>Time</name>

           <alias>time</alias>

      </col>

   </cols>

</info>

parametric description

1)path(required):The path to the dataset. If the path does not exist, create the sql dataset. Otherwise, modify the dataset of the path.

2)dbsource(required):Data source path.

3)sql(required):Sql statement.

4)material(optional): Materialized query or release of materialized query. Values can only be true and false.

5)cols(optional): you need to define a set of columns for aliases. If a column does not have an alias, the alias of the column is set according to the modified alias.

6)col(optional):defines column aliases.

7)name(required):column name (case-insensitive)

8)alias(optional): alias. If you want to cancel the alias of the column, do not write the node.

Sample

function saveSqlQuery() {

   var xml = getXml();

   $.post("http://" + ip + ":" + port + "/" + project + "/api?action=saveSQLQuery&token=xxxx",

     { xmlData : xml }, function( result) {

           writeXml(result)

   });

}

Response message

Response result

 

<?xml version="1.0" encoding="UTF-8"?>

<results>

   <result>

       <level>1</level>

       <message>Save Success</message>

   </result>

</results>

Result description

The response result information is xml. direct parse.

1) Level return type, different values represent different return status, see appendix.

2) Message is the interface operation result information.