このプロシージャを使用すると、指定したテーブルやビューをJSON 表現に変換することができます。

Parameters

Parameter

Description

tableName

Fully qualified table or view name which should be converted to JSON; mandatory

Usage

CALL "UTILS.tableToJson"(
"tableName" => 'string_tableName'
);;

Example

この例では、サンプル View を作成し、それを JSON に変換します:

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'
);;

次のような結果が得られます:

{"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.