<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Read Oracle json  database CLOB in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902360#M356601</link>
    <description>&lt;P&gt;The lines SQL*PLUS drew under the variables names look very long.&lt;/P&gt;
&lt;P&gt;Perhaps the TYPE of variable that your ORACLE query creates is not compatible with SAS variables?&lt;/P&gt;
&lt;P&gt;Can you add CAST() functions into your SELECT so you are sure that the results are something SAS can load?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select cast(j.id as varchar(10)) ID
     , cast(j.date1 as varchar(24)) DATE1
     , cast(j.date2 as varchar(24)) DATE2
from ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That alter schema does not appear to be doing anything since you are not making any table&amp;nbsp; so can you skip that step also in SQL*PLUS and see if it changes anything there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I am not sure what the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2216"&gt;@qq&lt;/a&gt; in your SQL*PLUS log means.&amp;nbsp; Are you sure that is generating the exact same query as what you posted before in the SAS code?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2023 16:54:24 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-11-09T16:54:24Z</dc:date>
    <item>
      <title>Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902285#M356557</link>
      <description>&lt;P&gt;Hi i'm facing a problem reading an oracle 21.2 that has CLOB and JSON columns data type.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp; same query in sql*plus or other GUI work perfectly but it doesnt exctrat any record if i launch it in SAS Pass Through.&lt;/P&gt;
