Please help ..........pl/sql help
in my table there are some records. table have 2 column (id integer and word varchar2)
i want to concate words which having same id
eg
1, 'word1'
1, 'word2'
1, 'word3'
2, 'word4'
2, 'word5'
2, 'word6'
3, 'word7'
3, 'word8'
3, 'word9'
4, 'word10'
and i want o/p
1 word1, word2, word3
2 word4, word5, word6
3 word7, word8, word9
4 word10
any help will be appriciated
SQL> select * from test;
ID VALUE
1 word1
1 word2
1 word3
2 word1
2 word5
SQL> column c2 format a40
SQL> select id,ltrim(max(sys_connect_by_path(value,',')),',') c2
2 from(
3 select id,value,row_number() over (partition by id order by value) rn
4 from test
5 )
6 start with rn = 1
7 connect by prior rn = rn - 1
8 and prior id = id
9 group by id
10 /
ID C2
1 word1,word2,word3
2 word1,word5
Similar Messages
-
Please help me to tune this PL/SQL...
Hi everyone,
I have a SQL query which runs ok when i run it individually but the same query if
i use it in a procedure.The procedure is hanging up.Could someone please help to tune this
SQL query and please check my procedure why is it hanging up.
SQL Query
=========
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
Taking around 6 minute to run and it returns """"268267"""" records
Explain Plan for the above SQL:
===============================
"PLAN_TABLE_OUTPUT"
"Plan hash value: 379550299"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | SELECT STATEMENT | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 1 | HASH UNIQUE | | 1 | 16 | | 54461 (2)| 00:10:54 |"
"|* 2 | COUNT STOPKEY | | | | | | |"
"|* 3 | TABLE ACCESS FULL | MEMBER_SPAN | 12891 | 201K| | 54459 (2)| 00:10:54 |"
"| 4 | HASH UNIQUE | | 1 | 16 | 2424K| 54736 (2)| 00:10:57 |"
"|* 5 | COUNT STOPKEY | | | | | | |"
"|* 6 | TABLE ACCESS FULL | MEMBER_SPAN | 51541 | 805K| | 54459 (2)| 00:10:54 |"
"| 7 | HASH UNIQUE | | 1 | 50 | | 64 (4)| 00:00:01 |"
"|* 8 | COUNT STOPKEY | | | | | | |"
"|* 9 | TABLE ACCESS FULL | AV_MEM_EMAIL | 1 | 50 | | 63 (2)| 00:00:01 |"
"|* 10 | TABLE ACCESS FULL | DIVISION | 1 | 14 | | 3 (0)| 00:00:01 |"
"|* 11 | HASH JOIN | | 2609K| 659M| | 91679 (3)| 00:18:21 |"
"| 12 | VIEW | | 581 | 12782 | | 8184 (4)| 00:01:39 |"
"| 13 | HASH UNIQUE | | 581 | 26145 | | 8184 (4)| 00:01:39 |"
"| 14 | TABLE ACCESS BY INDEX ROWID| CONTRACT | 1 | 14 | | 2 (0)| 00:00:01 |"
"| 15 | NESTED LOOPS | | 581 | 26145 | | 8183 (4)| 00:01:39 |"
"|* 16 | TABLE ACCESS FULL | CONTRACT_SPAN | 581 | 18011 | | 7019 (5)| 00:01:25 |"
"|* 17 | INDEX RANGE SCAN | CONTRACT_IX1 | 1 | | | 1 (0)| 00:00:01 |"
"|* 18 | HASH JOIN | | 449K| 104M| 39M| 83466 (2)| 00:16:42 |"
"|* 19 | TABLE ACCESS FULL | MEMBER_SPAN | 449K| 34M| | 54964 (3)| 00:11:00 |"
"| 20 | TABLE ACCESS FULL | MEMBER | 1436K| 221M| | 14664 (2)| 00:02:56 |"
"Predicate Information (identified by operation id):"
" 2 - filter(ROWNUM=1)"
" 3 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SP')"
" 5 - filter(ROWNUM=1)"
" 6 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SE')"
" 8 - filter(ROWNUM=1)"
" 9 - filter("AV_MEM_EMAIL"."MEMBER_NBR"=:B1)"
" 10 - filter(TRIM("DIV"."DIVISION_NBR")=TRIM(:B1))"
" 11 - access(TRIM("MB_ACTIVE"."CONTRACT_NBR")=TRIM("ACTIVE_CONTRACTS"."CONTRACT_NBR"))"
" 16 - filter("CONTRACT_SPAN"."YMDEFF"<=20090707 AND TRIM("CONTRACT_SPAN"."VOID") IS NULL AND "
" "CONTRACT_SPAN"."YMDEND">=20090707)"
" 17 - access("CONTRACT"."CONTRACT_NBR"="CONTRACT_SPAN"."CONTRACT_NBR")"
" 18 - access("MB_ACTIVE"."MEMBER_NBR"="MS_ACTIVE"."MEMBER_NBR")"
" 19 - filter(TRIM("MS_ACTIVE"."VOID") IS NULL AND "MS_ACTIVE"."YMDEFF"<=20090707 AND "
" "MS_ACTIVE"."YMDEND">=20090707)"
SAME SQL IN A PROCEDURE..IT IS HANGING UP
========================================
create or replace PROCEDURE TEST_CURRENT_PCP_SPAN is
EXTRACTED_STRING VARCHAR2(32767);
FILEHANDLER UTL_FILE.FILE_TYPE;
test_str varchar2(100);
pcp_eff_date number(10);
file_name varchar2(50);
CURSOR MEMBERS
IS
SELECT active_members.member_nbr,
active_members.name_last,
active_members.name_first,
active_members.name_middle,
active_members.dob,
active_members.sex,
active_members.subsciber_nbr,
active_members.ssn,
active_members.name_suffix,
active_members.class_x,
active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SP'
AND rownum = 1)
WHEN TRIM(active_members.class_x) = 'SP' THEN
(SELECT DISTINCT(mssp.member_nbr)
FROM member_span mssp
WHERE SUBSTR(mssp.member_nbr, 1, 9) = SUBSTR(active_members.member_nbr, 1, 9)
AND mssp.class_x = 'SE'
AND rownum = 1)
ELSE
NULL
END)
spouse_member_nbr,
active_members.division_nbr,
active_members.ymdeff,
active_members.ymdend,
active_members.actual_ymd_enddt,
active_members.email_id,
active_members.network_id,
active_members.insurance_company_code,
active_members.cob_flag,
active_members.vip_flag,
active_members.pre_x_flag,
active_members.region,
active_contracts.language_x,
active_contracts.corp_nbr,
active_members.group_nbr,
active_members.non_erisa_status
FROM
(SELECT mb_active.member_nbr,
mb_active.contract_nbr,
mb_active.name_last,
mb_active.name_first,
mb_active.name_middle,
ms_active.ymdeff,
ms_active.ymdend,
to_char(to_date(
CASE
WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
ELSE NULL
END, 'YYYYMMDD'), 'MM/DD/YYYY') dob,
mb_active.sex,
to_char(to_date(ms_active.ymdeff, 'YYYYMMDD'), 'MM/DD/YYYY') ymdeff_formatted,
to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY') ymdend_formatted,
ms_active.void,
CASE
WHEN SUBSTR(mb_active.member_nbr, 10, 2) = '00' THEN mb_active.member_nbr
ELSE SUBSTR(mb_active.member_nbr, 1, 9) || '00'
END) subsciber_nbr,
mb_active.ssn,
mb_active.name_suffix,
ms_active.class_x,
ms_active.aff_nbr,
ms_active.division_nbr,
CASE
WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
ELSE to_char(to_date(ms_active.ymdend, 'YYYYMMDD'), 'MM/DD/YYYY')
END) actual_ymd_enddt,
CASE
WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
ELSE NULL
END) network_id,
ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
(SELECT DISTINCT(email)
FROM dbo.av_mem_email
WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
AND rownum = 1)
email_id,
mb_active.lr_response cob_flag,
mb_active.record_nbr vip_flag,
ms_active.pre_exist pre_x_flag,
ms_active.region region,
ms_active.group_nbr,
CASE
WHEN
(SELECT TRIM(div.div_status)
FROM division div
WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
'Y'
ELSE
'N'
END)
non_erisa_status
FROM member mb_active,
member_span ms_active
WHERE mb_active.member_nbr = ms_active.member_nbr
AND(20090707 BETWEEN ms_active.ymdeff
AND ms_active.ymdend
AND TRIM(ms_active.void) IS NULL
active_members,
(SELECT DISTINCT(contract.contract_nbr),
contract.language_x,
contract_span.corp_nbr
FROM contract,
contract_span
WHERE contract.contract_nbr = contract_span.contract_nbr
AND(20090707 BETWEEN contract_span.ymdeff
AND contract_span.ymdend)
AND TRIM(contract_span.void) IS
NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
TYPE MEM IS TABLE OF MEMBERS%ROWTYPE INDEX BY PLS_INTEGER;
TABLE_MEM MEM;
MEMBER_ADDR MGONZALEZ.CPKG_UTIL.ADDR;
BEGIN
test_str := '''A10000213'''||','||'''A10000213''';
insert into test_number_char(str) values ('start time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
file_name := 'member_load'||to_char(sysdate,'YYYYMMDDHH24MI')||'.txt';
FILEHANDLER := UTL_FILE.FOPEN('AVMED_UTL_FILE',file_name, 'W',10000);
insert into test_number_char(str) values ('start time of opening members cursor(before open members command) '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
OPEN MEMBERS;
LOOP
FETCH MEMBERS
BULK COLLECT INTO TABLE_MEM LIMIT 1000 ;
EXIT WHEN TABLE_MEM.COUNT = 0;
insert into test_number_char(str) values ('start time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
FOR i IN 1 .. TABLE_MEM.COUNT
LOOP
EXTRACTED_STRING := TRIM(TABLE_MEM(i).MEMBER_NBR)||'| '||
TRIM(TABLE_MEM(i).NAME_LAST)||'| '||
TRIM(TABLE_MEM(i).NAME_FIRST)||'| '||
TRIM(TABLE_MEM(i).NAME_MIDDLE)||'| '||
TRIM(TABLE_MEM(i).ssn)||'| '||
TABLE_MEM(i).subsciber_nbr||'| '||
TRIM(TABLE_MEM(i).class_x)||'| '||
TRIM(TABLE_MEM(i).DOB)||'| '||
TRIM(TABLE_MEM(i).SEX)||'| ' ;
EXTRACTED_STRING :=
EXTRACTED_STRING ||
TRIM(TABLE_MEM(i).aff_nbr)||'| '||
pcp_eff_date||'| '||
TABLE_MEM(i).actual_ymd_enddt||'| '||
TRIM(TABLE_MEM(i).division_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TABLE_MEM(i).network_id||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).name_suffix)||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).spouse_member_nbr)||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
' '||'| '||
TRIM(TABLE_MEM(i).email_id)||'| '||
TABLE_MEM(i).Insurance_company_code||'| '||
TABLE_MEM(i).group_nbr||'| '||
TABLE_MEM(i).language_x||'| '||
TABLE_MEM(i).region||'| '||
TABLE_MEM(i).corp_nbr||'| '||
TABLE_MEM(i).non_erisa_status||'| '||
TABLE_MEM(i).cob_flag||'| '||
TABLE_MEM(i).pre_x_flag||'| '||
TABLE_MEM(i).vip_flag
EXTRACTED_STRING := rtrim(EXTRACTED_STRING,' ');
UTL_FILE.PUT_LINE(FILEHANDLER,EXTRACTED_STRING,TRUE);
EXTRACTED_STRING := NULL;
pcp_eff_date := NULL;
END LOOP;
insert into test_number_char(str) values ('end time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
END LOOP;
close members;
insert into test_number_char(str) values ('end time of opening members cursor '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
commit;
UTL_FILE.FCLOSE(FILEHANDLER);
insert into test_number_char(str) values ('End time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line( 'ERROR getting members '
|| SQLCODE
|| ' '
|| SQLERRM);
END ;
In my Test table which i am inserting to check the times...
I am geting on these 2 records after that it hangs up...
start time of MEMBER_LOAD_CURRENT_PCP_SPAN 07/08/2009 11:41:21
start time of opening members cursor(before open members command) 07/08/2009 11:41:21I have to call some other functions for each member to get additional details thats the reason i am going for Procedure.Instead it is just a simple SQL
Thanks in advanceIt is taking lot of timeYou could perhaps split it up in smaller, isolated parts.
Running certain steps separate.
..is it possible to find out the issues without running the proc?Other than have other people on OTN give their ideas/share experiences?
Not that I'm aware of.
There are lots of statistical views, you might be able to deduct from their data, but I personally prefer running the procedure and just trace it. But I'm always willing to learn new approaches, btw.
Still, you have 2 things to look at, at least:
- avoid loops in loops if possible
- check your predicates, if you apply a function, you lose the index, unless you create a function based index.
edit
One more thing (how could I overlook that):
You commit your instrumentation code ( insert into test_number_char(str) ) IN the loop.
Please remove commit in your loops...
Commit only once, at the end of your transaction.
Never commit in a loop.
(Preferrably the client commits)
And remove every commit in your loop...
Edited by: hoek on Jul 8, 2009 8:03 PM -
My First while loop inside PL/SQL block not working , please help
Hi ,
I am new to PL/sql and struck at PL SQL blocks , please help to solve this .
declare
v_A number constant :=10 ;
j number constant := 3 ;
BEGIN
WHILE j < v_A
LOOP
DBMS_OUTPUT.PUT_LINE('Hai');
END LOOP;
END;
please help as how to resolve this .
Thanks in advance .btw it's a useful habit to use indentation to highlight the block structure. Also it's worth deciding what your convention will be for keywords (I use uppercase, lowercase is also fine as far as I'm concerned but I've set up my editor to uppercase them) and variables, database object names etc (I use lowercase), e.g:
DECLARE
v_a CONSTANT PLS_INTEGER := 10;
j CONSTANT PLS_INTEGER := 3;
i PLS_INTEGER := j;
BEGIN
WHILE i <= v_a LOOP
DBMS_OUTPUT.PUT_LINE(i);
i := i +1;
END LOOP;
END;or perhapsdeclare
v_a constant pls_integer := 10;
j constant pls_integer := 3;
i pls_integer := j;
begin
while i <= v_a loop
dbms_output.put_line(i);
i := i +1;
end loop;
end;When I see "declare" and "BEGIN" in the same block of code I worry about the standard of code I'm going to see... -
I want to submit a concurrent program from pl/sql. Please help me.
Dear all,
I want to submit a concurrent program from pl/sql. But I failed. Please help me.
Detail:
I create a concurrent program in 'Cash Management, Vision Operations (USA)' responsibility. <strong>And it be submitted success in EBS</strong>.
Then
I create a test script in pl/sql. And use 'FND_GLOBAL.APPS_INITIALIZE' to initialize ebs, then use 'FND_REQUEST.SUBMIT_REQUEST' to submit
the consurrent program, But the procedure aways return <strong>0</strong>.
I cannot found the reason. Please help me.Thanks.
<em>Attached informations may describe the problem:
1.The concurrenct submitted success in EBS.</em>
request_id = 4750655 (Sorry, I dont know how to add pictures.)
<em>2.The initialize informations which from SQL</em>.
SELECT FCR.REQUESTED_BY USER_ID
,FCR.RESPONSIBILITY_ID
,FCR.RESPONSIBILITY_APPLICATION_ID
,FA.APPLICATION_SHORT_NAME
,FCP.CONCURRENT_PROGRAM_NAME
FROM FND_CONCURRENT_REQUESTS FCR
,FND_APPLICATION FA
,FND_CONCURRENT_PROGRAMS FCP
WHERE FCR.PROGRAM_APPLICATION_ID = FA.APPLICATION_ID
AND FCR.CONCURRENT_PROGRAM_ID = FCP.CONCURRENT_PROGRAM_ID
AND FCR.REQUEST_ID = 4750655;
Result: user_id = 1318;
responsibility_id = 50579;
application_id = 260;
application_short_name = 'CE';
program_short_name = 'CALLK009';
<em>3.The test script code.</em>
<p>
-- Created on 2008/10/22 by ERIC
declare
-- Local variables here
Wv_conc_req_id VARCHAR2(10) DEFAULT NULL;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(
1318
,50579
,260
Wv_conc_req_id := FND_REQUEST.SUBMIT_REQUEST(
'CE'
,'CALLK009'
,NULL
,SYSDATE
,FALSE
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
, CHR(0), CHR(0), CHR(0), CHR(0), CHR(0)
DBMS_OUTPUT.PUT_LINE(Wv_conc_req_id);
COMMIT;
end;
<em>4.The concurrent program code.</em>
create or replace package body CALLTEST is
PROCEDURE T1(PvO_errbuf OUT VARCHAR2
,PvO_retcode OUT VARCHAR2)
IS
BEGIN
FND_FILE.PUT_LINE(fnd_file.log, 'TEST');
END;
end CALLTEST;
</p>Can you check from which schema you are executing FND_REQUEST? You can try as follows;
Connect to your required schema, create a synonym on apps.fnd_request, connect from apps and finally execute grant all on apps.fnd_request to all.
You can check for relevance from Doc ID: Note:147495.1
Please do keep in the mind the soultion above should be applied to a test/dev EBS instance first.
I hope this would be of help.
Saad -
Please help with an sql to show more than one records into single row for each student
From the following data I would like to create an sql to get the information as the following layout
studentid, firstTerm, EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
Example
1 First, 30,40,20,Sec,30,40,20, simillarly next row for next row for another sudent. Please help to generate the sql for the same.
Please help it would be very appreciate.
With Thanks
Pol
polachancreate table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
insert into yourdata values
(1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
(2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
(3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
(1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
(2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
(3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
Select studentid
,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
,max(case when term='First' and section='Math' Then Mark End) as MathMark1
,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
From yourdata
Group by studentid
drop table yourdata -
Java and MS SQL Server 2000 problem, please help
please help me. I am using java and MS SQL Server 2000, and I'm trying to access and verify the login. I'm getting the following error message: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
Can any please help in this regard.
String userNumber = (String)userNumField.getValue();
char[] userPasswordArray = userPasswordField.getPassword();
String userPassword = new String(userPasswordArray);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:odbc:Dikolobe_Data");
java.sql.PreparedStatement statement = connection.prepareStatement(
"SELECT USER_NUMBER, USER_PASSWORD, USER_CLASS, USER_STATUS " +
"FROM SYS_USER " +
"WHERE (USER_NUMBER = ? AND USER_PASSWORD = ?);");
statement.setString(1, userNumber);
statement.setString(2, userPassword);
java.sql.ResultSet result = statement.executeQuery();
if(result.next()) {
String userStatus = result.getString(4);
if(userStatus.equals("logged on")) {
String loginErrorMessage = "User with number: " + userNumber + " is already logged on.";
javax.swing.JOptionPane loginErrorPane = getNarrowOptionPane(72);
loginErrorPane.setMessage(loginErrorMessage);
loginErrorPane.setMessageType(javax.swing.JOptionPane.ERROR_MESSAGE);
javax.swing.JDialog loginErrorDialog = loginErrorPane.createDialog(null, "Login Error");
loginErrorDialog.setVisible(true);
else {
String userClassification = result.getString(3);
if(userClassification.equals("Administrator")) {
AdminHomePage newAdminHomePage = new AdminHomePage();
newAdminHomePage.setVisible(true);
else if(userClassification.equals("Educator")) {
EduHomePage newEduHomePage = new EduHomePage();
newEduHomePage.setVisible(true);
statement = connection.prepareStatement(
"UPDATE SYS_USER SET USER_STATUS = ? " +
"WHERE USER_NUMBER = ?");
statement.setString(1, "logged on");
statement.setString(2, userNumber);
statement.executeUpdate();
dispose();
}Doesn't the following link give you enough information?
http://www.google.com/search?q=invalid+descriptor+index
Anyway .. This error means that the given ResultSet column index which you're trying to retrieve the value from is out of the range. -
SQL Server Express 2008 Installation error. PLEASE HELP.
Hey guys anyone know what I should do to install SQL Server Express 2008?
Im running Vista Home Premium SP1 32bit
These are folders i got on framework folder:
* v3.5
* v3.0
* v2.0.50727
* v1.1.4322
* v1.0.3705
Installing SQL Server 2008 Express (run time only)
And this is the error I get during the process
"Attributes do not match. Present Attributes (Directory, Compressed), included attributes (0), excluded attributes (Archive, Compressed, Encrypted)."
I have downloaded and installed all Visual Studio 2008 SP1 Express Ed (C++, C#, VB, WebDev) and all worked well
I get this error during the "Feature Selection" setup process.
I also noticed when I tried to use Windows Update, I saw Microsoft SQL Server 2008 Service Pack 1 (KB968369) suddenly available (I have updated windows and installed all important updates before installing Microsoft Visual Studio and SQL). Then I used Windows Update to install SQL Server 2008 SP1 and I still got this error:
Error
Code 84B40000 Unknown error....
I also get this downloading error on SQL Server while installing all 4 Visual Studio Express Editions (C#, C++, VB, WebDev).
"The following cannot be downloaded:"
I've already tried the troubleshooting guide about BITS but the tool fix seems to only supports Windows XP Operating Systems.
Please please please Help Me (^_^).. thanks to all.
P.S.
I think this might have some connections to why I get errors on a simple 'Hello World' Website.
I was just trying to simply make a 'Hello World' Website .. Just THAT on my website.
A simple Website for me to start. Just showing those text on the website. But when I tried to run (debug) the program. This error shows...
'Firefox can't establish a connection to the server at localhost:5903.'
I have Build the Web Site and there was no error. Since it was just simply 'Hello World' text.
Im sure there's some problem but I'm completely stuck here. I dunno if its connected to the problem above.
Please help me solve this problem. Thank you so much.
I appreciate everyone's help.In my case I had to uncheck "Allow files in this folder to have contents indexed in addition to file properties"
Right click on C:\Program Files\Microsoft SQL Server
Click Advanced on General Tab
Uncheck "Allow files in this folder to have contents indexed in addition to file properties" -
Please help - Scrollable result set in sql server 2000
Hi can some one please help me. I'm trying to create scrollable result set in sql server 2000, but i just can't get it to work. I've been trying to do this for the past 12 hours. I want to go home, but I can't till I get this going! please help!!! My crap code is as follows:
package transact;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JInternalFrame;
import java.sql.*;
import java.io.*;
import java.util.*;
public class DummyFrame extends Dummy
protected String name, surname;
protected Connection conn;
protected CallableStatement cstatement;
public DummyFrame()
createFrame();
private void createFrame()
try
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://server:1433;" +
"user=user;password=pwd;DatabaseName=Northwind");
catch (Exception e)
e.getMessage();
populateFields();
menuAction();
show();
private void menuAction()
btncontacts.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
getRecords();
populateFields();
btncontacts.setText("NEXT");
btnkeywords.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
// transaction.getRecords();
nextRecord();
populateFields();
btncontacts.setText("NEXT");
protected void nextRecord()
try
// CallableStatement cstatement = null;
cstatement = conn.prepareCall(
"{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = cstatement.executeQuery();
while (rs.next())
surname = rs.getString("Lastname");
cstatement.getMoreResults();
catch (Exception e)
e.getMessage();
protected void getRecords()
try
CallableStatement cstatement = null;
cstatement = conn.prepareCall(
"{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = cstatement.executeQuery();
while (rs.next())
surname = rs.getString("Lastname");
name = rs.getString("Firstname");
rs.first();
// call stored procedure
catch (Exception e)
e.getMessage();
// populate the fields;
private void populateFields()
txtfirstname.setText(name);
txtsurname.setText(surname);
}ummm ok i think the logic in your code is kinda screwy...
here is what your should be doing.
create the gui.
get the resultset...
have code that looks like this for nextRecord...
protected void displayNextRecord(){
// we do not call next here because we already called it last time
surname = rs.getString("Lastname");
name = rs.getString("Firstname");
populateFields();
if(!rs.next(){
btncontacts.setEnabled(false);// i'm not sure what btncontacts is but we want to disable next becuase there are no more records...
// in your intitalization code you need to do this...
// you old stuff ending with...
ResultSet rs = cstatement.executeQuery();
// the new stuff...
if(rs.first()){
displayNextRecord();
}else{
btncontacts.setEnabled(false);//the result set is empty
}ok the real problem you are having is that you are trying to display one record at a time but you are scrolling
through the entire result set using while(rs.next()... what you
want to do is create the result set once and scroll through
it one item at a time with your gui.
the example method i have given displays the data from the current
row in your gui. then it advances the result set forward one row if possible. this method assumes that the result set will always
be positioned on a valid row thus the need for calling
rs.first() before we originally call displayNextRecord()
well i hope you find this helpful. -
Please help me regarding the running of a sql file
Hi I downloaded one sql file from
http://www.cs.uwf.edu/~sbagui/db/practical_oracle.htm
But i am unable to run it successfully...please help me regarding this... thanking you
Edited by: SowmyRaj on Dec 24, 2009 5:24 AMHi vali thanks for your reply...
I am using Windows XP sp2 Os.
and Oracle database 11g ...
when executing this file the follwing error is occuring
Enter value for user_name: system
old 2: uname VARCHAR(50) := '&user_name';
new 2: uname VARCHAR(50) := 'system';
**MOBILE CODE** immediate 'drop user ' ||uname;
ERROR at line 13:
ORA-06550: line 13, column 1:
PLS-00103: Encountered the symbol "*" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge -
Please help me formulate this in PL/SQL - Thanks.
Hi ALL,
Please help me formulate this in PL/SQL. I really appreciate your help in advance. Below is the Specification.
Read Previous records
Check if this is a New Customer.
If New
Than check for New site
If New Site than Insert Site
End If
Insert Practice
Insert Customer
Check for Previous Months Balance for that Customer.
If there than (formula)
Else
set balance = 0
End if
Insert balance.
Thanks Much in adavance.Hi ALL,
Please help me formulate this in PL/SQL. I really appreciate your help in advance. Below is the Specification.
Read Previous records
Check if this is a New Customer.
If New
Than check for New site
If New Site than Insert Site
End If
Insert Practice
Insert Customer
Check for Previous Months Balance for that Customer.
If there than (formula)
Else
set balance = 0
End if
Insert balance.
Thanks Much in adavance. -
I have used a tool to convert my sql 2000 stored procedure to Oracle 10g PL/SQL, here is an example
SQL 2000 Stored Procedure
CREATE PROCEDURE [GetEmployees]
AS
Select * from EMPMST ORDER BY emp_name
GO
After Transformation i got 2 files, one was a procedure and other a package
CREATE OR REPLACE PACKAGE GLOBALPKG
AS
TYPE RCT1 IS REF CURSOR;
TRANCOUNT INTEGER := 0;
IDENTITY INTEGER;
END;
CREATE OR REPLACE PROCEDURE GetEmployees
RCT1 IN OUT GLOBALPKG.RCT1
AS
BEGIN
OPEN RCT1 FOR
SELECT *
FROM EMPMST
ORDER BY emp_name;
END;
When i execute the procedure GetEmployees i got this error :
SQL> execute GetEmployees;
BEGIN GetEmployees; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'GETEMPLOYEES'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please Help me in debugging this error. Thanks in advance.As the poster above mentioned you cannot call "GetEmployees" without a parameter.
Note that the procedure declaration has the following line
RCT1 IN OUT GLOBALPKG.RCT1
This means that whenever you want to call the procedure you must pass it a variable of type GLOBALPKG.RCT1
However unless this is merely a homework or learning exercise (i.e. you are not porting the code of a production application) i would strongly recommend that you do not attempt to simply convert the code to PL/SQL.
The reasoning behind this is that Oracle's architecture will be completely different to the source of the original code and if you attempt to simply port the code (especially using an automatic tool) you will almost certainly hit problems.
For example the SQL Server's 2000 code may (should be) be written based on SQL Server's locking strategy. Oracle's locking strategy is completly different if you try to use the same techniques as you do in SQL Server the performance will suffer.
Porting a code or a database schema from one platform to another involves a lot of analysis in order to take advantage of the features of the destination platform.
As I said this may not be important to you depending on why you are attempting a port.
Good Luck. -
hai friends!
I installed D2K recently. Iam unable to login to sql (directly or from D2K forms) using the usual username/password..scott/tiger,system/manager,demo/demo. I get the following error message :
TNS error: Unable to connect to destination
Please help me out!
thanX,
rajiwhat is your error number.
Did you try to look up this number in the oracle error book?
Usually you can also find the solution there.
My bet is that your tnsnames.ora file is not set properly. -
SQL question - please help!
Hi,
I am working on a SQL, please help ms with the question
below .... thanks
(1)Increase by 10% salary of these captain pilots who have
traveled more than 800,000 miles.
Routes | | Flights | |Pilots |
| | | | |
#routeID | | #flightNO | |#pilotID |
depAirportID | | airplaneNO| |*name |
arrAirportID |_______/| pilotID |\___________|*hours_in_air|
length | \| routeID |/ |*grade |
______________| |_____________| |*salary |
|____________|If the length column in routes is in hours, and it represents
additional hours to those shown in hours_in_air in pilots, then
the following should work:
UPDATE pilots
SET salary = salary * 1.1
WHERE pilotid in (SELECT a.pilotid
FROM pilots a,
(SELECT b.pilotid,sum(c.length) new_hours
FROM flights b, routes c
WHERE b.routeid = c.routeid
GROUP BY b.pilotid) d
WHERE a.pilotid = d.pilotid and
new_hours + hours_in_air >= 80000)I suspect that you probably need to add additional criteria to
the sub-query from flights and routes to take into account only
flights since the hours_in_air column from pilots was last
updated. However, your table structures do not indicate any
date sensitivity. If the table flights is emptied every time
hours_in_air is updated, then the query above will work. -
Please Help - SQL Report long column value required in a separate cell
Hi.
I need to create a SQL report with the structure like below:
Country State City Vertical Business Details (detail desc)
US MA Quincy Healthcare
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
US MA Braintree IT
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
This is a detail desc value that needs to displayed in a different cell.
I came through a solution where you can hide/display the long column value in a different cell. But my requirement is that it should be displayed when the page opens and user don;t want to click on a button to see the value. This is mainly for their presentations and printing. so its very annoying for them to click on so many buttons to see the detail desc value for every record. I am new to Java script, Please helpI'm not sure I understand your requirements--are you showing us 2 lines of data, 7 lines, or 9? Do you want the long detail description on the same row, or underneath it?
I'm going to go on the assumption that you're showing us two rows, and that the long descriptions in this example happen to be 3-4 lines long, and that you want the long descriptions underneath the details. In which case, I suggest using "named column" templates. They're a lot easier to use than they appear when you first look at them, so bear with me.
Under "Shared Components", select "Templates", and then click on the yellow Create> button. You're creating a report template, from scratch. On the final page of the wizard, select "Named Column (row template)" for the template type. This will create a rather generic (and useless) template, which you'll have to edit; I don't know why they chose to not send you straight into the editor. When you edit it, you'll see that the only field with a value in it is "Row Template 1", and it's set to:
<tr><td>#1#</td><td>#2#</td><td>#3#</td><td>#4#</td><td>#5#</td></tr>For meeting your requirements with basic functionality, change it to something along the lines of:
<tr><td>#COUNTRY#</td><td>#STATE#</td><td>#CITY#</td><td>#VERT#</td></tr>
<tr><td colspan="4">#DETAILS#</td></tr>Then you'll probably want to put something under Column Heading Template, like:
<tr><td>Country</td><td>State</td><td>City</td><td>Vertical Business</td></tr>
<tr><td colspan="4">Details</td></tr>Apply whatever CSS styles you want to it, of course.
Using the template is straightforward: if your report, chose the template, and make sure your SQL returns values using the column names you specified in your template. Otherwise, you'll see literal "#COUNTRY#" text in your report.
You can get fancy with these, of course, such as applying different styles to alternating rows, but I'll leave this as good enough to get you started (I hope).
-David -
My sql query running for more than 4 hours could some one please help me
Hi ,
I have one sql executable and the query is running for more than 4 hours . Could some one please help me in tuning the sql.
The stats and all the general stuff is intact at db level :
SELECT pasl.item_id item_id
, pv.vendor_name vendor_name
, msif.segment1 item
, NVL(cic.item_cost,0) item_cost
, NVL(pasl.attribute1,0) asl_cost
FROM apps.mtl_system_items_b msif
, apps.po_approved_supplier_list pasl
, apps.cst_item_cost_type_v cic
, apps.po_vendors pv
, apps.po_asl_statuses past
, apps.mtl_item_categories mic
, apps.mtl_categories_b mc
, apps.mtl_category_sets_b mcb
, apps.mtl_category_sets_b mcbm
, apps.mtl_categories_b mcm
, apps.mtl_item_categories micm
WHERE pasl.item_id = msif.inventory_item_id
AND msif.inventory_item_id = cic.inventory_item_id
AND msif.inventory_item_status_code in ('Active','ENG HOLD')
AND cic.cost_type = 'Frozen'
AND msif.organization_id = cic.organization_id
AND EXISTS (SELECT 1
FROM apps.mtl_system_items_b msin,
apps.mtl_parameters mpn,
apps.org_organization_definitions oodn
WHERE msin.organization_id = mpn.organization_id
AND mpn.organization_id = oodn.organization_id
AND msin.inventory_item_id = msif.inventory_item_id
AND oodn.operating_unit = :p_ou
AND cic.organization_id = 87
AND NVL(pv.end_date_active,TRUNC(SYSDATE+1)) > TRUNC(SYSDATE)
AND pv.vendor_id = pasl.vendor_id
AND mcbm.structure_id = mcm.structure_id
AND nvl(mcm.start_date_active, (SYSDATE - 1)) < SYSDATE
AND nvl(mcm.end_date_active, (SYSDATE + 1)) > SYSDATE
AND mcbm.category_set_id = 1
AND micm.inventory_item_id = msif.inventory_item_id
AND micm.organization_id = msif.organization_id
AND micm.category_set_id = mcbm.category_set_id
AND micm.category_id = mcm.category_id
AND (SUBSTR(mcm.segment1,1,2) = 'FG' OR msif.item_type LIKE 'FG%')
AND mcm.segment3 NOT IN ('4','5','9','A')
AND mcb.structure_id = mc.structure_id
AND NVL(mc.start_date_active, (SYSDATE - 1)) < SYSDATE
AND nvl(mc.end_date_active, (SYSDATE + 1)) > SYSDATE
AND mcb.category_set_id = 1100000022
AND mic.inventory_item_id = msif.inventory_item_id
AND mic.organization_id = msif.organization_id
AND mic.category_set_id = mcb.category_set_id
AND mic.category_id = mc.category_id
AND SUBSTR(mc.segment2,1,2) = pv.attribute6
AND ROUND(NVL(pasl.attribute1,0),2) <> ROUND(NVL(cic.item_cost,0),2)
AND pasl.asl_status_id = past.status_id
AND UPPER(past.status) = 'APPROVED'
--and pv.attribute6 not in('IN','BG','CT')
and msif.inventory_item_id = :p_item_id42737
UNION
SELECT pasl.item_id item_id
, pv.vendor_name vendor_name
, msif.segment1 item
, NVL(cic.item_cost,0) item_cost
, NVL(pasl.attribute1,0) asl_cost
FROM apps.mtl_system_items_fvl msif
, apps.po_approved_supplier_list pasl
, apps.cst_item_cost_type_v cic
, apps.po_vendors pv
, apps.po_asl_statuses past
, apps.mtl_item_categories mic
, apps.mtl_categories_b mc
, apps.mtl_category_sets_b mcb
, apps.mtl_category_sets_b mcbm
, apps.mtl_categories_b mcm
, apps.mtl_item_categories micm
WHERE pasl.item_id = msif.inventory_item_id
AND msif.inventory_item_id = cic.inventory_item_id
AND msif.inventory_item_status_code in ('Active','ENG HOLD')
AND cic.cost_type = 'Frozen'
AND msif.organization_id = cic.organization_id
AND EXISTS (SELECT 1
FROM apps.mtl_system_items_b msin,
apps.mtl_parameters mpn,
apps.org_organization_definitions oodn
WHERE msin.organization_id = mpn.organization_id
AND mpn.organization_id = oodn.organization_id
AND msin.inventory_item_id = msif.inventory_item_id
AND oodn.operating_unit = :p_ou
AND cic.organization_id = 87
AND NVL(pv.end_date_active,TRUNC(SYSDATE+1)) > TRUNC(SYSDATE)
AND pv.vendor_id = pasl.vendor_id
AND mcbm.structure_id = mcm.structure_id
AND NVL(mcm.start_date_active,(SYSDATE - 1)) < SYSDATE
AND NVL(mcm.end_date_active, (SYSDATE + 1)) > SYSDATE
AND mcbm.category_set_id = 1
AND micm.inventory_item_id = msif.inventory_item_id
AND micm.organization_id = msif.organization_id
AND micm.category_set_id = mcbm.category_set_id
AND micm.category_id = mcm.category_id
AND (SUBSTR(mcm.segment1,1,2) = 'FG' OR msif.item_type LIKE 'FG%')
AND mcm.segment3 NOT IN ('4','5','9','A')
AND mcb.structure_id = mc.structure_id
AND NVL(mc.start_date_active,(SYSDATE - 1)) < SYSDATE
AND nvl(mc.end_date_active,(SYSDATE + 1)) > SYSDATE
AND mcb.category_set_id = 1100000022
AND mic.inventory_item_id = msif.inventory_item_id
AND mic.organization_id = msif.organization_id
AND mic.category_set_id = mcb.category_set_id
AND mic.category_id = mc.category_id
AND SUBSTR(mc.segment2,1,2) = pv.attribute6
AND pasl.asl_status_id = past.status_id
AND UPPER(past.status) = 'APPROVED'
--and pv.attribute6 not in('IN','BG','CT')
AND NVL(pasl.attribute1,0) = 0
AND NVL(cic.item_cost,0) != 0
and msif.inventory_item_id = :p_item_id42737
The execution plan displayed in taod is as below :
Plan
SELECT STATEMENT ALL_ROWSCost: 464 Bytes: 905 Cardinality: 2
140 SORT UNIQUE Cost: 464 Bytes: 905 Cardinality: 2
139 UNION-ALL
69 NESTED LOOPS Cost: 185 Bytes: 446 Cardinality: 1
67 NESTED LOOPS OUTER Cost: 180 Bytes: 444 Cardinality: 1
65 NESTED LOOPS Cost: 178 Bytes: 408 Cardinality: 1
63 NESTED LOOPS Cost: 177 Bytes: 404 Cardinality: 1
60 NESTED LOOPS Cost: 176 Bytes: 378 Cardinality: 1
57 NESTED LOOPS Cost: 174 Bytes: 353 Cardinality: 1
55 NESTED LOOPS Cost: 174 Bytes: 349 Cardinality: 1
53 NESTED LOOPS Cost: 174 Bytes: 342 Cardinality: 1
50 NESTED LOOPS Cost: 173 Bytes: 336 Cardinality: 1
48 NESTED LOOPS Cost: 173 Bytes: 332 Cardinality: 1
46 FILTER
45 NESTED LOOPS OUTER Cost: 171 Bytes: 322 Cardinality: 1
43 NESTED LOOPS Cost: 169 Bytes: 305 Cardinality: 1
41 NESTED LOOPS Cost: 168 Bytes: 292 Cardinality: 1
38 NESTED LOOPS Cost: 166 Bytes: 277 Cardinality: 1
36 NESTED LOOPS Cost: 166 Bytes: 273 Cardinality: 1
33 NESTED LOOPS Cost: 165 Bytes: 256 Cardinality: 1
30 NESTED LOOPS Cost: 162 Bytes: 237 Cardinality: 1
27 NESTED LOOPS Cost: 161 Bytes: 203 Cardinality: 1
24 NESTED LOOPS Cost: 159 Bytes: 185 Cardinality: 1
22 NESTED LOOPS Cost: 158 Bytes: 163 Cardinality: 1
19 NESTED LOOPS Cost: 156 Bytes: 117 Cardinality: 1
16 NESTED LOOPS Cost: 90 Bytes: 95 Cardinality: 1
13 NESTED LOOPS Cost: 49 Bytes: 72 Cardinality: 1
10 NESTED LOOPS Cost: 8 Bytes: 41 Cardinality: 1
8 NESTED LOOPS Cost: 3 Bytes: 30 Cardinality: 1
5 NESTED LOOPS Cost: 2 Bytes: 22 Cardinality: 1
2 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1
1 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
4 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1
3 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
7 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_DEFAULT_CATEGORY_SETS Cost: 1 Bytes: 8 Cardinality: 1
6 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_DEFAULT_CATEGORY_SETS_U1 Cost: 0 Cardinality: 1
9 TABLE ACCESS FULL TABLE PO.PO_ASL_STATUSES Cost: 5 Bytes: 11 Cardinality: 1
12 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 93 Cardinality: 3
11 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426
15 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 92 Cardinality: 4
14 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426
18 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_ITEM_CATEGORIES Cost: 65 Bytes: 22 Cardinality: 1
17 INDEX RANGE SCAN INDEX INV.MTL_ITEM_CATEGORIES_N3 Cost: 2 Cardinality: 293
21 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 46 Cardinality: 1
20 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1
23 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1
26 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_APPROVED_SUPPLIER_LIST Cost: 2 Bytes: 18 Cardinality: 1
25 INDEX RANGE SCAN INDEX PO.PO_APPROVED_SUPPLIER_LIST_N1 Cost: 1 Cardinality: 1
29 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_VENDORS Cost: 1 Bytes: 34 Cardinality: 1
28 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_VENDORS_U1 Cost: 0 Cardinality: 1
32 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_ITEM_COSTS Cost: 3 Bytes: 19 Cardinality: 1
31 INDEX RANGE SCAN INDEX (UNIQUE) BOM.CST_ITEM_COSTS_U1 Cost: 2 Cardinality: 1
35 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_COST_TYPES Cost: 1 Bytes: 17 Cardinality: 1
34 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Cardinality: 1
37 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Bytes: 4 Cardinality: 1
40 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 15 Cardinality: 1
39 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1
42 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1
44 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 17 Cardinality: 1
47 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 2 Bytes: 30 Cardinality: 3
49 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1
52 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 6 Cardinality: 1
51 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1
54 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 7 Cardinality: 1
56 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1
59 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 25 Cardinality: 1
58 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1
62 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 1 Bytes: 26 Cardinality: 1
61 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1
64 INDEX FULL SCAN INDEX (UNIQUE) GL.GL_SETS_OF_BOOKS_U2 Cost: 1 Bytes: 4 Cardinality: 1
66 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1
68 TABLE ACCESS FULL TABLE APPLSYS.FND_PRODUCT_GROUPS Cost: 5 Bytes: 2 Cardinality: 1
138 NESTED LOOPS Cost: 278 Bytes: 459 Cardinality: 1
136 NESTED LOOPS Cost: 277 Bytes: 449 Cardinality: 1
134 NESTED LOOPS Cost: 277 Bytes: 445 Cardinality: 1
132 NESTED LOOPS Cost: 277 Bytes: 441 Cardinality: 1
129 NESTED LOOPS Cost: 275 Bytes: 415 Cardinality: 1
127 NESTED LOOPS Cost: 275 Bytes: 408 Cardinality: 1
124 NESTED LOOPS Cost: 274 Bytes: 402 Cardinality: 1
122 NESTED LOOPS Cost: 273 Bytes: 398 Cardinality: 1
120 MERGE JOIN CARTESIAN Cost: 268 Bytes: 373 Cardinality: 1
117 FILTER
116 NESTED LOOPS OUTER Cost: 263 Bytes: 371 Cardinality: 1
114 NESTED LOOPS Cost: 261 Bytes: 354 Cardinality: 1
112 NESTED LOOPS OUTER Cost: 260 Bytes: 341 Cardinality: 1
110 NESTED LOOPS Cost: 258 Bytes: 305 Cardinality: 1
107 NESTED LOOPS Cost: 256 Bytes: 290 Cardinality: 1
105 NESTED LOOPS Cost: 256 Bytes: 286 Cardinality: 1
102 NESTED LOOPS Cost: 255 Bytes: 269 Cardinality: 1
99 NESTED LOOPS Cost: 252 Bytes: 250 Cardinality: 1
97 NESTED LOOPS Cost: 251 Bytes: 237 Cardinality: 1
95 NESTED LOOPS Cost: 250 Bytes: 215 Cardinality: 1
93 NESTED LOOPS Cost: 249 Bytes: 193 Cardinality: 1
90 NESTED LOOPS Cost: 245 Bytes: 294 Cardinality: 2
87 HASH JOIN Cost: 230 Bytes: 387 Cardinality: 3
85 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 92 Cardinality: 4
84 NESTED LOOPS Cost: 90 Bytes: 95 Cardinality: 1
82 NESTED LOOPS Cost: 49 Bytes: 72 Cardinality: 1
79 NESTED LOOPS Cost: 8 Bytes: 41 Cardinality: 1
77 NESTED LOOPS Cost: 3 Bytes: 30 Cardinality: 1
74 NESTED LOOPS Cost: 2 Bytes: 22 Cardinality: 1
71 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1
70 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
73 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1
72 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
76 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_DEFAULT_CATEGORY_SETS Cost: 1 Bytes: 8 Cardinality: 1
75 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_DEFAULT_CATEGORY_SETS_U1 Cost: 0 Cardinality: 1
78 TABLE ACCESS FULL TABLE PO.PO_ASL_STATUSES Cost: 5 Bytes: 11 Cardinality: 1
81 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 93 Cardinality: 3
80 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426
83 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426
86 TABLE ACCESS FULL TABLE PO.PO_VENDORS Cost: 139 Bytes: 15,980 Cardinality: 470
89 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_APPROVED_SUPPLIER_LIST Cost: 13 Bytes: 18 Cardinality: 1
88 INDEX RANGE SCAN INDEX PO.PO_APPROVED_SUPPLIER_LIST_N3 Cost: 1 Cardinality: 64
92 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 46 Cardinality: 1
91 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1
94 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1
96 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1
98 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1
101 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_ITEM_COSTS Cost: 3 Bytes: 19 Cardinality: 1
100 INDEX RANGE SCAN INDEX (UNIQUE) BOM.CST_ITEM_COSTS_U1 Cost: 2 Cardinality: 1
104 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_COST_TYPES Cost: 1 Bytes: 17 Cardinality: 1
103 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Cardinality: 1
106 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Bytes: 4 Cardinality: 1
109 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 15 Cardinality: 1
108 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1
111 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1
113 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1
115 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 17 Cardinality: 1
119 BUFFER SORT Cost: 266 Bytes: 2 Cardinality: 1
118 TABLE ACCESS FULL TABLE APPLSYS.FND_PRODUCT_GROUPS Cost: 5 Bytes: 2 Cardinality: 1
121 TABLE ACCESS FULL TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 5 Bytes: 25 Cardinality: 1
123 INDEX FULL SCAN INDEX (UNIQUE) GL.GL_SETS_OF_BOOKS_U2 Cost: 1 Bytes: 4 Cardinality: 1
126 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 6 Cardinality: 1
125 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1
128 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 7 Cardinality: 1
131 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 26 Cardinality: 1
130 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1
133 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1
135 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1
137 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Bytes: 10 Cardinality: 1
Regards,
Siva.Welcome to the forums !
Pl post details of OS, database and EBS versions.
Pl see these threads on how to post a tuning request -
HOW TO: Post a SQL statement tuning request - template posting
When your query takes too long ...
HTH
Srini -
How to show PL/SQL package output and fix below error(please help)
--PACKAGE SPECIFICATION AND BODY complied successfully but I can not see output some error are also there.. please help ;how to fix this problem
-- with code
CREATE OR REPLACE PACKAGE package_variables IS
-- Declare package components.
PROCEDURE set(value VARCHAR2);
FUNCTION get RETURN VARCHAR2;
END package_variables;
CREATE OR REPLACE PACKAGE BODY package_variables IS
-- Declare package scope variable.
variable VARCHAR2(20) := 'Initial Value';
-- Define function
FUNCTION get RETURN VARCHAR2 IS
BEGIN
RETURN variable;
END get;
-- Define procedure.
PROCEDURE set(value VARCHAR2) IS
BEGIN
variable := value;
END set;
END package_variables;
VARIABLE outcome VARCHAR2(20)
CALL package_variables.get() INTO :outcome;
SELECT :outcome AS outcome FROM dual;
EXECUTE package_variables.set('New Value');
CALL package_variables.get() INTO :outcome;
SELECT :outcome AS outcome FROM dual;
OUTPUT
PACKAGE package_variables Compiled.
PACKAGE BODY package_variables Compiled.
Error starting at line 2 in command:
CALL package_variables.get() INTO :outcome
Error report:
SQL Error: ORA-01008: not all variables bound
01008. 00000 - "not all variables bound"
*Cause:
*Action:
OUTCOME
1 rows selected
anonymous block completed
Error starting at line 2 in command:
CALL package_variables.get() INTO :outcome
Error report:
SQL Error: ORA-01008: not all variables bound
01008. 00000 - "not all variables bound"
*Cause:
*Action:
OUTCOME
1 rows selected
*/EXECUTE package_variables.set('New Value');
CALL package_variables.get INTO :outcome;
SELECT :outcome AS outcome FROM dual;
OUTPUT
anonymous block completed
Error starting at line 2 in command:
CALL package_variables.get INTO :outcome
Error report:
SQL Error: ORA-06576: not a valid function or procedure name
06576. 00000 - "not a valid function or procedure name"
*Cause: Could not find a function (if an INTO clause was present) or
a procedure (if the statement did not have an INTO clause) to
call.
*Action: Change the statement to invoke a function or procedure
OUTCOME
1 rows selected
Maybe you are looking for
-
Issue in background processing- Very Urgent
A custom program which is scheduled to run every day as a background job, Failed yesterday with the below system log: R3JD: SQL UPDATE FAILED. Error in ZMOMPO05. Contact R3JD Support. R3JD Additional Info: A2000_UPDATE_PROCESS UPDATE ZMPOR FAILED.
-
I'd like to configure my mini to alert me in a unique way when an email comes in from a certain FROM address. i know how to set up the rule, but I'd like help creating an audible alert which is not there now by default from apple. i'd like to have th
-
Multiple waveform chart automatic plot
Hello I need to plot multiple signals in the same waveform chart. The problem is that the number of signals is not constant. I have a control that enables me to change the number of signals to plot each time I run my VI. Is there any way to do it? Th
-
Under Tools the Clear Recent History line is in shaded type and can't be accessed
In the dropdown menu under Tools the Clear Recent History option is in lighter type and cannot be accessed. Please advise. == This happened == Every time Firefox opened == I just tried to clear history
-
TS3274 my ipad screen will not respond
my ipad is unresonsive. I have tried to syn and my compuer will not recognize it