tableToJson
This procedure allows to convert a given table or view to a JSON representation.
Parameters
Parameter | Description |
---|---|
tableName | Fully qualified table or view name which should be converted to JSON; mandatory |
Usage
SQL
CALL "UTILS.tableToJson"(
"tableName" => 'string_tableName'
);;
Example
In this example, we create a sample view and then convert it to JSON:
SQL
CREATE VIEW views.testView
AS
SELECT 1 AS "a", 2 AS "b", 9 AS "c"
UNION ALL
SELECT 5 AS "a", 7 AS "b", 10 AS "c"
UNION ALL
SELECT 9 AS "a", 8 AS "b", 20 AS "c";;
CALL "UTILS.tableToJson"(
"tableName" => 'views.testView'
);;
It gives the following result:
XML
{"testView":{"row":[{"a":1,"b":2,"c":9},{"a":5,"b":7,"c":10},{"a":9,"b":8,"c":20}]}}
This procedure needs a lot of memory. We recommend ensuring that your system has enough RAM available and not use it for huge tables.