&lt;P&gt;I use pass Through to use the native ORACLE JSON functions such as JSON_TABLE, JSON_EXISTS and so on.&lt;/P&gt;
&lt;P&gt;Tjhe client oracle is 19.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help? Maybe an options in the connection string?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 10:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902285#M356557</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T10:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902289#M356559</link>
      <description>&lt;P&gt;Please share your code and log.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 12:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902289#M356559</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-11-09T12:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902291#M356561</link>
      <description>code: &lt;BR /&gt;proc sql _method ;&lt;BR /&gt;connect to oracle(user=user password='password'&lt;BR /&gt;PATH = pathname);&lt;BR /&gt;  execute (alter session set current_schema = schema) by oracle;&lt;BR /&gt;&lt;BR /&gt; create table table as &lt;BR /&gt; select * from connection to oracle&lt;BR /&gt;(&lt;BR /&gt;select j.*,d.JSON_field1 ,d.JSON_field2&lt;BR /&gt;from   user.tableora d, &lt;BR /&gt;       json_table (&lt;BR /&gt;         d.JSON_field2, '$' columns (&lt;BR /&gt;           id PATH '$.idnum',&lt;BR /&gt;           date1 PATH '$.date1',&lt;BR /&gt;           date2 PATH '$.date2')&lt;BR /&gt;           )j &lt;BR /&gt;           WHERE json_exists(d.JSON_field1 ,&lt;BR /&gt;                    '$[*]?(@.idnum == 11)')&lt;BR /&gt;);&lt;BR /&gt;DISCONNECT FROM ORACLE;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;LOG:&lt;BR /&gt;NOTE: SQL execution methods chosen are:&lt;BR /&gt;&lt;BR /&gt;      sqxcrta&lt;BR /&gt;          sqxextr( connection to oracle &lt;BR /&gt;/* dbms=oracle, connect options=(user=user password=XXXXX PATH = pathname) */ ( select j.*,d.JSON_field ,d.JSON_field2 from &lt;BR /&gt;user.tableora d, json_table ( d.JSON_field2, '$' colum ... ) )&lt;BR /&gt;NOTE: Table WORK.TABLE created, with 0 rows and 5 columns.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2023 12:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902291#M356561</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T12:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902310#M356567</link>
      <description>&lt;P&gt;So nothing in the log from Oracle itself?&lt;/P&gt;
&lt;P&gt;I not sure if it helps, try add these options to your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sastrace=',,,d' sastraqceloc=saslog nostsuffix msglevel=i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't get more information from this, see if a DBA can help you browse the Oracle internal logs.&lt;/P&gt;
&lt;P&gt;Also, try a step that queries another table in the same schema with non-JSON data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902310#M356567</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-11-09T14:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902323#M356571</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;thanks for the answer, the options doesnt give any useful informations, i'm gonna aks the DBA for the details in log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And yes if i query a table with no json columns i get the records.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 14:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902323#M356571</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T14:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902351#M356593</link>
      <description>we just tried the same query on server with sql*plus and it works, maybe some missing options in sas code?</description>
      <pubDate>Thu, 09 Nov 2023 16:07:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902351#M356593</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T16:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902353#M356595</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1929"&gt;@gtadda&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;we just tried the same query on server with sql*plus and it works, maybe some missing options in sas code?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean you ran the exact same ORACLE code on the same ORACLE database using a different interface to ORACLE?&lt;/P&gt;
&lt;P&gt;Did you sign-on using the same account?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why did you include the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;alter session set current_schema = schema;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your code does not look that complicated.&amp;nbsp; It wanted "table" created in "schema" then why not include that in the SQL to begin with?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table "schema"."table" as&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted "schema" to be your default schema why not just include that when you connected to ORACLE? Either in your SQL CONNECT statement or in the LIBNAME statement you used to create the connection to ORACLE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 16:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902353#M356595</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-09T16:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902357#M356598</link>
      <description>Do you mean you ran the exact same ORACLE code on the same ORACLE database using a different interface to ORACLE?&lt;BR /&gt;Yes i take the same query and the same user in the sql*plus interface  and this is the result</description>
      <pubDate>Thu, 09 Nov 2023 16:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902357#M356598</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T16:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902358#M356599</link>
      <description>SQL*Plus: Release 19.0.0.0.0 - Production on Thu Nov 9 16:57:12 2023&lt;BR /&gt;Version 19.3.0.0.0&lt;BR /&gt;&lt;BR /&gt;Copyright (c) 1982, 2019, Oracle.  All rights reserved.&lt;BR /&gt;&lt;BR /&gt;SQL&amp;gt; connect user/xxxxxxxx@pathname&lt;BR /&gt;Connected.&lt;BR /&gt;SQL&amp;gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2216"&gt;@qq&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;id&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;date1&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;date2&lt;BR /&gt;--------------------------------------------------------------------------------&lt;BR /&gt;11&lt;BR /&gt;2023-09-14T00:00:00+0200&lt;BR /&gt;2024-09-14T00:00:00+0200&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2023 16:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902358#M356599</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T16:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902360#M356601</link>
      <description>&lt;P&gt;The lines SQL*PLUS drew under the variables names look very long.&lt;/P&gt;
&lt;P&gt;Perhaps the TYPE of variable that your ORACLE query creates is not compatible with SAS variables?&lt;/P&gt;
&lt;P&gt;Can you add CAST() functions into your SELECT so you are sure that the results are something SAS can load?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select cast(j.id as varchar(10)) ID
     , cast(j.date1 as varchar(24)) DATE1
     , cast(j.date2 as varchar(24)) DATE2
from ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That alter schema does not appear to be doing anything since you are not making any table&amp;nbsp; so can you skip that step also in SQL*PLUS and see if it changes anything there?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I am not sure what the&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2216"&gt;@qq&lt;/a&gt; in your SQL*PLUS log means.&amp;nbsp; Are you sure that is generating the exact same query as what you posted before in the SAS code?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 16:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902360#M356601</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-09T16:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Read Oracle json  database CLOB</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902364#M356605</link>
      <description>&lt;P&gt;solved ! the problem was in the code, you have to select only the flattened columns cause SAS doesnt understand the ORACLE CLOB or JSON data type.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works like a charm&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql _method ;&lt;BR /&gt;connect to oracle(user=user password='xxxx' &lt;BR /&gt;PATH = pathname);&lt;BR /&gt;execute (alter session set current_schema = schema) by oracle;&lt;/P&gt;
&lt;P&gt;create table tablesas as &lt;BR /&gt;select * from connection to oracle&lt;BR /&gt;(&lt;BR /&gt;select j.*&lt;BR /&gt;from user.tableora d, &lt;BR /&gt;json_table (&lt;BR /&gt;d.JSON_field2, '$' columns (&lt;BR /&gt;id PATH '$.idnum',&lt;BR /&gt;date1 PATH '$.date1',&lt;BR /&gt;date2 PATH '$.date2')&lt;BR /&gt;)j &lt;BR /&gt;WHERE json_exists(d.JSON_field1 ,&lt;BR /&gt;'$[*]?(@.idnum == 11)')&lt;BR /&gt;);&lt;BR /&gt;DISCONNECT FROM ORACLE;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 17:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-Oracle-json-database-CLOB/m-p/902364#M356605</guid>
      <dc:creator>gtadda</dc:creator>
      <dc:date>2023-11-09T17:06:45Z</dc:date>
    </item>
  </channel>
</rss>

