<?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: while fetching data from SQl thru pass thrugh query column length is big in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/384275#M24766</link>
    <description>&lt;P&gt;Very interesting and useful. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jul 2017 14:07:50 GMT</pubDate>
    <dc:creator>TomKari</dc:creator>
    <dc:date>2017-07-31T14:07:50Z</dc:date>
    <item>
      <title>while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18104#M3220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am geting below problem kindly check,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;while fetching data from oracle using pass thru query ,the column length is more than 4000 in oracle .but it is defaultly taking 1000 length in sas data set .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for your reference appended code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oracle(user=developer password="&amp;amp;dbpass" path='cprdev');&lt;/P&gt;&lt;P&gt;execute (execute CPR147_NPA_LOSS_ASSETS(to_date(&amp;amp;DATE1,'yyyymmdd'),(to_date(&amp;amp;DATE6,'yyyymmdd')))) by oracle;&lt;/P&gt;&lt;P&gt;create table rbi_147 as select * from connection to oracle(select&amp;nbsp; * from NPA_LOSS_ASSETS_RPDG_REP order by SR_NO,NAME_OF_BORROWER );&lt;/P&gt;&lt;P&gt;disconnect from oracle;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 05:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18104#M3220</guid>
      <dc:creator>RameshReddy</dc:creator>
      <dc:date>2011-12-21T05:50:58Z</dc:date>
    </item>
    <item>
      <title>while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18105#M3221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;SAS has a default limit when converting certain datatypes from Oracle (e.g. RAW).&amp;nbsp; Have a look at the dbmax_text option at &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#connect.htm"&gt;http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#connect.htm&lt;/A&gt;&lt;SPAN&gt; .&amp;nbsp; Hopefully that will help &lt;/SPAN&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Dec 2011 14:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18105#M3221</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-12-22T14:29:01Z</dc:date>
    </item>
    <item>
      <title>while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18106#M3222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know that VARCHAR variables are very popular in Oracle; SAS doesn't have a variable length character datatype, so this can be a problem when accessing Oracle from SAS. If any of your Oracle variables are longer than 256 bytes, they are probably causing your problems. Could you perhaps define a view on the longer variables that could reduce the size?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Dec 2011 04:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18106#M3222</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2011-12-24T04:09:05Z</dc:date>
    </item>
    <item>
      <title>while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18107#M3223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agree with DF. Using "dbmax_text" should allow you to retrieve strings up to the maximum a SAS character variable can store (32767 bytes). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the Oracle variable contains an even longer string (eg. in a CLOB) then you need to split up this variable inside your pass-through SQL. You should find a lot of examples for this via Google as also PL/SQL can only hold variables up to 32K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2011 00:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18107#M3223</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-12-27T00:16:03Z</dc:date>
    </item>
    <item>
      <title>while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18108#M3224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes DBMAX_TEXT=32767 option working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Dec 2011 12:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/18108#M3224</guid>
      <dc:creator>RameshReddy</dc:creator>
      <dc:date>2011-12-28T12:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/384131#M24753</link>
      <description>&lt;P&gt;Apologies for bumping such an old thread. It comes up consistently with Google though so I hope this will help others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below is an effective method for retrieving a single record with a large CLOB. Instead of calculating how many fields to split the clob into resulting in a very wide record, it instead splits it into multiple rows. See expected output at bottom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Disclaimer: Although effective it may not be efficient ie may not scale well to multiple rows, the generally accepted approach then is row pipelining PLSQL. That being said, the below got me out of a pinch...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
connect to oracle (authdomain=YOUR_Auth path=devdb DBMAX_TEXT=32767 );
&lt;BR /&gt;create table clob_chunks (compress=yes) as
select *
from connection to Oracle (
	SELECT    id
		, key	
		, level clob_order
		, regexp_substr(clob_value, '.{1,32767}', 1, level, 'n') clob_chunk
	FROM (
		SELECT id, key, clob_value
		FROM schema.table
		WHERE id = 123
	)
	CONNECT BY LEVEL &amp;lt;= regexp_count(clob_value, '.{1,32767}',1,'n')
)
order by id, key, clob_order;

disconnect from oracle;

QUIT;	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Expected output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID	KEY	CHUNK	CLOB
1	1	1	short_clob
2	2	1	long clob chunk1of3
2	2	2	long clob chunk2of3
2	2	3	long clob chunk3of3
3	3	1	another_short_one&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Explanation:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;DBMAX_TEXT tells SAS to adjust the default of 1024 for a clob field.&lt;/LI&gt;&lt;LI&gt;The regex .{1,32767} tells Oracle to match at least once but no more than 32767 times. This splits the input and captures the last chunk which is likely to be under 32767 in length.&lt;/LI&gt;&lt;LI&gt;The regexp_substr is pulling a chunk from the clob (param1) starting from the start of the clob (param2), skipping to the 'level'th occurance (param3) and treating the clob as one large string (param4 'n').&lt;/LI&gt;&lt;LI&gt;The connect by re-runs the regex to count the chunks to stop the level incrementing beyond end of the clob.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;References:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="http://support.sas.com/kb/41/575.html" target="_self"&gt;SAS KB article for DBMAX_TEXT&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions135.htm#SQLRF20014" target="_self"&gt;Oracle docs for REGEXP_COUNT&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions138.htm#SQLRF06303" target="_self"&gt;Oracle docs for REGEXP_SUBSTR&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://docs.oracle.com/cd/B28359_01/server.111/b28286/ap_posix001.htm#SQLRF55423" target="_self"&gt;Oracle regex syntax&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://stackoverflow.com/a/14331055/5291110" target="_self"&gt;Stackoverflow example of regex splitting&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 01:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/384131#M24753</guid>
      <dc:creator>hamishcarpenter</dc:creator>
      <dc:date>2017-07-31T01:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: while fetching data from SQl thru pass thrugh query column length is big</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/384275#M24766</link>
      <description>&lt;P&gt;Very interesting and useful. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 14:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/while-fetching-data-from-SQl-thru-pass-thrugh-query-column/m-p/384275#M24766</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-07-31T14:07:50Z</dc:date>
    </item>
  </channel>
</rss>

