[Home] [Help]
The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT to_number(SUBSTR(version_text, 1, instr(version_text, '|') -1) ),
to_number( SUBSTR(version_text, instr(version_text, '|') + 1) )
INTO db_version_major,
db_version_minor
FROM
(SELECT SUBSTR(REPLACE(REPLACE(version, '.', '|'), ',', '|'), 1, instr(REPLACE(REPLACE(version, '.', '|'), ',', '|'), '|', 1, 2) -1) version_text
FROM v$instance
);
select owner from sys.all_tables
where table_name = c_view_name;
UPDATE ams_query_template_all
SET recalc_table_status = 'IN_PROGRESS',
mv_available_flag = 'N',
request_id = l_request_id,
LAST_UPDATE_DATE = SYSDATE,
LAST_UPDATED_BY = FND_GLOBAL.USER_ID,
LAST_UPDATE_LOGIN = FND_GLOBAL.CONC_LOGIN_ID,
PROGRAM_APPLICATION_ID = FND_GLOBAL.PROG_APPL_ID,
PROGRAM_UPDATE_DATE = SYSDATE
WHERE template_id = p_template_id;
UPDATE ams_query_template_all
SET recalc_table_status = 'DRAFT',
mv_available_flag = 'N',
LAST_UPDATE_DATE = SYSDATE,
LAST_UPDATED_BY = FND_GLOBAL.USER_ID
WHERE template_id = p_template_id;
l_insert_string VARCHAR2(32767);
l_select_string VARCHAR2(32767);
SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null;
select count(*) from (SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) total_records;
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id;
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id
and alias2.source_object_name like 'HZ_%';
select count(*) from (
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id ) alias_count;
select types.master_source_type_flag,
decode(master_source_type_flag,'Y','A'||to_char(rownum)||'.'||source_object_pk_field||' = ',
'A'||to_char(rownum)||'.'||source_object_pk_field ||'(+)')
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id;
select count(*) from
(
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id
) tab3
where master_source_type_flag = 'N';
select column_name from sys.all_tab_columns where table_name = l_view_name
and column_name not in (
select flds.source_column_name
from ams_list_src_fields flds ,AMS_QUERY_ALIAS alias,ams_list_src_types types,
ams_query_template_all qtemp
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.LIST_SOURCE_TYPE_ID = flds.LIST_SOURCE_TYPE_ID
and types.MASTER_SOURCE_TYPE_FLAG = 'Y'
and qtemp.template_id = alias.template_id
and qtemp.list_src_type = types.source_type_code);
select 'Y' from sys.all_tables where table_name = l_view_name;
select 'Y' from sys.all_objects
where object_name = l_view_name
and object_type = 'SYNONYM';
select types.source_object_name
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and types.master_source_type_flag = 'Y'
and alias.object_name = types.source_type_code;
select tab1.query_alias_id,
decode(tab1.master_source_type_flag,'Y',
'( select * from ( select * from '|| tab1.source_object_name||
' order by dbms_random.value ) where rownum <=
(select (count(*) * '|| l_sample_pct ||'/100) from '|| tab1.source_object_name||') )' ,tab1.source_object_name),
tab1.master_source_type_flag,tab1.source_object_pk_field,
tab1.line_num
from
(
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id ) tab1;
select flds.source_column_name
from ams_list_src_fields flds ,AMS_QUERY_ALIAS alias,ams_list_src_types types,
ams_query_template_all qtemp
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.LIST_SOURCE_TYPE_ID = flds.LIST_SOURCE_TYPE_ID
and types.MASTER_SOURCE_TYPE_FLAG = 'Y'
and qtemp.template_id = alias.template_id
and qtemp.list_src_type = types.source_type_code;
select typ.SOURCE_OBJECT_PK_FIELD
from ams_query_template_all tmp,ams_list_src_types typ
where tmp.template_id = p_template_id
and tmp.list_src_type = typ.SOURCE_TYPE_CODE;
select tab2.source_object_name,tab2.list_source_type_id,tab2.master_source_type_flag,tab2.line_num||'.'
from
(
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.master_source_type_flag,alias2.source_object_pk_field,
alias2.line_num, alias2.list_source_type_id
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num,types.list_source_type_id
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id
) tab2;
select nvl(assoc.master_source_type_pk_column,types.SOURCE_OBJECT_PK_FIELD ),assoc.sub_source_type_pk_column from
ams_list_src_type_assocs assoc , ams_list_src_types types
where assoc.master_source_type_id = l_master_lstype_id
and assoc.sub_source_type_id = l_child_lstype_id
and assoc.master_source_type_id = types.list_source_type_id;
select source_object_pk_field from ams_list_src_types where list_source_type_id = p_template_id;
select 'Y' from sys.dba_policies where object_name like 'HZ%';
select 'Y' from sys.dba_policies where object_name = l_source_object_name;
select tablespace,INDEX_TABLESPACE from fnd_product_installations
where application_id = '530';
select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias, ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id;
select types.LIST_SOURCE_TYPE_ID, types.source_object_name, types.master_source_type_flag,'A'||to_char(rownum)||'.' line_num
from AMS_QUERY_ALIAS alias, ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
and types.list_source_type = 'TARGET'
order by alias.query_alias_id;
select sys_context( 'userenv', 'current_schema' ) "apps_schema" from dual;
select NVL(types.remote_flag, 'N'), database_link
from AMS_QUERY_ALIAS alias, ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code;
select application_short_name from fnd_application where application_id = 530;
update ams_query_template_all
set MV_AVAILABLE_FLAG = 'N'
where TEMPLATE_ID = p_template_id;
l_create_string := l_create_string || ' AS SELECT ';
l_insert_string := ' INSERT INTO '||l_view_name||' SELECT ';
l_create_string := l_create_string || ' COMPRESS AS SELECT ';
l_insert_string := ' INSERT /*+ APPEND */ INTO '||l_view_name||' SELECT ';
l_create_string := l_create_string || ' AS SELECT ';
l_insert_string := ' INSERT INTO '||l_view_name||' SELECT ';
l_create_string := l_create_string || ' COMPRESS AS SELECT ';
l_insert_string := ' INSERT /*+ APPEND */ INTO '||l_view_name||' SELECT ';
Ams_Utility_Pvt.Write_Conc_log('l_insert_string = '||l_insert_string);
l_master_string := 'begin select count(*) into :l_master_total_records from '||l_master_view||' ;end;';
l_master_string := 'begin select count(*) into :l_master_total_records from '||l_master_view||'@'||l_dblink||' ;end;';
l_select_string := l_select_string||' '||l_column_alias||'.'||l_attribute_name||' '
||l_column_alias||'_'||l_attribute_name||' '||l_comma;
Ams_Utility_Pvt.Write_Conc_log('l_select_string = '||l_select_string );
l_select_string := l_select_string||' '||l_master_columns_string;
Ams_Utility_Pvt.Write_Conc_log('l_select_string = '||l_select_string);
l_no_of_chunks := ceil(length(l_select_string)/2000 );
Ams_Utility_Pvt.Write_Conc_log('l_select_string = '||substrb(l_select_string,(2000*i) - 1999,2000));
l_create1_string := l_create_string ||' '||l_select_string||' '||l_from_string||' '||l_where_string||' '||l_policy_where||' ';
Ams_Utility_Pvt.Write_Conc_log('Maximum 100 LOV value selections are allowed. Please reselect the LOV values.');
Ams_Utility_Pvt.Write_Conc_log('Maximum 100 LOV value selections are allowed. Please reselect the LOV values.');
l_create_string := l_create_string ||' '||l_select_string||' '||l_from_string||' '||l_where_string||' '||l_policy_where||' ';
l_insert_string := l_insert_string ||' '||l_select_string||' '||l_from_string||' '||l_where_string||' '||l_policy_where||' ';
l_no_of_chunks := ceil(length(l_insert_string)/2000 );
Ams_Utility_Pvt.Write_Conc_log('Final l_insert_string chunks= '||l_no_of_chunks);
Ams_Utility_Pvt.Write_Conc_log(substrb(l_insert_string,(2000*i) - 1999,2000));
execute immediate l_insert_string;
Ams_Utility_Pvt.Write_Conc_log('Insert statement executed. ');
l_insert_string||
'; exception when others then Ams_Utility_Pvt.Write_Conc_log(SQLERRM); end; ' ;
update ams_query_template_all
set mv_name = l_view_name,
MV_AVAILABLE_FLAG = 'Y',
SAMPLE_PCT = l_sample_pct,
SAMPLE_PCT_RECORDS = l_sample_records,
MASTER_DS_REC_NUMBERS = l_master_total_records,
RECALC_TABLE_STATUS = 'AVAILABLE'
where TEMPLATE_ID = p_TEMPLATE_ID;
l_check_table_string := 'begin select 1 into :l_exist from sys.all_tables'||'@'||l_dblink||' where table_name = '''||l_view_name||''' ;end;';
Ams_Utility_Pvt.Write_Conc_log('remote l_insert_string = '||l_insert_string);
l_insert_string,
l_null,
OUT l_total_recs,
'EXECUTE_STRING';
update ams_query_template_all
set mv_name = l_view_name,
MV_AVAILABLE_FLAG = 'Y',
SAMPLE_PCT = l_sample_pct,
SAMPLE_PCT_RECORDS = l_sample_records,
MASTER_DS_REC_NUMBERS = l_master_total_records,
RECALC_TABLE_STATUS = 'AVAILABLE'
where TEMPLATE_ID = p_TEMPLATE_ID;
l_remote_index_string := 'begin select max(COLUMN_ID) into :l_number_of_index from sys.all_tab_columns'||'@'||l_dblink||' where table_name = '''||l_view_name||''' and column_name like ''A%'';end;';
l_remote_index_string := 'BEGIN select column_name into :l_index_column from sys.all_tab_columns'||'@'||l_dblink||' where table_name = '''||l_view_name||''' and column_name like ''A%'' and column_id = '||l_counter||'; END;';
update ams_query_template_all
set RECALC_TABLE_STATUS = 'FAILED'
where TEMPLATE_ID = p_TEMPLATE_ID;
l_delete_string varchar2(2000);
select template_id, mv_name from ams_query_template_all where mv_name is not null;
l_delete_string := ' DROP MATERIALIZED VIEW '||l_mv_name;
execute immediate l_delete_string;
update ams_query_template_all
set MV_AVAILABLE_FLAG = 'N'
where TEMPLATE_ID = L_TEMPLATE_ID;
select nvl(SAMPLE_PCT,0),MASTER_DS_REC_NUMBERS,SAMPLE_PCT_RECORDS from ams_query_template_all
where TEMPLATE_ID = P_TEMPLATE_ID;
select NVL(types.remote_flag, 'N'), database_link
from AMS_QUERY_ALIAS alias, ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code;
delete from ams_act_logs where ARC_ACT_LOG_USED_BY =
'RECL' and ACT_LOG_USED_BY_ID = p_template_id;
select distinct cond.query_condition_id cond_id
from AMS_QUERY_CONDITION cond, AMS_QUERY_COND_DISP_STRUCT_all struct,
AMS_COND_STRUCT_RESTRICT_VALUE res_values
where cond.template_id = p_template_id
and cond.value1_type = 'LOV'
and struct.QUERY_CONDITION_ID = cond.query_condition_id
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id(+)
and struct.token_type= 'OPERATOR'
and cond.mandatory_flag = 'Y'
UNION
select distinct cond.query_condition_id cond_id
from AMS_QUERY_CONDITION cond, AMS_QUERY_COND_DISP_STRUCT_all struct,
AMS_COND_STRUCT_RESTRICT_VALUE res_values
where cond.template_id = p_template_id
and cond.value1_type = 'LOV'
and struct.QUERY_CONDITION_ID = cond.query_condition_id
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id
and struct.token_type= 'OPERATOR'
and cond.mandatory_flag = 'Y'
and ( ( upper(res_values.code) in ('IS', 'IN', 'LIKE') and upper(res_values.code) not in ('IS NOT', 'NOT IN', 'NOT LIKE'))
or ( upper(res_values.code) in ('IS NOT', 'NOT IN', 'NOT LIKE') and upper(res_values.code) not in ('IS', 'IN', 'LIKE'))
)
and upper(res_values.code) not in ('>', '>=', 'BETWEEN', '<', '<=');
select struct.non_variant_value attr_name, source_object_name table_name,src_types.list_source_type_id
-- || alias.ALIAS_SEQ table_name
from AMS_QUERY_COND_DISP_STRUCT_all struct, AMS_QUERY_ALIAS alias, ams_list_src_types src_types
where struct.query_condition_id = p_cond_id
and struct.token_type = 'ATTRIBUTE'
and alias.query_alias_id = struct.query_alias_id
and alias.OBJECT_NAME = src_types.SOURCE_TYPE_CODE;
select upper(res_values.code) operator
from AMS_QUERY_COND_DISP_STRUCT_all struct, AMS_COND_STRUCT_RESTRICT_VALUE res_values
where struct.query_condition_id = p_cond_id and
struct.token_type = 'OPERATOR'
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id;
select upper(res_values.code) lov_value
from AMS_QUERY_COND_DISP_STRUCT_all struct, AMS_COND_STRUCT_RESTRICT_VALUE res_values
where struct.query_condition_id = p_cond_id and
struct.token_type = 'VALUE1'
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id;
select qu.QUERY --sql_string is obsolete bug 4604653
from ams_list_src_fields flds,ams_attb_lov_b lovb, ams_list_queries_all qu
where flds.LIST_SOURCE_TYPE_ID = l_list_source_type_id
and flds.SOURCE_COLUMN_NAME = l_source_field
and flds.attb_lov_id = lovb.attb_lov_id
and lovb.CREATION_TYPE = 'SQL'
and qu.ACT_LIST_QUERY_USED_BY_ID = lovb.attb_lov_id
and qu.ARC_ACT_LIST_QUERY_USED_BY = 'LOV' ;
select lovb.CREATION_TYPE
from ams_list_src_fields flds ,ams_attb_lov_b lovb
where flds.LIST_SOURCE_TYPE_ID = l_list_source_type_id
and flds.SOURCE_COLUMN_NAME = l_source_field
and flds.attb_lov_id = lovb.attb_lov_id;
select valb.value_code
from ams_list_src_fields flds ,ams_attb_lov_b lovb, ams_attb_lov_values_b valb
where flds.LIST_SOURCE_TYPE_ID = l_list_source_type_id
and flds.SOURCE_COLUMN_NAME = l_source_field
and flds.attb_lov_id = lovb.attb_lov_id
and lovb.CREATION_TYPE = 'USER'
and lovb.attb_lov_id = valb.attb_lov_id;
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id;
Ams_Utility_Pvt.Write_Conc_log('After c_lov_values --SELECT ALL is used for lov values ');
EXECUTE IMMEDIATE ' BEGIN select valb.value_code '||' BULK COLLECT INTO :1 '||
' from ams_list_src_fields flds ,ams_attb_lov_b lovb, ams_attb_lov_values_b valb'||
' where flds.LIST_SOURCE_TYPE_ID = :2'||
' and flds.SOURCE_COLUMN_NAME = :3 '||
' and flds.attb_lov_id = lovb.attb_lov_id and lovb.CREATION_TYPE = '||''''|| 'USER'||''''||
' and lovb.attb_lov_id = valb.attb_lov_id ; END; ' USING OUT l_code_tbl, IN l_left_operand_rec.list_source_type_id, l_left_operand_rec.attr_name;
select cond.query_condition_id cond_id, count(*)
from AMS_QUERY_CONDITION cond, AMS_QUERY_COND_DISP_STRUCT_all struct,
AMS_COND_STRUCT_RESTRICT_VALUE res_values
where cond.template_id = p_template_id
and cond.value1_type = 'CONSTANT'
and struct.QUERY_CONDITION_ID = cond.query_condition_id
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id
and struct.token_type= 'OPERATOR'
and cond.mandatory_flag = 'Y'
group by cond.query_condition_id
having count(*) = 1;
select struct.non_variant_value attr_name, source_object_name table_name, src_types.list_source_type_id
from AMS_QUERY_COND_DISP_STRUCT_all struct, AMS_QUERY_ALIAS alias, ams_list_src_types src_types
where struct.query_condition_id = p_cond_id
and struct.token_type = 'ATTRIBUTE'
and alias.query_alias_id = struct.query_alias_id
and alias.OBJECT_NAME = src_types.SOURCE_TYPE_CODE;
select upper(res_values.code) operator, count(*)
from AMS_QUERY_COND_DISP_STRUCT_all struct, AMS_COND_STRUCT_RESTRICT_VALUE res_values
where struct.query_condition_id = p_query_cond_id and
struct.token_type = 'OPERATOR'
and struct.QUERY_COND_DISP_STRUCT_ID = res_values.query_cond_disp_struct_id
group by upper(res_values.code)
having count(*) = 1; --has only one operator
select display_text
from AMS_QUERY_COND_DISP_STRUCT_vl struct
where struct.query_condition_id = p_query_cond_id and
struct.token_type in ('VALUE1');
select display_text
from AMS_QUERY_COND_DISP_STRUCT_vl struct
where struct.query_condition_id = p_query_cond_id and
struct.token_type in ('VALUE2');
select distinct alias2.query_alias_id,alias2.source_object_name, alias2.line_num
from
(SELECT distinct non_variant_value, query_alias_id
from AMS_QUERY_COND_DISP_STRUCT_vl
where query_template_id = p_template_id and token_type in ('ATTRIBUTE','VALUE1','VALUE2')
and query_alias_id is not null) alias1,
(select alias.query_alias_id, types.source_object_name, types.master_source_type_flag,types.source_object_pk_field,
'A'||to_char(rownum) line_num
from AMS_QUERY_ALIAS alias,ams_list_src_types types
where alias.template_id = p_template_id
and alias.object_name = types.source_type_code
order by alias.query_alias_id) alias2
where alias1.query_alias_id = alias2.query_alias_id;