Postgres Procedure / function dependencies - postgresql

In pgAdmin tool, when I click on any user-defined function or a procedure on the left side panel, I'm able to see the dependent DB objects like user-defined Types, Schema, Language, Roles etc. in the 'Dependencies' tab.
Is it possible to get the underlying query for those dependencies? Because I need to take the dependent objects for all the procedures and functions from a set of schemas.

Below is the code used in pgAdmin to show Dependents for PostgreSQL 12 plus versions.
This shows up all dependents for all objects. Needs to be filtered out for required objects using oid.
SELECT DISTINCT dep.classid, dep.objid, dep.objsubid, dep.refclassid, dep.refobjid,
dep.deptype,
cl.relkind, ad.adbin, pg_get_expr(ad.adbin, ad.adrelid) as adsrc,
COALESCE(coc.relname, clrw.relname) AS ownertable,
CASE WHEN cl.relname IS NOT NULL AND att.attname IS NOT NULL THEN cl.relname || COALESCE('.' || att.attname, '')
ELSE COALESCE(cl.relname, co.conname, pr.proname, tg.tgname, ty.typname, la.lanname, rw.rulename, ns.nspname,
fs.srvname, fdw.fdwname, evt.evtname, col.collname, ftsc.cfgname, ftsd.dictname, ftsp.prsname,
ftst.tmplname, ext.extname, syn.synname, pl.polname)
END AS refname,
COALESCE(nsc.nspname, nso.nspname, nsp.nspname, nst.nspname, nsrw.nspname, colns.nspname, ftscns.nspname,
ftsdns.nspname, ftspns.nspname, ftstns.nspname, synns.nspname) AS dep_obj_schema,
CASE WHEN cl.relkind IS NOT NULL THEN CASE WHEN cl.relkind = 'r' THEN cl.relkind || COALESCE(dep.objsubid::text, '') ELSE cl.relkind END
WHEN tg.oid IS NOT NULL THEN CASE WHEN tg.tgpackageoid != 0 THEN 'Tc'::text ELSE 'Tr'::text END
WHEN ty.oid IS NOT NULL THEN CASE WHEN ty.typtype = 'd' THEN 'd'::text ELSE 'Ty'::text END
WHEN ns.oid IS NOT NULL THEN CASE WHEN ns.nspparent != 0 AND ns.nspcompoundtrigger = false THEN 'Pa'::text ELSE 'n'::text END
WHEN pr.oid IS NOT NULL AND (prtyp.typname = 'trigger' OR prtyp.typname = 'event_trigger') THEN 'Pt'::text
WHEN pr.oid IS NOT NULL THEN CASE WHEN pr.prokind = 'p' THEN 'Procedure'::text ELSE 'Function'::text END
WHEN la.oid IS NOT NULL THEN 'l'::text
WHEN rw.oid IS NOT NULL THEN 'Rl'::text
WHEN co.oid IS NOT NULL THEN CASE WHEN co.contypid > 0 THEN 'Cd' ELSE 'C'::text || contype END
WHEN ad.oid IS NOT NULL THEN 'A'::text
WHEN fs.oid IS NOT NULL THEN 'Fs'::text
WHEN fdw.oid IS NOT NULL THEN 'Fw'::text
WHEN evt.oid IS NOT NULL THEN 'Et'::text
WHEN col.oid IS NOT NULL THEN 'Co'::text
WHEN ftsc.oid IS NOT NULL THEN 'Fc'::text
WHEN ftsp.oid IS NOT NULL THEN 'Fp'::text
WHEN ftsd.oid IS NOT NULL THEN 'Fd'::text
WHEN ftst.oid IS NOT NULL THEN 'Ft'::text
WHEN ext.oid IS NOT NULL THEN 'Ex'::text
WHEN syn.oid IS NOT NULL THEN 'Sy'::text
WHEN pl.oid IS NOT NULL THEN 'Rs'::text
ELSE ''
END AS dep_obj_type
CASE WHEN inhits.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherits,
CASE WHEN inhed.inhparent IS NOT NULL THEN '1' ELSE '0' END AS is_inherited
FROM pg_catalog.pg_depend dep
LEFT JOIN pg_catalog.pg_class cl ON dep.objid=cl.oid
LEFT JOIN pg_catalog.pg_attribute att ON dep.objid=att.attrelid AND dep.objsubid=att.attnum
LEFT JOIN pg_catalog.pg_namespace nsc ON cl.relnamespace=nsc.oid
LEFT JOIN pg_catalog.pg_proc pr ON dep.objid=pr.oid
LEFT JOIN pg_catalog.pg_namespace nsp ON pr.pronamespace=nsp.oid
LEFT JOIN pg_catalog.pg_trigger tg ON dep.objid=tg.oid
LEFT JOIN pg_catalog.pg_type ty ON dep.objid=ty.oid
LEFT JOIN pg_catalog.pg_namespace nst ON ty.typnamespace=nst.oid
LEFT JOIN pg_catalog.pg_constraint co ON dep.objid=co.oid
LEFT JOIN pg_catalog.pg_class coc ON co.conrelid=coc.oid
LEFT JOIN pg_catalog.pg_namespace nso ON co.connamespace=nso.oid
LEFT JOIN pg_catalog.pg_rewrite rw ON dep.objid=rw.oid
LEFT JOIN pg_catalog.pg_class clrw ON clrw.oid=rw.ev_class
LEFT JOIN pg_catalog.pg_namespace nsrw ON clrw.relnamespace=nsrw.oid
LEFT JOIN pg_catalog.pg_language la ON dep.objid=la.oid
LEFT JOIN pg_catalog.pg_namespace ns ON dep.objid=ns.oid
LEFT JOIN pg_catalog.pg_attrdef ad ON ad.oid=dep.objid
LEFT JOIN pg_catalog.pg_foreign_server fs ON fs.oid=dep.objid
LEFT JOIN pg_catalog.pg_foreign_data_wrapper fdw ON fdw.oid=dep.objid
LEFT JOIN pg_catalog.pg_type prtyp ON prtyp.oid = pr.prorettype
LEFT JOIN pg_catalog.pg_inherits inhits ON (inhits.inhrelid=dep.objid)
LEFT JOIN pg_catalog.pg_inherits inhed ON (inhed.inhparent=dep.objid)
LEFT JOIN pg_catalog.pg_event_trigger evt ON evt.oid=dep.objid
LEFT JOIN pg_catalog.pg_collation col ON col.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace colns ON col.collnamespace=colns.oid
LEFT JOIN pg_catalog.pg_ts_config ftsc ON ftsc.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace ftscns ON ftsc.cfgnamespace=ftscns.oid
LEFT JOIN pg_catalog.pg_ts_dict ftsd ON ftsd.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace ftsdns ON ftsd.dictnamespace=ftsdns.oid
LEFT JOIN pg_catalog.pg_ts_parser ftsp ON ftsp.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace ftspns ON ftsp.prsnamespace=ftspns.oid
LEFT JOIN pg_catalog.pg_ts_template ftst ON ftst.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace ftstns ON ftst.tmplnamespace=ftstns.oid
LEFT JOIN pg_catalog.pg_extension ext ON ext.oid=dep.objid
LEFT JOIN pg_catalog.pg_synonym syn ON syn.oid=dep.objid
LEFT JOIN pg_catalog.pg_namespace synns ON syn.synnamespace=synns.oid
LEFT JOIN pg_catalog.pg_policy pl ON pl.oid=dep.objid
WHERE
classid IN ( SELECT oid FROM pg_catalog.pg_class WHERE relname IN
('pg_class', 'pg_constraint', 'pg_conversion', 'pg_language', 'pg_proc', 'pg_rewrite', 'pg_namespace',
'pg_trigger', 'pg_type', 'pg_attrdef', 'pg_event_trigger', 'pg_foreign_server', 'pg_foreign_data_wrapper',
'pg_collation', 'pg_ts_config', 'pg_ts_dict', 'pg_ts_parser', 'pg_ts_template', 'pg_extension',
'pg_synonym', 'pg_policy'));

