Return results of a sql query as JSON in oracle 12c

后端 未结 9 1617
误落风尘
误落风尘 2020-11-29 05:42

Background

I need to fetch a few thousands rows from Oracle and convert them to JSON for use in SlickGrid. Currently I am fetching the rows in PHP,

9条回答
  •  庸人自扰
    2020-11-29 06:24

    Oracle 12c version 12.1.0.2 (the latest version as of 11.11.2014) adds JSON support: https://docs.oracle.com/database/121/NEWFT/chapter12102.htm#BGBGADCC

    It's been available since October 17th. https://blogs.oracle.com/db/entry/oracle_database_12c_release_1

    If you are unable to patch/work with that version there is an excellent package written by Lewis Cunningham and Jonas Krogsboell: PL/JSON * http://pljson.sourceforge.net/

    It's an excellent package (I have used it in numerous database installations).

    The examples included are good and cover most scenarios.

    declare 
      ret json;
    begin
      ret := json_dyn.executeObject('select * from tab');
      ret.print;
    end;
    /
    

提交回复
热议问题