<?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: How to execute json query in talend job for postgres database in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307455#M78893</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, yes i have fixed it , but now i am getting different error.(attached error screenshot)&lt;/P&gt;&lt;P&gt;Do you think with statement in query is creating the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;PK&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrkS"&gt;json_query_error.PNG&lt;/A&gt;</description>
    <pubDate>Wed, 17 Jan 2018 10:57:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-17T10:57:04Z</dc:date>
    <item>
      <title>How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307451#M78889</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt; 
&lt;P&gt;I need to execute json query in postgres database below is the example.&lt;/P&gt; 
&lt;P&gt;When i run this query in tpostsqlInput component, i get many compilation error.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I am able to execute this query in pgadmin, can some one help.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;WITH aid AS ( 
	SELECT u.eid
		, btrim((u.type)::text, '"'::text) AS type
		, btrim((u.value)::text, '"'::text) AS value 
	FROM ( 
		SELECT xyz.eid
			, (xyz.value -&amp;gt; 'type'::text) AS type
			, (xyz.value -&amp;gt; 'value'::text) AS value 
		FROM ( 
			WITH reports(data) AS ( 
				SELECT (e_1.data)::json AS data
					, e_1.eid 
				FROM entities_history e_1 
				WHERE e_1.version = (SELECT max(i.version) AS max FROM entities_history i WHERE i.eid = e_1.eid)
					-- AND eid = 29381
					-- AND bulk_load_id = '506100'
				) 
			SELECT r.data, r.eid, obj.value 
			FROM reports r
				, LATERAL json_array_elements((r.data #&amp;gt; '{alternateIds}'::text[])) obj(value)) xyz
		) u 
		WHERE (btrim((u.type)::text, '"'::text) = 'SCID'::text) 
	)
, gsl6 AS ( 
	SELECT u.eid
		, btrim((u.type)::text, '"'::text) AS type
		, btrim((u.value)::text, '"'::text) AS value 
	FROM ( 
		SELECT xyz.eid
			, (xyz.value -&amp;gt; 'type'::text) AS type
			, (xyz.value -&amp;gt; 'value'::text) AS value 
		FROM ( 
			WITH reports(data) AS ( 
				SELECT (e_1.data)::json AS data
					, e_1.eid 
				FROM entities_history e_1 
				WHERE e_1.version = (SELECT max(i.version) AS max FROM entities_history i WHERE i.eid = e_1.eid)
					-- AND eid = 99485
					-- AND bulk_load_id = '506100'
				) 
			SELECT r.data, r.eid, obj.value 
			FROM reports r
				, LATERAL json_array_elements((r.data #&amp;gt; '{alternateIds}'::text[])) obj(value)) xyz
		) u 
	WHERE (btrim((u.type)::text, '"'::text) = 'GSL6'::text) 
	)
, gold_id AS ( 
	SELECT u.eid
		, btrim((u.type)::text, '"'::text) AS type
		, btrim((u.value)::text, '"'::text) AS value 
	FROM ( 
		SELECT xyz.eid
			, (xyz.value -&amp;gt; 'type'::text) AS type
			, (xyz.value -&amp;gt; 'value'::text) AS value 
		FROM ( 
			WITH reports(data) AS ( 
				SELECT (e_1.data)::json AS data
					, e_1.eid 
				FROM entities_history e_1 
				WHERE e_1.version = (SELECT max(i.version) AS max FROM entities_history i WHERE i.eid = e_1.eid)
					-- AND eid = 99485
					-- AND bulk_load_id = '506100'
				) 
			SELECT r.data, r.eid, obj.value 
			FROM reports r
			, LATERAL json_array_elements((r.data #&amp;gt; '{alternateIds}'::text[])) obj(value)) xyz
		) u 
	WHERE (btrim((u.type)::text, '"'::text) = 'GOLD_ID'::text) 
	)
, branch_id AS (
	SELECT u.eid
	, btrim((u.type)::text, '"'::text) AS type
	, btrim((u.value)::text, '"'::text) AS value
	FROM (
		SELECT xyz.eid
			, (xyz.value -&amp;gt; 'type'::text) AS type
			, (xyz.value -&amp;gt; 'value'::text) AS value
		FROM (
			WITH reports(data) AS (
				SELECT (e_1.data)::json AS data
					, e_1.eid
				FROM entities_history e_1
				WHERE e_1.version = (SELECT max(i.version) AS max FROM entities_history i WHERE i.eid = e_1.eid)
					-- AND eid = 99485
					-- AND bulk_load_id = '506100'
			)
         SELECT r.data, r.eid, obj.value
         FROM reports r
			, LATERAL json_array_elements((r.data #&amp;gt; '{alternateIds}'::text[])) obj(value)) xyz
		) u
	WHERE (btrim((u.type)::text, '"'::text) = 'GOLD_BRANCH_ID'::text)
	)
SELECT
	e.type AS entitytype,
	e.id AS entityid,
	e.root_id AS party_id,
	h.parent_eid as parent_eid,
	aid.value AS scidvalue,
	gsl6.value AS gsl6,
	gold_id.value AS gold_id,
	branch_id.value AS branch_id,
	btrim(((h.data -&amp;gt; 'legalName'::text))::text, '"'::text) AS legalname
FROM entities_history h 
	INNER JOIN (
		SELECT eid, source_id, ROW_NUMBER() OVER(PARTITION BY eid ORDER BY CASE source_type WHEN 'GETS-SSS' THEN 1 WHEN 'REQUEST' THEN 2 ELSE '9' END ASC, version DESC) AS rn
		FROM entities_history
			) ext_source_ident
		ON ext_source_ident.eid = h.eid&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 10:27:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307451#M78889</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-16T10:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307452#M78890</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what errors do you see?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Lojdr&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 12:10:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307452#M78890</guid>
      <dc:creator>lojdr</dc:creator>
      <dc:date>2018-01-16T12:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307453#M78891</link>
      <description>&lt;P&gt;Attaching screenshot of error.&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lrk2"&gt;json_query_error.PNG&lt;/A&gt;</description>
      <pubDate>Wed, 17 Jan 2018 09:02:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307453#M78891</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-17T09:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307454#M78892</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you try to use escape sequences in your query for double quotas?&lt;/P&gt;&lt;P&gt;E.g.:&lt;/P&gt;&lt;PRE&gt; btrim((u.type)::text, '\"'::text) AS type&lt;/PRE&gt;&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; btrim((u.type)::text, '"'::text) AS type&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Lojdr&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 09:33:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307454#M78892</guid>
      <dc:creator>lojdr</dc:creator>
      <dc:date>2018-01-17T09:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307455#M78893</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply, yes i have fixed it , but now i am getting different error.(attached error screenshot)&lt;/P&gt;&lt;P&gt;Do you think with statement in query is creating the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;PK&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrkS"&gt;json_query_error.PNG&lt;/A&gt;</description>
      <pubDate>Wed, 17 Jan 2018 10:57:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307455#M78893</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-17T10:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute json query in talend job for postgres database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307456#M78894</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Do you have the query in double quotas in the job definition (at the beginning and at the end)?&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture1.JPG" style="width: 420px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LsI9.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/141495iC40D5DD48694C6B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LsI9.jpg" alt="0683p000009LsI9.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Regards&lt;/P&gt; 
&lt;P&gt;Lojdr&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 11:20:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-execute-json-query-in-talend-job-for-postgres-database/m-p/2307456#M78894</guid>
      <dc:creator>lojdr</dc:creator>
      <dc:date>2018-01-17T11:20:16Z</dc:date>
    </item>
  </channel>
</rss>