Related

PSQL Query Not Modifications

Can someone please edit this query for psql. I try alot but pgAdmin gives me Error that "d.artifact_type as text" has as Error
SELECT
a.id, a.name, a.description, a.user_id, a.created_at, a.updated_at,
array_agg(row_to_json(c.id, c.first_name, c.last_name, c.email,
b.workspace_id, b.share_id, b.share_with_type, b.write_access)) as users,
array_agg(row_to_json(d.id, d.artifact_name, d.original_artifact_name,
d.artifact_size,d.artifact_type, d.file_address,
d.user_id,d.file_type, d.created_at, f.user_assigned_to)) as files,
array_agg(row_to_json(d.artifact_type as text, d.artifact_type as value)) extensions
FROM workspaces a
LEFT JOIN share_workspaces b ON a.id = b.workspace_id
LEFT JOIN users c ON b.share_id = c.id
LEFT JOIN share_artifacts e ON a.id = e.share_id
LEFT JOIN artifacts d ON d.id = e.artifact_id
LEFT JOIN assigned_artifacts f ON f.artifact_id = d.id
WHERE (a.user_id='${user_id}' AND d.is_deleted is not true)
Group By a.id, a.name, a.description, a.user_id, a.created_at, a.updated_at
ORDER BY a.created_at ASC

