dynamic sql [message #606955] |
Fri, 31 January 2014 04:16 |
|
guddu_12
Messages: 227 Registered: April 2012 Location: UK
|
Senior Member |
|
|
Dear All.
I have a dynamic sql which result into below sql statement
SELECT count(*) cnt, 'DS_CUPID_RP2' SCHEMAS, 'DS_ATTRIBUTIONHISTORY' TABLE_NAME
FROM ds_cupid_rp2.ds_attributionhistory
WHERE ds_load_delta_id = :IP_DELTA_LOAD_ID
My dynamic sql is below return 155 sql statement like above.
OPEN CUR_INS_REC FOR 'SELECT ''SELECT count(*) cnt,'' || '' '''''' ||OWNER ||''''''''|| '' SCHEMAS,'' || '' '''''' ||TABLE_NAME ||''''''''|| '' TABLE_NAME''|| CHR(10) || '' FROM ''|| LOWER(OWNER) || ''.'' || LOWER(TABLE_NAME) ||CHR(10) || '' WHERE ds_load_delta_id = :IP_DELTA_LOAD_ID'' STMNT
from all_tables
where owner like ''DS%''
AND owner <> ''DS_CUPID_RP1''
AND table_name LIKE ''DS_%''
AND table_name not in (''DS_ABSENCE_DELTA_TO_DATE_CTRL'',''DS_DUTY_DELTA_TO_DATE_CTRL'',''DS_PWS_DELTA_TO_DATE_CTRL'',''DS_PLANNED_WORK_SCHEDULE'',''DS_WEATHER'',''DS_INCIDENTS_SAFE'',''DS_INCIDENTS_C'',''DS_INCIDENTS_BACKUP'') UNION ALL
SELECT ''SELECT count(*) cnt,'' || '' '''''' ||OWNER ||''''''''|| '' SCHEMAS,'' || '' '''''' ||TABLE_NAME ||''''''''|| '' TABLE_NAME''|| CHR(10) || '' FROM ''|| LOWER(OWNER) || ''.'' || LOWER(TABLE_NAME) ||CHR(10) || '' WHERE dm_load_delta_id = :IP_DELTA_LOAD_ID'' STMNT
from all_tables
where owner like ''DM%''
AND (TABLE_NAME LIKE ''DIM%'' OR TABLE_NAME LIKE ''FCT%'')
AND TABLE_NAME NOT IN (''DIM_STATION_CLOSURE_AREA'',''DM_LOAD_DELTA_ID'',''DIM_BUSINESS_AREA'')
UNION ALL
select ''SELECT count(*) cnt,'' || '' '''''' ||OWNER ||''''''''|| '' SCHEMAS,'' || '' '''''' ||TABLE_NAME ||''''''''|| '' TABLE_NAME''|| CHR(10) || '' FROM ''|| LOWER(OWNER) || ''.'' || LOWER(TABLE_NAME) ||CHR(10) || '' WHERE dm_load_delta_id = :IP_DELTA_LOAD_ID'' STMNT
from all_tables
where owner like ''CON%''
AND TABLE_NAME LIKE ''DIM%''
AND TABLE_NAME NOT IN (''DIM_CAL'',''DIM_CALENDAR'',''DIM_TIME'',''DIM_TIME_BANDS'',''DIM_EMPLOYEE_SECURITYOLD'',''DIM_ORGANISATION_HELPER'',''DIM_ORGANISATION_HELPER_2'',''DIM_ORGANISATION_NOVEL'')';
I want to insert the record from this sql statement into a table. since the above sql statement takes input and also it has been generated
from dynaic sql , i want to know how can i insert the result of the above query into table for eact input.
Please help
|
|
|
|
|