DBA Data[Home] [Help]

APPS.CSM_IB_TXN_SUB_TYPES_EVENT_PKG SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 20

l_updates_cur CSM_UTIL_PKG.Changed_Records_Cur_Type;
Line: 21

l_inserts_cur CSM_UTIL_PKG.Changed_Records_Cur_Type;
Line: 24

l_prog_update_date jtm_con_request_data.last_run_date%TYPE;
Line: 41

SELECT nvl(last_run_date, (sysdate - 365*50))
FROM jtm_con_request_data
WHERE package_name = 'CSM_IB_TXN_SUB_TYPES_EVENT_PKG'
AND procedure_name = 'REFRESH_ACC';
Line: 46

CURSOR l_deletes_cur
IS
SELECT acc.access_id
FROM csm_ib_txn_types_acc acc
WHERE NOT EXISTS
(SELECT cit.sub_type_id
 FROM csi_ib_txn_types cit , csi_source_ib_types cst , csi_txn_types ctt ,
      csi_instance_statuses cis , cs_transaction_types_b ttb
WHERE acc.sub_type_id = cit.sub_type_id
AND cit.cs_transaction_type_id = ttb.transaction_type_id(+)
AND ctt.source_application_id = 513
AND ctt.source_transaction_type = 'FIELD_SERVICE_REPORT'
AND cst.sub_type_id = cit.sub_type_id
AND ctt.transaction_type_id = cst.transaction_type_id
AND cit.src_status_id = cis.instance_status_id(+)
AND (NVL(cst.update_IB_flag, 'N') = 'N' --Non IB
     OR ( cst.update_ib_flag = 'Y'
          and trunc(sysdate) between nvl(cis.start_date_active,trunc(sysdate)) and nvl(cis.end_date_active,trunc(sysdate))
          and nvl(cis.terminated_flag, 'N') <> 'Y'
          and (
		  	  	(--Return IB
		  	  	 cit.src_change_owner_to_code = 'I'
		  	  	 and nvl(cit.parent_reference_reqd, 'N') = 'N'
				 and ttb.line_order_category_code ='RETURN'
          		 and cit.src_change_owner = 'Y'
          	  	 and nvl(cit.src_return_reqd, 'N') = 'N'

				)
             or (--Order IB
			 	cit.src_change_owner_to_code = 'E'
			 	--and cit.src_reference_reqd = 'Y'
			 	and ttb.line_order_category_code='ORDER'
          		and cit.src_change_owner = 'Y'
          		and nvl(cit.src_return_reqd, 'N') = 'N'

			    )
              or
			    (--Loaner IB
				ttb.line_order_category_code='ORDER'
				and NVL(cit.src_change_owner,'N') = 'N'
				and nvl(cit.src_return_reqd, 'Y') = 'Y'
				AND NVL(cit.src_change_owner_to_code,'N') ='N'

				)

              )
        )
     )
);
Line: 100

SELECT tt_tl.LANGUAGE
FROM cs_transaction_types_tl tt_tl
WHERE tt_tl.transaction_type_id = p_transaction_type_id;
Line: 106

SELECT 1
FROM csm_ib_txn_types_acc
WHERE sub_type_id = p_sub_type_id;
Line: 115

  FETCH l_last_run_date_csr INTO l_prog_update_date;
Line: 124

  /****** DELETES  **********/
  --open the cursor
   open l_deletes_cur;
Line: 129

     FETCH l_deletes_cur INTO l_access_id;
Line: 130

     EXIT WHEN l_deletes_cur%NOTFOUND;
Line: 142

     DELETE FROM CSM_IB_TXN_TYPES_ACC
       WHERE ACCESS_ID = l_access_id;
Line: 147

   close l_deletes_cur;
Line: 149

  /******* UPDATES **********/
  --generate sql for updates
  l_dsql := 'SELECT acc.access_id
             FROM csm_ib_txn_types_acc acc ,
                  csi_ib_txn_types cit,
                  csi_source_ib_types cst ,
                  csi_txn_types ctt ,
                  csi_instance_statuses cis ,
                  cs_transaction_types_b ttb
             WHERE acc.sub_type_id = cit.sub_type_id
             AND cit.cs_transaction_type_id = ttb.transaction_type_id(+)
             AND ctt.source_application_id = 513
             AND ctt.source_transaction_type = ''FIELD_SERVICE_REPORT''
             AND cst.sub_type_id = cit.sub_type_id
             AND ctt.transaction_type_id = cst.transaction_type_id
             AND cit.src_status_id = cis.instance_status_id(+)
             AND (NVL(cst.update_IB_flag, ''N'') = ''N''
                  OR ( cst.update_ib_flag = ''Y''
                     and trunc(sysdate) between nvl(cis.start_date_active,trunc(sysdate)) and nvl(cis.end_date_active,trunc(sysdate))
                     and nvl(cis.terminated_flag, ''N'') <> ''Y''
                     and (
					 	   (cit.src_change_owner_to_code = ''I''
						    and nvl(cit.parent_reference_reqd, ''N'') = ''N''
							and ttb.line_order_category_code =''RETURN''
                  		    and cit.src_change_owner = ''Y''
                  		    and nvl(cit.src_return_reqd, ''N'') = ''N''

							)
                          or
						    (cit.src_change_owner_to_code = ''E''
							and ttb.line_order_category_code=''ORDER''
                  		    and cit.src_change_owner = ''Y''
                  		    and nvl(cit.src_return_reqd, ''N'') = ''N''

							)
                         or (
   						    ttb.line_order_category_code=''ORDER''
                 		    and NVL(cit.src_change_owner,''N'') = ''N''
				            and nvl(cit.src_return_reqd, ''Y'') = ''Y''
						    AND NVL(cit.src_change_owner_to_code,''N'') =''N''

					        )

                         )
                     )
                 )
              AND (cit.last_update_date > :1
                 or cst.last_update_date > :2
                 or ctt.last_update_date > :3
                 or cis.last_update_date > :4
                 or ttb.last_update_date > :5
               )';