Jasper Report: error executing SQL statement by Collection Parameter

I'm creating a report which's passing by collection parameter.
The parameter name as 'ids' and the class is java.util.Collection.
My query:
select * from order_deliveryorder a
left join order_deliveryorderline b on a.id = b.d_order_id
left join order_item c on c.id = b.product_id
left join order_orderline e on e.id = b.s_order_id
left join order_order f on e.order_id = f.id
left join order_itemsection g on g.id = f.section_id
left join order_location d on d.id = a.location_id
left join order_location h on h.id = a.from_location_id
where a.id in ('2377900603251741014','2377900603251740997','2377900603251740967')
the query in jasper:
select * from order_deliveryorder a
left join order_deliveryorderline b on a.id = b.d_order_id
left join order_item c on c.id = b.product_id
left join order_orderline e on e.id = b.s_order_id
left join order_order f on e.order_id = f.id
left join order_itemsection g on g.id = f.section_id
left join order_location d on d.id = a.location_id
left join order_location h on h.id = a.from_location_id
where $X{IN, a.id, ids}
The value of parameter "ids" is ["2377900603251741014","2377900603251740997","2377900603251740967"]
In the End, had met the error executing sql statement.

Bad performance for muli joined sub-queries

Could someone help me on this query. When generating the related report through web application it times out due to response time taking over 30seconds(standard http request time out).
select c.counterparty_shortname AS [Réference]
,cty.counterparty_type_name AS [Type ref]
,t.transaction_shortname AS [transaction_shortname]
,mitigant_shortname
,(SELECT ISNULL(SUM(ISNULL(tce.outstanding_amount,0)),0)
from transaction_credit_event tce
where tce.transaction_id=t.transaction_id) AS [Montant impayé]
,(select count(t1.transaction_id)
from [transaction] t1
where t1.counterparty_id=c.counterparty_id) AS [Nbre affaire]
,(select isnull(count(tce.credit_event_id),0)
from transaction_credit_event tce
where tce.transaction_id=t.transaction_id
and isnull(tce.outstanding_amount,0)>0
and tce.credit_event_type_id=51) AS [nbr impaye]
,TT.transaction_type_name AS [Type Produit]
,isnull(cm1.value1_text,'') AS [type garantie]
,isnull(cm2.value1_text,'') AS [marque]
,isnull(cm3.value1_text,'') AS [modele]
,(select top 1 tmp1.payment_posting_date
from (select pp.payment_posting_date
,tce.transaction_id
FROM payment_posting pp
inner JOIN transaction_credit_event tce
ON pp.credit_event_id=tce.credit_event_id) tmp1
where tmp1.transaction_id=t.transaction_id
order by tmp1.payment_posting_date desc) AS [Date dernier paiement]
,fate_shortname AS [sort]
,raf.recovery_action_fate_id
,ISNULL(t.outstanding_amount,0) AS [CRD]
,1 AS [ID]
,(select isnull(count(tce.credit_event_id),0)
from transaction_credit_event tce,[transaction] tt
where tce.transaction_id=tt.transaction_id
and tt.counterparty_id=c.counterparty_id
and isnull(tce.outstanding_amount,0)>0
and tce.credit_event_type_id=51) AS [nbr impaye tiers]
,convert(date,dispatch_start_date,103) AS [date debut]
,convert(date,dispatch_end_date,103) AS [date fin]
,c.counterparty_type_id
,t.transaction_type_id
from counterparty c
inner join wf_task_dispatch w on w.item_id=c.counterparty_id
inner join [transaction] t on c.counterparty_id=t.counterparty_id
LEFT join transaction_recovery tr on tr.counterparty_id=c.counterparty_id and tr.transaction_recovery_id=(select top 1 transaction_recovery_id from transaction_recovery where counterparty_id=c.counterparty_id order by idate desc)
LEFT join recovery_action_fate raf on raf.recovery_action_fate_id=tr.recovery_action_fate_id
left join counterparty_type cty on cty.counterparty_type_id=c.counterparty_type_id
left join [transaction_type] TT on t.transaction_type_id = TT.transaction_type_id
inner join mitigant_transaction mt on mt.transaction_id=t.transaction_id and mt.ddate is null
inner join mitigant m on m.mitigant_id=mt.mitigant_id and mitigant_screen='asset' and m.ddate is null
left join constant_matrix cm1 on cm1.criteria1_text=m.regulatory_mitigant_type and cm1.constant_matrix_shortname='CAIN' and cm1.ddate is null
left join constant_matrix cm2 on cm2.criteria1_text=m.valuation_frequency and cm2.constant_matrix_shortname='MARQ' and cm2.ddate is null
left join constant_matrix cm3 on cm3.criteria1_text=m.valuation_source and cm3.constant_matrix_shortname='GMOD' and cm3.ddate is null
where (select [dbo].FN_GetPhase)=81

