<legend id='0Wfba'><style id='0Wfba'><dir id='0Wfba'><q id='0Wfba'></q></dir></style></legend>
    1. <i id='0Wfba'><tr id='0Wfba'><dt id='0Wfba'><q id='0Wfba'><span id='0Wfba'><b id='0Wfba'><form id='0Wfba'><ins id='0Wfba'></ins><ul id='0Wfba'></ul><sub id='0Wfba'></sub></form><legend id='0Wfba'></legend><bdo id='0Wfba'><pre id='0Wfba'><center id='0Wfba'></center></pre></bdo></b><th id='0Wfba'></th></span></q></dt></tr></i><div id='0Wfba'><tfoot id='0Wfba'></tfoot><dl id='0Wfba'><fieldset id='0Wfba'></fieldset></dl></div>

        <bdo id='0Wfba'></bdo><ul id='0Wfba'></ul>
      <tfoot id='0Wfba'></tfoot>

      1. <small id='0Wfba'></small><noframes id='0Wfba'>

        在 oracle 12c 中将 sql 查询的结果作为 JSON 返回

        时间:2023-09-20

          <legend id='9rZgS'><style id='9rZgS'><dir id='9rZgS'><q id='9rZgS'></q></dir></style></legend>

            <small id='9rZgS'></small><noframes id='9rZgS'>

          1. <tfoot id='9rZgS'></tfoot>
            • <bdo id='9rZgS'></bdo><ul id='9rZgS'></ul>

                  <tbody id='9rZgS'></tbody>
              1. <i id='9rZgS'><tr id='9rZgS'><dt id='9rZgS'><q id='9rZgS'><span id='9rZgS'><b id='9rZgS'><form id='9rZgS'><ins id='9rZgS'></ins><ul id='9rZgS'></ul><sub id='9rZgS'></sub></form><legend id='9rZgS'></legend><bdo id='9rZgS'><pre id='9rZgS'><center id='9rZgS'></center></pre></bdo></b><th id='9rZgS'></th></span></q></dt></tr></i><div id='9rZgS'><tfoot id='9rZgS'></tfoot><dl id='9rZgS'><fieldset id='9rZgS'></fieldset></dl></div>
                • 本文介绍了在 oracle 12c 中将 sql 查询的结果作为 JSON 返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  背景

                  我需要从 Oracle 获取几千行并将它们转换为 JSON 以在 SlickGrid 中使用.目前我正在获取 PHP 中的行,使用 iconv 将其从 ISO 转换为 UTF-8,并使用 json_encode 导出到 json.整个操作在 DB 端大约需要 1 秒,生成 JSON 需要 5 秒.太长了.

                  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, converting it from ISO to UTF-8 with iconv and exporting to json with json_encode. The whole operation takes about 1 second on DB side and 5 seconds to generate JSON. It is way to long.

                  问题

                  我已经读到 Oracle 12c 支持 JSON,但我找不到我需要的确切内容.

                  I have read that Oracle 12c supports JSON, but I cannot find exactly what I need.

                  有没有办法以json格式返回标准sql查询的结果?

                  Is there a way to return the result of a standard sql query in a json format?

                  据说我想发出类似这样的查询:

                  supposedly I would like to issue a query similar to this:

                  SELECT * from table AS JSON
                  

                  并接收一个类似于此的有效 json:

                  and receive a valid json similar to this:

                  [{"col1": "value1", "col2": 2}, {"col1": "valueOfRow2", "col2": 3}]
                  

                  重要的是,我需要为我转义 unicode 序列,因为我在客户端使用 ISO-8859-2 字符集,而 JSON 必须采用 UTF-8 或转义序列.

                  An important thing is that I need to have the unicode sequences escaped for me, as I use ISO-8859-2 charset on the client side, and JSON have to be in either UTF-8 or have the sequences escaped.

                  推荐答案

                  Oracle 12c 版本 12.1.0.2(最新版本截至 11.11.2014)添加了 JSON 支持:https://docs.oracle.com/database/121/NEWFT/chapter12102.htm#BGBGADCC

                  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

                  它自 10 月 17 日起可用.https://blogs.oracle.com/db/entry/oracle_database_12c_release_1

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

                  如果您无法修补/使用该版本,则可以使用 Lewis Cunningham 和 Jonas Krogsboell 编写的优秀软件包:PL/JSON* http://pljson.sourceforge.net/

                  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;
                  /
                  

                  这篇关于在 oracle 12c 中将 sql 查询的结果作为 JSON 返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:检查是否“这是一个数字"Oracle 中的函数 下一篇:在 Oracle 中将字符串日期转换为日期时间

                  相关文章

                  • <bdo id='uQo4c'></bdo><ul id='uQo4c'></ul>

                  <small id='uQo4c'></small><noframes id='uQo4c'>

                • <i id='uQo4c'><tr id='uQo4c'><dt id='uQo4c'><q id='uQo4c'><span id='uQo4c'><b id='uQo4c'><form id='uQo4c'><ins id='uQo4c'></ins><ul id='uQo4c'></ul><sub id='uQo4c'></sub></form><legend id='uQo4c'></legend><bdo id='uQo4c'><pre id='uQo4c'><center id='uQo4c'></center></pre></bdo></b><th id='uQo4c'></th></span></q></dt></tr></i><div id='uQo4c'><tfoot id='uQo4c'></tfoot><dl id='uQo4c'><fieldset id='uQo4c'></fieldset></dl></div>

                  <legend id='uQo4c'><style id='uQo4c'><dir id='uQo4c'><q id='uQo4c'></q></dir></style></legend>

                  <tfoot id='uQo4c'></tfoot>