Line: 203

   open l_updates_cur for l_dsql USING l_prog_update_date, l_prog_update_date, l_prog_update_date, l_prog_update_date, l_prog_update_date;
Line: 206

     FETCH l_updates_cur INTO l_access_id;
Line: 207

     EXIT WHEN l_updates_cur%NOTFOUND;
Line: 226

     UPDATE CSM_IB_TXN_TYPES_ACC
       SET LAST_UPDATE_DATE = l_run_date
       WHERE ACCESS_ID = l_access_id;
Line: 233

   close l_updates_cur;
Line: 235

  /****** INSERTS  **********/
  --generate sql for inserts
  l_dsql := 'SELECT cit.sub_type_id
            FROM csi_ib_txn_types cit , csi_source_ib_types cst , csi_txn_types ctt ,
                 csi_instance_statuses cis , cs_transaction_types_b ttb
           WHERE cit.cs_transaction_type_id = ttb.transaction_type_id(+)
           AND ctt.source_application_id = 513
           AND ctt.source_transaction_type = ''FIELD_SERVICE_REPORT''
           AND cst.sub_type_id = cit.sub_type_id
           AND ctt.transaction_type_id = cst.transaction_type_id
           AND cit.src_status_id = cis.instance_status_id(+)
           AND (NVL(cst.update_IB_flag, ''N'') = ''N''--Non IB
               OR ( cst.update_ib_flag = ''Y''
                  and trunc(sysdate) between nvl(cis.start_date_active,trunc(sysdate)) and nvl(cis.end_date_active,trunc(sysdate))
                  and nvl(cis.terminated_flag, ''N'') <> ''Y''
                  and (   (--Retirn IB
				          cit.src_change_owner_to_code = ''I''
				  	      and nvl(cit.parent_reference_reqd, ''N'') = ''N''
						  and ttb.line_order_category_code =''RETURN''
                  		  and cit.src_change_owner = ''Y''
                  		  and nvl(cit.src_return_reqd, ''N'') = ''N''

						  )
                       or (--Order IB
					      cit.src_change_owner_to_code = ''E''
					 	  and ttb.line_order_category_code=''ORDER''
                  		  and cit.src_change_owner = ''Y''
                  		  and nvl(cit.src_return_reqd, ''N'') = ''N''

					      )
                       or (--Loaner IB
   						   ttb.line_order_category_code=''ORDER''
                 		   and NVL(cit.src_change_owner,''N'') = ''N''
						   and nvl(cit.src_return_reqd, ''Y'') = ''Y''
						   AND NVL(cit.src_change_owner_to_code,''N'') =''N''

					      )
                      )
                  )
               )
            AND NOT EXISTS
            (SELECT 1
             FROM csm_ib_txn_types_acc acc
             WHERE acc.sub_type_id = cit.sub_type_id
             ) ';
Line: 282

   open l_inserts_cur for l_dsql;
Line: 285

     FETCH l_inserts_cur INTO l_sub_type_id;
Line: 286

     EXIT WHEN l_inserts_cur%NOTFOUND;
Line: 289

     select CSM_IB_TXN_TYPES_ACC_S.NEXTVAL into l_access_id from dual;
Line: 314

          INSERT INTO csm_ib_txn_types_acc(access_id, sub_type_id, CREATED_BY,
                       CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN)
          VALUES (l_access_id,l_sub_type_id, fnd_global.user_id, l_run_date,
                fnd_global.user_id, l_run_date, fnd_global.login_id);
Line: 324

   close l_inserts_cur;
Line: 327

   UPDATE jtm_con_request_data
   SET last_run_date = l_run_date
   WHERE package_name = 'CSM_IB_TXN_SUB_TYPES_EVENT_PKG'
     AND procedure_name = 'REFRESH_ACC';