SAP BO XI 3.1 SP5 with DB2 10.5 connection Using Client 10 z/OS

We have created a report using SAP BO 3.1 SP5 for DB2 9.7 using client 9. Now we have upgraded the DB2 from 9.7 to 10.5. So using client 10 z/OS we have connected the SAP BO, but the generated query differs from what we get while connecting with client 9. Can anyone explain the issue?
Is it not possible to connect DB10.5 with client 10 z/OS? Is it the generated query have difference by this version difference?
Sorry guys, I am a newbie to BO. Maybe this is a silly question, but we have to answer for this.
Thanks in advance.
I have attached the generated query below:
Generated By Client 9:
SELECT
RPT_EMPLOYEE.FIRST_NAME,
RPT_EMPLOYEE.MIDDLE_NAME,
RPT_EMPLOYEE.LAST_NAME,
GENDER.ITEM_VALUE,
RPT_EMPLOYEE.DEPARTMENT,
SUB_DEPARTMENT.ITEM_VALUE,
RPT_EMPLOYEE.JOB_TITLE,
WD_JOB_GROUP.GROUP_NO,
WD_GLBT_LIST.DESCRIPTION,
WD_EEO_LIST.DESCRIPTION,
CASE WHEN RPT_EMPLOYEE.HAS_DISABILITY = -1 THEN ' ' ELSE DISABILITY.ITEM_VALUE END,
RPT_NEW_HIRE.HIRE_DT,
PART_OF_TEN.ITEM_VALUE,
WD_CLUB.LONG_NAME,
CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN HIRE_SOURCE.ITEM_VALUE ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.PROMOTED <> 0 THEN CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN ',' ELSE '' END || PROMOTED.ITEM_VALUE ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.IS_DEACTIVATED <> 0 THEN CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN ',' ELSE '' END || DEACTIVATED.ITEM_VALUE || '-' ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.IS_DEACTIVATED <> 0 THEN DEACTIVATION_REASON.ITEM_VALUE ELSE ' ' END
FROM
WD_KEY_LIST DEACTIVATION_REASON
LEFT OUTER JOIN RPT_DEACTIVATION ON RPT_DEACTIVATION.REASON_CODE=DEACTIVATION_REASON.ITEM_ID AND DEACTIVATION_REASON.KEY_ID=7
RIGHT OUTER JOIN RPT_EMPLOYEE ON RPT_DEACTIVATION.SURVEY_ID=RPT_EMPLOYEE.SURVEY_ID AND RPT_DEACTIVATION.CLUB_ID=RPT_EMPLOYEE.CLUB_ID AND RPT_EMPLOYEE.EMP_ID=RPT_DEACTIVATION.EMP_ID
LEFT OUTER JOIN RPT_NEW_HIRE ON RPT_EMPLOYEE.SURVEY_ID=RPT_NEW_HIRE.SURVEY_ID AND RPT_EMPLOYEE.CLUB_ID=RPT_NEW_HIRE.CLUB_ID AND RPT_EMPLOYEE.EMP_ID=RPT_NEW_HIRE.EMP_ID
LEFT OUTER JOIN WD_CLUB ON RPT_EMPLOYEE.CLUB_ID=WD_CLUB.CLUB_ID AND WD_CLUB.SURVEY_ID=RPT_EMPLOYEE.SURVEY_ID
LEFT OUTER JOIN WD_GLBT_LIST ON RPT_EMPLOYEE.SURVEY_ID=WD_GLBT_LIST.SURVEY_ID AND WD_GLBT_LIST.GLBT_ID=RPT_EMPLOYEE.GLBT_ID
LEFT OUTER JOIN WD_EEO_LIST ON RPT_EMPLOYEE.SURVEY_ID=WD_EEO_LIST.SURVEY_ID AND WD_EEO_LIST.EEO_ID=RPT_EMPLOYEE.EEO_ID
LEFT OUTER JOIN WD_JOB_GROUP ON RPT_EMPLOYEE.SURVEY_ID=WD_JOB_GROUP.SURVEY_ID AND WD_JOB_GROUP.JOB_GROUP_ID=RPT_EMPLOYEE.JOB_GROUP_ID
LEFT OUTER JOIN WD_KEY_LIST GENDER ON GENDER.ITEM_ID=RPT_EMPLOYEE.GENDER_ID AND GENDER.KEY_ID = 1
LEFT OUTER JOIN WD_KEY_LIST PART_OF_TEN ON PART_OF_TEN.ITEM_ID=RPT_EMPLOYEE.IS_TOP_10 AND PART_OF_TEN.KEY_ID=20
LEFT OUTER JOIN WD_KEY_LIST HIRE_SOURCE ON RPT_EMPLOYEE.IS_ADDED=HIRE_SOURCE.ITEM_ID and HIRE_SOURCE.KEY_ID=12
LEFT OUTER JOIN WD_KEY_LIST PROMOTED ON RPT_EMPLOYEE.PROMOTED=PROMOTED.ITEM_ID AND PROMOTED.KEY_ID=13
LEFT OUTER JOIN WD_KEY_LIST DISABILITY ON RPT_EMPLOYEE.HAS_DISABILITY=DISABILITY.ITEM_ID and DISABILITY.KEY_ID=4
LEFT OUTER JOIN WD_KEY_LIST DEACTIVATED ON RPT_EMPLOYEE.IS_DEACTIVATED=DEACTIVATED.ITEM_ID AND DEACTIVATED.KEY_ID=14
LEFT OUTER JOIN WD_SURVEY SURVEY ON RPT_EMPLOYEE.SURVEY_ID=SURVEY.SURVEY_ID
LEFT OUTER JOIN WD_KEY_LIST SUB_DEPARTMENT ON SUB_DEPARTMENT.ITEM_ID=RPT_EMPLOYEE.SUB_DEPARTMENT AND SUB_DEPARTMENT.KEY_ID = 21
WHERE
(
SURVEY.SHORT_NAME IN ('*******')
AND
SUB_DEPARTMENT.ITEM_VALUE = '*****'
)
Generated By Client 10 z/OS:
SELECT
RPT_EMPLOYEE.FIRST_NAME,
RPT_EMPLOYEE.MIDDLE_NAME,
RPT_EMPLOYEE.LAST_NAME,
GENDER.ITEM_VALUE,
RPT_EMPLOYEE.DEPARTMENT,
SUB_DEPARTMENT.ITEM_VALUE,
RPT_EMPLOYEE.JOB_TITLE,
WD_JOB_GROUP.GROUP_NO,
WD_GLBT_LIST.DESCRIPTION,
WD_EEO_LIST.DESCRIPTION,
CASE WHEN RPT_EMPLOYEE.HAS_DISABILITY = -1 THEN ' ' ELSE DISABILITY.ITEM_VALUE END,
RPT_NEW_HIRE.HIRE_DT,
PART_OF_TEN.ITEM_VALUE,
WD_CLUB.LONG_NAME,
CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN HIRE_SOURCE.ITEM_VALUE ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.PROMOTED <> 0 THEN CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN ',' ELSE '' END || PROMOTED.ITEM_VALUE ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.IS_DEACTIVATED <> 0 THEN CASE WHEN RPT_EMPLOYEE.IS_ADDED <> 0 THEN ',' ELSE '' END || DEACTIVATED.ITEM_VALUE || '-' ELSE '' END || '' ||
CASE WHEN RPT_EMPLOYEE.IS_DEACTIVATED <> 0 THEN DEACTIVATION_REASON.ITEM_VALUE ELSE ' ' END
FROM
WD_KEY_LIST SUB_DEPARTMENT
LEFT OUTER JOIN RPT_EMPLOYEE ON SUB_DEPARTMENT.ITEM_ID=RPT_EMPLOYEE.SUB_DEPARTMENT AND SUB_DEPARTMENT.KEY_ID = 21
RIGHT OUTER JOIN RPT_NEW_HIRE ON RPT_EMPLOYEE.SURVEY_ID=RPT_NEW_HIRE.SURVEY_ID AND RPT_EMPLOYEE.CLUB_ID=RPT_NEW_HIRE.CLUB_ID AND RPT_EMPLOYEE.EMP_ID=RPT_NEW_HIRE.EMP_ID
RIGHT OUTER JOIN WD_CLUB ON RPT_EMPLOYEE.CLUB_ID=WD_CLUB.CLUB_ID AND WD_CLUB.SURVEY_ID=RPT_EMPLOYEE.SURVEY_ID
RIGHT OUTER JOIN WD_GLBT_LIST ON RPT_EMPLOYEE.SURVEY_ID=WD_GLBT_LIST.SURVEY_ID AND WD_GLBT_LIST.GLBT_ID=RPT_EMPLOYEE.GLBT_ID
RIGHT OUTER JOIN WD_EEO_LIST ON RPT_EMPLOYEE.SURVEY_ID=WD_EEO_LIST.SURVEY_ID AND WD_EEO_LIST.EEO_ID=RPT_EMPLOYEE.EEO_ID RIGHT
OUTER JOIN WD_JOB_GROUP ON RPT_EMPLOYEE.SURVEY_ID=WD_JOB_GROUP.SURVEY_ID AND WD_JOB_GROUP.JOB_GROUP_ID=RPT_EMPLOYEE.JOB_GROUP_ID
RIGHT OUTER JOIN WD_KEY_LIST GENDER ON GENDER.ITEM_ID=RPT_EMPLOYEE.GENDER_ID AND GENDER.KEY_ID = 1
RIGHT OUTER JOIN WD_KEY_LIST PART_OF_TEN ON PART_OF_TEN.ITEM_ID=RPT_EMPLOYEE.IS_TOP_10 AND PART_OF_TEN.KEY_ID=20
RIGHT OUTER JOIN WD_KEY_LIST HIRE_SOURCE ON RPT_EMPLOYEE.IS_ADDED=HIRE_SOURCE.ITEM_ID and HIRE_SOURCE.KEY_ID=12
RIGHT OUTER JOIN WD_KEY_LIST PROMOTED ON RPT_EMPLOYEE.PROMOTED=PROMOTED.ITEM_ID AND PROMOTED.KEY_ID=13
RIGHT OUTER JOIN WD_KEY_LIST DISABILITY ON RPT_EMPLOYEE.HAS_DISABILITY=DISABILITY.ITEM_ID and DISABILITY.KEY_ID=4
RIGHT OUTER JOIN RPT_DEACTIVATION ON RPT_DEACTIVATION.SURVEY_ID=RPT_EMPLOYEE.SURVEY_ID AND RPT_DEACTIVATION.CLUB_ID=RPT_EMPLOYEE.CLUB_ID AND RPT_EMPLOYEE.EMP_ID=RPT_DEACTIVATION.EMP_ID
LEFT OUTER JOIN WD_KEY_LIST DEACTIVATION_REASON ON RPT_DEACTIVATION.REASON_CODE=DEACTIVATION_REASON.ITEM_ID AND DEACTIVATION_REASON.KEY_ID=7
RIGHT OUTER JOIN WD_KEY_LIST DEACTIVATED ON RPT_EMPLOYEE.IS_DEACTIVATED=DEACTIVATED.ITEM_ID AND DEACTIVATED.KEY_ID=14
RIGHT OUTER JOIN WD_SURVEY SURVEY ON RPT_EMPLOYEE.SURVEY_ID=SURVEY.SURVEY_ID
WHERE
( SURVEY.CREATED_BY=SURVEY.IS_CREATED )
AND
(
SURVEY.SHORT_NAME IN ('*******')
AND
SUB_DEPARTMENT.ITEM_VALUE = '*******'
)
The differences are instead of LEFT JOIN, RIGHT JOIN have added in client 10 z/OS and the additional condition SURVEY.CREATED_BY=SURVEY.IS_CREATED added in client 10 z/OS.

Postgres UPDATE statement

I have moved from mysql to psql, but find it hard to get my head around the UPDATE statement using multiple left joins.
How would you rewrite this in Postgres? (I am using postresql 9.4)
update task t
left join project p on t.project_id = p.id
left join client c on t.client_id = c.id
left join user u on t.user_id = u.id
set t.project_name = p.name,
t.client_name = c.name,
t.user_name = u.name;
Any pointer will be welcome.
Here you go:
WITH task_data AS (
SELECT t.id,
p.name AS project_name,
c.name AS client_name,
u.name AS user_name
FROM task t
LEFT JOIN project p ON t.project_id = p.id
LEFT JOIN client c ON t.client_id = c.id
LEFT JOIN "user" u ON t.user_id = u.id
)
UPDATE task t
FROM task_data d
SET
project_name = d.project_name,
client_name = d.client_name,
user_name = d.user_name
WHERE t.id = d.id
I would be curious to see if there is a more efficient way