A row of Sub query returns more than 1 row!
I'm trying to update the values in one table from another table and get the error: void line query returns More Than 1 row.I want to PRV_NAME B chart updated in the table A PRV_NAME where A.PRVID = B.PRVID where B.PRV_TYPE = M"
The two paintings were all unique PRVID, however, table B has PRVID that have the same name. So the data in table B can look like this:
PRVID PRV_NAME
1234 PHOENIX MED
1235 MED BAG
1236 MED BAG
1237 OVERLAND
etc...
So, as you can see are the unique PRVID, but not the PRV_NAME. Is this the reason why I get this error?
I do not build the tables and have no control over what is put in them. If this is the reason for the error, is there a way to fix this?
For reference, here's the request. Maybe there's something wrong with that?
Update msb_prv_source ps
Set ps.prv_name =
(select prv00.prv00_prv_name
of prv00_prv prv00
Join msb_prv_source ps
On prv00.prv00_prv_id = ps.prvid
where prv00.prv00_prv_type = am')
Published by: user12296489 on April 19, 2013 10:46
/* Formatted on 4/19/2013 2:00:43 PM (QP5 v5.185.11230.41888) */
MERGE INTO msb_prv_source a
USING (SELECT *
FROM prv00_prv
WHERE prv00_prv_type = 'M') b
ON (a.prv00_prv_id = b.prvi)
WHEN MATCHED
THEN
UPDATE SET a.prv_name = prv00_prv_name
Tags: Database
Similar Questions
-
Einreihig subquery returns more than one query
Hello
I get the following error: einreihig subquery returns more than one request. I don't know how I should debug this application. As far as I know, subqueries can return only 1 row...: S
I've only Oracle SQL Developer to run/test of my queries. I can run the query with ROWNUM < 5000, which gives no error. If I run with ROWNUM > 5000 and ROWNUM < 6000 then the error pops up...
This is the query:
Published by: layout of the code user574699 on November 17, 2008 02:10with DATES as (select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL), MONTHS as (select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1), CALCULATIONS as (select PNM.PNM_AUTO_KEY PNM_KEY, MONTHS.DT DT, NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING, NVL((select sum(saj.qty_adj) from stock_adjust saj inner join stock stm on saj.stm_auto_key = stm.stm_auto_key inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING from MONTHS, PARTS_MASTER PNM) SELECT ROWNUM, CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE FROM CALCULATIONS;
the problem is that you use the same alias in your view online as well as in your main query in the second statement-nvl...
HTH
-
exact fetch returns more than requested number: retrieve first row
I have this statement:
I got this error:FOR l IN C1 LOOP select amount,customer_id INTO F_AMT,I_custid from zerorize where doc_id = l.doc_id and trans_type = C_py; END LOOP;
I want to change my sql statement in such a way, it gets the first line. How am I suppose to add my where clause condition?ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 172
If you don't have a way to restrict your query to return only 1 row according to the data, you can use the line number...
for exampleselect data, data2, ..... from ( select data, data2, ....., rownum rn from table ) where rn = 1
-
Hi all
We try to add new proposal for a salary of some employees from form August 1, 2015 (the Date of the beginning of employee)
There is no existing salary proposal doesn't exist for these employees.
We get below error.
ORA-01422: exact fetch returns more than the requested number of rows in the hr_maintain_proposal_swi procedure insert_salary_proposal package
Help, please.
Thank you
Tarun
Hi John,.
If it helps, take a look at the following note:
ORA-01422 exact Fetch returns more than number of lines requested in Hr_maintain_proposal_swi (Doc ID 1673527.1)
Kind regards
Rajen
-
Single - row subquery returns more than one line.
Hi Experts
I am faced with error
ORA-01427: single - row subquery returns more than one line.
MyQuery is:
select TO_CHAR(T.MR_REG_DATE,'DD') "DATE" ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END age ,count(T.Mr_Code) No_of_Patient ,( SELECT count(x.mr_code) mr_code FROM HMIS_MRINFO X where X.mr_reg_date between &FRM_DATE AND &TO_DATE and X.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y WHERE Y.mr_reg_date between &FRM_DATE AND &TO_DATE ) GROUP BY CASE WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ) Missing_MR from hmis_mrinfo T,hmis_pat_add_dis_detail M where T.mr_code = M.mr_code(+) and T.mr_reg_date between &FRM_DATE AND &TO_DATE &AGE_GRP GROUP BY T.MR_REG_DATE ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ORDER BY T.MR_REG_DATE;
Please give some advice / solution.
I think this might do it for you
Select
TO_CHAR (T.MR_REG_DATE, 'DD') "DATE."
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
Age of the END
count (T.Mr_Code) No_of_Patient
, count (case when t.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y))
WHERE Y.mr_reg_date between & FRM_DATE AND & TO_DATE)
then t.mr_code
(end) Missing_MR
of hmis_mrinfo T, hmis_pat_add_dis_detail M
where T.mr_code = M.mr_code (+)
and between T.mr_reg_date & FRM_DATE AND & TO_DATE
& AGE_GRP
T.MR_REG_DATE GROUP
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
END
ORDER BY T.MR_REG_DATE;
-
How to know what sub query returns multiple rows
Hi all
Someone can give me hints, how to know what sub query returns many rows in the following query.
Kind regards/* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */ SELECT a.*, ROWNUM AS rnm FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org", prxm.mbr_idntfr AS "Beneficiary ID", md.last_name || ', ' || md.first_name AS "Beneficiary Name", pci.idntfr AS "Tracking No.", TO_CHAR (TRUNC (req.pa_rqst_date), 'MM/dd/yyyy' ) AS "Request Date", sts.status_name AS "Status", req.pa_rqst_sid AS "Request #", prxm.mbr_sid AS "Mbr_sid", TO_CHAR (TRUNC (req.pa_revision_date), 'MM/dd/yyyy' ) AS "Last Updated", TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE", prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID", pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View", DECODE ((SELECT DISTINCT pd.national_prvdr_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), 0, (SELECT prxplo.prvdr_lctn_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), NULL, (SELECT prxplo.prvdr_lctn_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), (SELECT DISTINCT pd.national_prvdr_idntfr FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR') ) AS "NPI/ID", DECODE ((SELECT pd.org_bsns_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), NULL, (SELECT pd.last_name || ', ' || pd.first_name || ' ' || pd.middle_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR'), (SELECT pd.org_bsns_name FROM pa_request_x_provider_location prxplo WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid AND prxplo.oprtnl_flag = 'A' AND prxplo.pa_prvdr_type_lkpcd = 'RR') ) AS "Prvdr Name", TO_CHAR (psd.from_date, 'MM/dd/yyyy' ) AS "Srvc From Date", TO_CHAR (req.validity_start_date, 'MM/DD/YYYY' ) AS "Due Date", (fn_get_busniess_days (TRUNC (req.validity_start_date)) ) AS "Days<br>Left", req.pa_mode_type_lkpcd AS "Source", TO_CHAR (TRUNC (wmdtl.rtng_date), 'MM/dd/yyyy' ) AS "Assigned On", NVL (wmdtl.assigned_to_user_name, 'Not Assigned' ) AS "Assigned To", req.org_unit_sid AS "OrgUnitSid", TO_CHAR (wmdtl.modified_date, 'MM/dd/yyyy hh24:mi:ss' ) AS "WTRD_MODIFIED_DATE", TO_CHAR (wmdtl.rtng_date, 'MM/dd/yyyy' ) AS "WTRD_RTNG_DATE", req.status_cid AS "PA_STATUS_CID", TO_CHAR (req.modified_date, 'MM/dd/yyyy' ) AS "PA_REQ_MODIFIED_DATE", prs.state_pa_srvc_type_code AS "STATE_PA_SRVC_TYPE_CODE", wmdtl.wm_pa_task_rtng_dtl_sid AS "WM_TASK_RTNG_DTL_SID", wmdtl.assigned_to_user_acct_sid AS "WTRD_Assigned_to_user_acct_sid", (fn_get_busniess_days (TRUNC (req.validity_start_date)) ) AS "Days<br>LeftSort", wmdtl.assigned_to_org_unit_sid AS "WTRD_Assigned_to_OrgUntSid", DECODE ((SELECT COUNT (*) FROM pa_request_status prs WHERE prs.pa_rqst_sid = req.pa_rqst_sid AND prs.status_cid = 5 AND prs.oprtnl_flag = 'I'), 0, 'N', 'Y' ) AS "SHOW_UTILIZATION" FROM pa_request req, pa_certification_identifier pci, status sts, pa_request_x_member prxm, wm_pa_task_routing_detail wmdtl, pa_service_date psd, org_unit ou, pa_request_service prs, pa_request_x_provider_location prxpl, provider_location pl, provider_detail pd, provider p, mbr_dmgrphc md WHERE req.oprtnl_flag = 'A' AND req.status_cid NOT IN (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101) AND req.org_unit_sid IN (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145, 3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149, 3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153, 3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157, 3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161, 3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165, 3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169, 3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173, 3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177, 3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181, 3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185, 3101, 3186, 3102, 3187, 3103, 3003, 75000104, 75000108, 2006, 75000103, 75000102, 75000113, 75000111, 75000109, 2001, 2009, 75000105, 75000107, 2004, 2010, 2013, 2014, 2005, 2011, 75000112, 2002, 1001, 2012, 75000106, 2007, 75000101, 2003, 75000110, 2008, 3001, 3002, 3019, 3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023, 3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027, 3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031, 3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035, 3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039, 3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043, 3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047, 3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051, 3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055, 3140, 3056, 3141) AND req.pa_rqst_sid = prs.pa_rqst_sid AND prs.oprtnl_flag = 'A' AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid AND psd.oprtnl_flag = 'A' AND req.pa_rqst_sid = pci.pa_rqst_sid AND pci.oprtnl_flag = 'A' AND req.pa_rqst_sid = prxm.pa_rqst_sid AND prxm.oprtnl_flag = 'A' AND md.oprtnl_flag = 'A' AND md.status_cid = 2 AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE AND prxm.mbr_sid = md.mbr_sid AND ou.org_unit_sid = req.org_unit_sid AND ou.oprtnl_flag = 'A' AND req.pa_rqst_sid = prxpl.pa_rqst_sid AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid AND pci.pa_rqst_sid = prxm.pa_rqst_sid AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid AND pci.pa_rqst_sid = prxpl.pa_rqst_sid AND prxpl.pa_prvdr_type_lkpcd = 'RR' AND prxpl.oprtnl_flag = 'A' AND req.status_cid = sts.status_cid AND sts.status_type_cid = 3 AND sts.oprtnl_flag = 'A' AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid AND p.prvdr_sid = pd.prvdr_sid AND p.prvdr_sid = pl.prvdr_sid AND pd.oprtnl_flag = 'A' AND pd.status_cid = 2 AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE AND wmdtl.subsystem_task_sid = req.pa_rqst_sid AND wmdtl.subsystem_lkpcd = 'PA' AND wmdtl.oprtnl_flag = 'A' AND req.pa_rqst_date > (SYSDATE - 365) ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC, "Beneficiary Name" ASC) a WHERE ROWNUM < 102;
Prakash P
Published by: BluShadow on May 17, 2011 15:01
addition of {noformat}{noformat} tags around the code
3360 wrote:
See point 9 of this section of the FAQ on how to format the code.I see that you did.
No, I did. It's pretty easy to change if the code seems formatted anyway below. It's when I go to edit the message and find no sense because it is not formatted in all cases, I despair. {noformat} :) {noformat}
-
ORA-01422: exact fetch returns more than number of rows - FIX?
Dear experts of PL/SQL,
I encounter this problem when running under procedure, how this can be exceeded? Procedure was running well for the last few weeks and we have this problem all of a sudden:
ORA-01422: exact fetch returns more than number of lines
CREATE OR REPLACE PROCEDURE DBA_MAINT. () SQL_EXEC_DRILLDOWN
beginsnapid in numbers
endsnapid in numbers
)
AS
begin_date varchar2 (30);
End_date varchar2 (30);
statName VARCHAR2 (64);
err_msg VARCHAR2 (100);
The CNT number;
cursor c1
is
Select stat_name,
Sum in the NTC
de)
Select instance_number,
stat_name,
((VALUE) max - min (VALUE)) COUNTY
of dba_hist_sysstat
where stat_name in ("run the County", 'parse count (total)', "parse count (hard)")
and snap_id between beginsnapid
and endsnapid
Instance_number group, stat_name)
Stat_name group
Union of all the
Select stat_name,
Sum in the NTC
de)
Select instance_number,
stat_name,
Round (((value) - (VALUE) min Max) / 1000000) COUNTY
of DBA_HIST_SYS_TIME_MODEL
where stat_name in ("DB CPU", "background time cpu", 'sql execute elapsed time', 'analysis elapsed time', ' parse hard time elapsed ")
and snap_id between beginsnapid
and endsnapid
Instance_number group, stat_name)
Stat_name Union group all the
Select stat_name,
MySQL as cnt
de)
Select a.stat_name stat_name,
(b.value - a.value) VALUE
dba_hist_sysstat a, dba_hist_sysstat b
where a.dbid = b.dbid
and a.instance_number = b.instance_number
and a.stat_id = b.stat_id
and a.snap_id = beginsnapid
and b.snap_id = endsnapid
and a.stat_name in ('physical reads',
"physical Scriptures."
"physical read IO total number of applications."
"physical write IO requests total."
"Physics read total multi block requests."
"total multi block request writing for the physical box,.
("reading session logic")
and a.instance_number = b.instance_number)
Stat_name group;
Start
Start
Select distinct TO_CHAR (END_INTERVAL_TIME, "MM/DD/YYYY HH24 '")
in begin_date
of dba_hist_snapshot
where snap_id = beginsnapid;
Select distinct TO_CHAR (END_INTERVAL_TIME, "MM/DD/YYYY HH24 '")
in end_date
of dba_hist_snapshot
where snap_id = endsnapid;
-DBMS_OUTPUT. Put_line (begin_date);
-DBMS_OUTPUT. Put_line (end_date);
exception
When no_data_found
then
null;
end;
C1_rec IN C1
LOOP
Start
Insert
in DBA_MAINT. Values (DB_SQL_EXEC_DETAILS)
beginsnapid,
endsnapid,
begin_date,
End_date,
c1_rec.stat_name,
c1_rec. CNT
);
-DBMS_OUTPUT. Put_line (c1_rec.stat_name |) » '|| c1_rec. CNT);
exception
When no_data_found
then
null;
end;
end loop;
commit;
end;
/
Reasons to explain above, but I think it would be more appropriate select latest END_INTERVAL_TIME as follows
Select TO_CHAR ((max (END_INTERVAL_TIME)), "MM/DD/YYYY HH24")
in begin_date
of dba_hist_snapshot
where snap_id = beginsnapid;
Select TO_CHAR ((max (END_INTERVAL_TIME)), "MM/DD/YYYY HH24")
in end_date
of dba_hist_snapshot
where snap_id = endsnapid;
-
Error - ORA-01422: exact fetch returns more than number of lines
Hello
I get the error when running script below. Please help me.
/****************** ERROR ******************/
Error report:
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at line 71
01422 00000 - "exact fetch returns more than number of lines."
* Cause: Exact extraction specified number is less than the returned rows.
* Action: Rewrite the query or change the number of rows requested
/****************** SCRIPT ******************/
DECLARE
l_xml XMLTYPE: = XMLTYPE ("< LoggingInformation >
< commandeEmplacement >
< name > ServiceCall1 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
< status > completed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< ServiceLoggingEntries >
< item >
< foo > 1 < / foo >
< / ServiceInformation >
< item >
< foo > 2 < / foo >
< / ServiceInformation >
< / ServiceLoggingEntries >
< InformationLoggingEntries >
< ProcessInformation >
< bar > 1 < / >
< / ProcessInformation >
< ProcessInformation >
< bar > 2 < / >
< / ProcessInformation >
< / InformationLoggingEntries >
< / commandeEmplacement >
< commandeEmplacement >
< name > ServiceCall2 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
< status > completed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< ServiceLoggingEntries >
< item >
< foo > 3 < / foo >
< / ServiceInformation >
< item >
< foo > 4 < / foo >
< / ServiceInformation >
< / ServiceLoggingEntries >
< InformationLoggingEntries >
< ProcessInformation >
< bar > 3 < / >
< / ProcessInformation >
< ProcessInformation >
< bar > < / > 4
< / ProcessInformation >
< / InformationLoggingEntries >
< / commandeEmplacement >
< commandeEmplacement >
< name > ServiceCall3 < / name >
< StartTime > 2010-01-18T 11: 11:41.570664 - 00:00 < / StartTime >
< EndTime > 2010-01-18T 11: 11:43.8987741 - 00:00 < / EndTime >
< ElapsedTime > 00:00:02.3281101 < / ElapsedTime >
status of <>failed < / status >
< ExceptionMessage > error here... < / ExceptionMessage >
< ExceptionStackTrace > Stack Trace here... < / ExceptionStackTrace >
< / commandeEmplacement >
(< / LoggingInformation > ');
v_txt VARCHAR2 (2000);
BEGIN
SELECT XMLTYPE. Extract (value (TT),'/ CommandInformation/Name/Text () '). GETSTRINGVAL()
IN v_txt
TABLE (XMLSEQUENCE (l_xml. Extract('/LoggingInformation/CommandInformation'))) tt;
DBMS_OUTPUT. Put_line (v_txt);
END;Select...
means only 1 row can be returned.
Your select returns more than one line.
Change v_txt in a collection, define a cursor and the extraction of it or change the statement, i.e. it returns a single line.---------
Sybrand Bakker
Senior Oracle DBA -
"Getting the error 'exact fetch returns more than number of lines.
Hi try to run a query of Iam
but when I run what it it gives an error
Error report:
here's my querey
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at line 9 level
01422 00000 - "exact fetch returns more than number of lines."
* Cause: Exact extraction specified number is less than the returned rows.
* Action: Rewrite the query or change the number of rows requested
SET SERVEROUTPUT ON
DECLARE
Emp_table_type TYPE IS an ARRAY OF
hr_api_transactions % ROWTYPE INDEX BY PLS_INTEGER;
my_emp_table emp_table_type;
BEGIN
I'm in 1.53
LOOP
SELECT * INTO my_emp_table (i) FROM hr_api_transactions
WHERE transaction_ref_table = 'PER_ALL_VACANCIES ';
END LOOP;
BECAUSE me IN my_emp_table. FIRST... my_emp_table. LAST
LOOP
DBMS_OUTPUT. Put_line (my_emp_table (i) .transaction_document);
END LOOP;
END;Hello
'Re missing you the bulk of the Collections. Ask that you well want to have a glance on manual of oracle collections.
Replace your code...DECLARE TYPE emp_table_type IS TABLE OF hr_api_transactions%ROWTYPE INDEX BY PLS_INTEGER; my_emp_table emp_table_type; BEGIN SELECT * BULK COLLCT INTO my_emp_table FROM hr_api_transactions WHERE transaction_ref_table = 'PER_ALL_VACANCIES'; FOR i IN my_emp_table.FIRST..my_emp_table.LAST LOOP DBMS_OUTPUT.PUT_LINE(my_emp_table(i).transaction_document); END LOOP; END;
Before you run the above script, don't forget to run the
set serveroutput on
I hope this helps.
PS-> mark as Complete/useful, if the apporoach above meets the expected result
Kind regards
Claudy -
ERRO ORA-01422: exact fetch returns more than number of lines
SET SERVEROUTPUT ON
create or replace procedure copy
AS
cursor c2 IS
Select t.country_code
transactions t;
v_lc_details_current_hist c2% rowtype;
v_country_code transactions.country_code% TYPE;
Start
Open c2;
loop
extract the c2 in v_lc_details_current_hist;
OUTPUT WHEN c2% NOTFOUND;
Select the country_code in v_country_code of transactions;
DBMS_OUTPUT. Put_line (v_country_code);
end loop;
Close c2;
end;
/
I'm gettintha error ORA-01422: exact fetch returns more than number of lines
Please help me[email protected] wrote:
Select the country_code in v_country_code of transactions;
-It's to return several rows, and the SELECT INTO statement expects that one line.A SELECT INTO statement can be used if you want a query to return only one row. Otherwise use bulk collect and a variable of class to contain the result lines multiples.
-
exact fetch returns more than number of lines
Hello
I have here is the procedure to kill session from blocking. It works fine if a row is returned to select it.
How can I change to operate multiple lines?CREATE OR REPLACE PROCEDURE kill_blocking IS
l_sid NUMBER (10);
l_serial NUMBER (10);
l_wait NUMBER (10);
l_username VARCHAR2 (20);
sqlstmt VARCHAR2 (1000);
BEGIN
SELECT s1. SID, s1.serial #, s2.seconds_in_wait, s2.username
IN l_sid, l_serial, l_wait, l_username
V $ lock l1.
v$ session s1,.
v$ lock l2,.
v$ session s2,.
v$ sql sqlt1.
v$ sql sqlt2
WHERE s1. SID = l1. SID
AND s2. SID = l2. SID
AND sqlt1.sql_id = s2.sql_id
AND sqlt2.sql_id = s1.prev_sql_id
AND l1. BLOCK = 1
AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2;
IF l_username = "APP" AND l_wait > 100
THEN
sqlstmt: =.
"ALTER SYSTEM KILL SESSION"'.
|| To_char (l_sid)
|| ','
|| To_char (l_serial)
|| '''';
Dbms_output.put_line (sqlstmt);
EXECUTE IMMEDIATE sqlstmt;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
Dbms_output.put_line ('no data found');
END;
/
SQL > exec kill_blocking;
BEGIN kill_blocking; END;*
ERROR on line 1:
ORA-01422: exact fetch returns more than number of lines
ORA-06512: at TK. "KILL_BLOCKING", line 8
ORA-06512: at line 1Hello
You can use the procedure below
create or replace
PROCEDURE kill_blocking_mig
IS
l_sid NUMBER (10);
l_serial NUMBER (10);
l_wait NUMBER (10);
l_username VARCHAR2 (20);
sqlstmt VARCHAR2 (1000);
CURSOR status_cus IS
SELECT s1. SID, S1. Serial #, s2.seconds_in_wait, s2.username
V $ lock l1.
v$ session s1,.
v$ lock l2,.
v$ session s2,.
v$ sql sqlt1.
v$ sql sqlt2
WHERE s1. SID = l1. SID
AND s2. SID = l2. SID
AND sqlt1.sql_id = s2.sql_id
AND sqlt2.sql_id = s1.prev_sql_id
AND l1. BLOCK = 1
AND l2.request > 0
AND l1.id1 = l2.id1
AND l2.id2 = l2.id2;
BEGIN
OPEN status_cus.
loop
extract the status_cus IN l_sid, l_serial, l_wait, l_username;
When the output status_cus % notfound;
IF l_username = "APP" AND l_wait > 100 THEN
sqlstmt: = ' EDIT the SYSTEM KILL SESSION "' | To_char (l_sid) | ',' || To_char (l_serial) | '''';
Dbms_output.put_line (sqlstmt);
EXECUTE IMMEDIATE sqlstmt;
END IF;
end loop;
EXCEPTION
WHEN NO_DATA_FOUND THEN
Dbms_output.put_line ('no data found');
END;
-
Error ORA-01422 apex: exact fetch returns more than the required number of line
Hi people,
Apex 4.1
I have a page that works like a charm.
Based on my application I need I have to perform the same operation for the different regions. As a quick and better method, I copied the page and branched, it inspires tab for this region.
The problem is that the original page works fine.
I haven't changed anything except the parent set to this copied page tab and works that I find with the above error.
It allows me to make the first entry on this page, but when I try to access the page again it gives me this error.
The error in detail is as below:
is_internal_error: false
ora_sqlcode:-1422
ora_sqlerrm: ORA-01422: exact fetch returns more than number of lines
Component.type: APEX_APPLICATION_PAGE_PROCESS
Component.ID: 214936714355373108
Component.Name: EMP_LEAVE_INFO line
error_backtrace:
ORA-06512: at line 1
ORA-06512: at "SYS." DBMS_SYS_SQL", line 1926
ORA-06512: at "SYS." WWV_DBMS_SQL', line 973
ORA-06512: at "SYS." WWV_DBMS_SQL', line 999
ORA-06512: at "APEX_040200.WWV_FLOW_DYNAMIC_EXEC", line 806
ORA-06512: at "APEX_040200.WWV_FLOW_DML", line 336
ORA-06512: at "APEX_040200.WWV_FLOW_PROCESS", line 332>
As a quick and better method, I copied the page and branched, it inspires tab for this region.
>Copy paste is never advisable. It can be fast in some cases, there is an anti-pattern.
Be aware that the automatic extraction of the APEX line is based on a component of demand.
It is possible that your automatic rowfetch is based on the element of your previous page. If you for example to change the name of the table, but do not change the reference is the primary key value, then you can pass a value to your table that was not unique. This would result in ORA-01422.
Find the value of the session element and run your query.
Concerning
Nico
-
ORA-01422: exact fetch returns more than number of lines
Hello world
I want to create a procedure only allows me to perform selection et Update in my database, I have already create the procedure and compiled without problems but when I want to run this procedure, I have this error
ORA-01422: exact fetch returns more than number of lines
This syntax of my procedure
create or replace procedure app is
i nombre := 100 ;
o_username employees.first_name% TYPE ;
o_lastn employees. Last_name %TYPE
o_sal. employees % of SALARY TYPE ;
Start
loop
/ * display * /.
Select first_name, LAST_NAME, SALARY
in o_username, o_lastn, o_sal
of admin.employees where employee_id = i;
DBMS_OUTPUT. Put_line (' name: ' | o_username);
DBMS_OUTPUT. Put_line (' first name: ' | o_lastn);
DBMS_OUTPUT. Put_line (' salary: ' | o_sal)
/ * put a days * /.
Update employees
put salary = salary + salary *0.25 where employee_id = i;
commit;
/ * dbms_put.put_line (' new salary is: ' | ') sell2_tab (i)); * /
i := i + 1 ;
/ * list the data * /
/ * dbms_put.put_line (' new salary is: ' ") ;*/
output when i = 200;
end loop;
end app;
thnx
create or replace procedure APP is
Constant START_ID EMPLOYEES. EMPLOYEE_ID % TYPE: = 100;
Constant END_ID EMPLOYEES. EMPLOYEE_ID % TYPE: = 200;
O_USERNAME EMPLOYEES. Type % name;
O_LASTN EMPLOYEES. Last_name type %;
O_SAL EMPLOYEES. Kind of % of SALARY;
Start
for rec (select FIRST_NAME, LAST_NAME, salary
the admin. EMPLOYEES
where EMPLOYEE_ID between START_ID and END_ID)
loop
DBMS_OUTPUT. Put_line (' name: ' | rec. NAME);
DBMS_OUTPUT. Put_line ("first name:" | ") Rec. LAST_NAME);
DBMS_OUTPUT. Put_line (' salary: ' | rec. SALARY) / * setting days * /.
end loop;
Update EMPLOYEES
Set SALARY = SALARY + SALARY * 0.25
where EMPLOYEE_ID between START_ID and END_ID;
commit;
end app;
-
replacement selection on 2 columns and return more than 1 column lists
Hello
I try to build 2 other selection lists and each selection list should return more than 1 column
2 PART_ID and PART_SPECIFICATION columns
Now I build a select on PART_ID as list
Select part_id d, part_id parts r;
The result should be:
PART_ID and PART_SPECIFICATION a PART_ID column must be the text of PART_SPECIFICATION
The selection based on PART_SPECIFICATION list should be like
Select d, part_id parts r part_specification;
Now, it should be posted part_specification in PART_SPECIFICATION and part_id in PART_ID.
This is because a user knows the part_id and the other knows only the specification
Please help me
Siegwin
Hi Siegwin,
Check your application Page 7 (copy of the 500 page) using the selection instead of plugin list, it gives all the values.
and works very well,
use ajax process to get the Xml data in page elements
Here are the changes
application process: getData
point of application: TEMPORARY_APPLICATION_ITEM
create a function in the html header pull_multi_value() page
and he gave the floor to point page p7_empno on the attribute of the html form element as onchange = "pull_multi_value (this.value)"; ""
This can help you.
Leave.
-
How to get a magic number for any table that returns more than 32 k?
I'm in a unique situation where in I try to extract the values of the multiple tables and to publish as XML output. The problem is based on the condition of a few tables can retrieve more than 32 KB and less than 32 KB of data. Less than 32KB is not a problem, as the generation of XML is smooth. The minute he reached more than 32 k, it generates a runtime error. I was wondering if there is a way to make sure that the minute results of the query is greater than 32 KB, it must break say - if results is 35KO, so should I break this result 32 KB and 3 KB. Once then pass these data to appear as XML output. Again, it is not just for a table, but all the tables which are called in the function.
Is it possible? I'm unable to get ideas, or did I do something so complex from the point of view of production support. If you'd be grateful if someone can guide me on this.
The way it is, is the following:
I have a table named ctn_pub_cntlCREATE TABLE CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id NUMBER(18) ,table_name VARCHAR2(50) ,last_pub_tms DATE ,queue_name VARCHAR2(50) ,dest_system VARCHAR2(50) ,frequency NUMBER(6) ,status VARCHAR2(8) ,record_create_tms DATE ,create_user_id VARCHAR2(8) ,record_update_tms DATE ,update_user_id VARCHAR2(8) ,CONSTRAINT ctn_pub_cntl_id_pk PRIMARY KEY(ctn_pub_cntl_id) );
To do this, the data are:
INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_SBDVSN' ,TO_DATE('10/2/2004 10:17:44PM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.TSZ601.UNP' ,'SAP' ,15 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_TRACK_SGMNT_DN' ,TO_DATE('02/06/2015 9:50:00AM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.WRKORD.UNP' ,'SAP' ,30 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_FXPLA_TRACK_LCTN_DN' ,TO_DATE('10/2/2004 10:17:44PM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.YRDPLN.INPUT' ,'SAP' ,30 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_FXPLA_TRACK_LCTN2_DN' ,TO_DATE('02/06/2015 9:50:00AM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.TSZ601.UNP' ,'SAP' ,120 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_FXPLA_TRACK_LCTN2_DN' ,TO_DATE('04/23/2015 11:50:00PM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.YRDPLN.INPUT' ,'SAP' ,10 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_FIXED_PLANT_ASSET' ,TO_DATE('04/23/2015 11:50:00AM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.WRKORD.UNP' ,'SAP' ,10 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_OPRLMT' ,TO_DATE('03/26/2015 7:50:00AM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.WRKORD.UNP' ,'SAP' ,30 ); INSERT INTO CTNAPP.ctn_pub_cntl (ctn_pub_cntl_id ,table_name ,last_pub_tms ,queue_name ,dest_system ,frequency ) VALUES (CTNAPP_SQNC.nextval ,'TRKFCG_OPRLMT_SGMNT_DN' ,TO_DATE('03/28/2015 12:50:00AM','MM/DD/YYYY HH12:MI:SSPM') ,'UT.TSD.WRKORD.UNP' ,'SAP' ,30 ); / COMMIT;
Once the above data are inserted and committed, then I created a feature in a package:
CREATE OR REPLACE PACKAGE CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH IS TYPE tNameTyp IS TABLE OF ctn_pub_cntl.table_name%TYPE INDEX BY BINARY_INTEGER; g_tName tNameTyp; TYPE tClobTyp IS TABLE OF CLOB INDEX BY BINARY_INTEGER; g_tClob tClobTyp; FUNCTION GetCtnData(p_nInCtnPubCntlID IN CTN_PUB_CNTL.ctn_pub_cntl_id%TYPE,p_count OUT NUMBER ) RETURN tClobTyp; END CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH; --Package body CREATE OR REPLACE PACKAGE BODY CTNAPP.CTN_PUB_CNTL_EXTRACT_PUBLISH IS doc xmldom.DOMDocument; main_node xmldom.DOMNode; root_node xmldom.DOMNode; root_elmt xmldom.DOMElement; child_node xmldom.DOMNode; child_elmt xmldom.DOMElement; leaf_node xmldom.DOMNode; elmt_value xmldom.DOMText; tbl_node xmldom.DOMNode; table_data XMLDOM.DOMDOCUMENTFRAGMENT; l_ctx DBMS_XMLGEN.CTXHANDLE; vStrSqlQuery VARCHAR2(32767); l_clob tClobTyp; -- l_xmltype XMLTYPE; -- --Local Procedure to build XML header PROCEDURE BuildCPRHeader IS BEGIN child_elmt := xmldom.createElement(doc, 'PUBLISH_HEADER'); child_node := xmldom.appendChild (root_node, xmldom.makeNode (child_elmt)); child_elmt := xmldom.createElement (doc, 'SOURCE_APLCTN_ID'); elmt_value := xmldom.createTextNode (doc, 'CTN'); leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt)); leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); child_elmt := xmldom.createElement (doc, 'SOURCE_PRGRM_ID'); elmt_value := xmldom.createTextNode (doc, 'VALUE'); leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt)); leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); child_elmt := xmldom.createElement (doc, 'SOURCE_CMPNT_ID'); elmt_value := xmldom.createTextNode (doc, 'VALUE'); leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt)); leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); child_elmt := xmldom.createElement (doc, 'PUBLISH_TMS'); elmt_value := xmldom.createTextNode (doc, TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS')); leaf_node := xmldom.appendChild (child_node, xmldom.makeNode (child_elmt)); leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); END BuildCPRHeader; --Get table data based on table name FUNCTION GetCtnData(p_nInCtnPubCntlID IN CTN_PUB_CNTL.ctn_pub_cntl_id%TYPE,p_Count OUT NUMBER) RETURN tClobTyp IS vTblName ctn_pub_cntl.table_name%TYPE; vLastPubTms ctn_pub_cntl.last_pub_tms%TYPE; BEGIN g_vProcedureName:='GetCtnData'; g_vTableName:='CTN_PUB_CNTL'; SELECT table_name,last_pub_tms INTO vTblName, vLastPubTms FROM CTN_PUB_CNTL WHERE ctn_pub_cntl_id=p_nInCtnPubCntlID; -- Start the XML Message generation doc := xmldom.newDOMDocument; main_node := xmldom.makeNode(doc); root_elmt := xmldom.createElement(doc, 'PUBLISH'); root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt)); --Append Table Data as Publish Header BuildCPRHeader; --Append Table Data as Publish Body child_elmt := xmldom.createElement(doc, 'PUBLISH_BODY'); leaf_node := xmldom.appendChild (root_node, xmldom.makeNode(child_elmt)); DBMS_SESSION.SET_NLS('NLS_DATE_FORMAT','''YYYY:MM:DD HH24:MI:SS'''); vStrSqlQuery := 'SELECT * FROM ' || vTblName || ' WHERE record_update_tms <= TO_DATE(''' || TO_CHAR(vLastPubTms, 'MM/DD/YYYY HH24:MI:SS') || ''', ''MM/DD/YYYY HH24:MI:SS'') ' ; -- || ' AND rownum < 16' --; DBMS_OUTPUT.PUT_LINE(vStrSqlQuery); l_ctx := DBMS_XMLGEN.NEWCONTEXT(vStrSqlQuery); DBMS_XMLGEN.SETNULLHANDLING(l_ctx, 0); DBMS_XMLGEN.SETROWSETTAG(l_ctx, vTblName); -- Append Table Data as XML Fragment l_clob(1):=DBMS_XMLGEN.GETXML(l_ctx); elmt_value := xmldom.createTextNode (doc, l_clob(1)); leaf_node := xmldom.appendChild (leaf_node, xmldom.makeNode (elmt_value)); xmldom.writeToBuffer (doc, l_clob(1)); l_clob(1):=REPLACE(l_clob(1),'<?xml version="1.0"?>', NULL); l_clob(1):=REPLACE(l_clob(1),'<', '<'); l_clob(1):=REPLACE(l_clob(1),'>', '>'); RETURN l_clob; DBMS_OUTPUT.put_line('Answer is' ||l_clob(1)); EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.put_line('There is no data with' || SQLERRM); g_vProcedureName:='GetCtnData'; g_vTableName:='CTN_PUB_CNTL'; g_vErrorMessage:=SQLERRM|| g_vErrorMessage; g_nSqlCd:=SQLCODE; ctn_log_error('ERROR',g_vErrorMessage,'SELECT',g_nSqlCd,p_nInCtnPubCntlID,g_vPackageName,g_vProcedureName,g_vTableName); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR : ' || SQLERRM); ctn_log_error('ERROR',g_vErrorMessage,'OTHERS',g_nSqlCd,p_nInCtnPubCntlID,g_vPackageName,g_vProcedureName,g_vTableName); END GetCtnData; PROCEDURE printClob (result IN OUT NOCOPY CLOB) IS xmlstr VARCHAR2 (32767); line VARCHAR2 (2000); BEGIN xmlstr := DBMS_LOB.SUBSTR (result, 32767); LOOP EXIT WHEN xmlstr IS NULL; line := SUBSTR (xmlstr, 1, INSTR (xmlstr, CHR (10)) - 1); DBMS_OUTPUT.put_line (line); xmlstr := SUBSTR (xmlstr, INSTR (xmlstr, CHR (10)) + 1); END LOOP; END printClob; END CTN_PUB_CNTL_EXTRACT_PUBLISH;
If you notice my query:
vStrSqlQuery := 'SELECT * FROM ' || vTblName || ' WHERE record_update_tms <= TO_DATE(''' || TO_CHAR(vLastPubTms, 'MM/DD/YYYY HH24:MI:SS') || ''', ''MM/DD/YYYY HH24:MI:SS'') ' ; || ' AND rownum < 16' ;
The minute I comment
|| ' AND rownum < 16' ;
It generates an error because this query returns about 600 lines and all these lines must be published in XML format and the tragedy, is that it is a C program between institutions i.e. C calls my functions of packged and then will do all the processing. This will return the results to the C program. Then obviously C does not recognize the CLOB and somewhere in the process, I convert to VARCHAR or CLOB CLOB, I have to use VARCHAR as a return type. That's my challenge.
Someone who can help me find the number required of magic and also a brief knows how, I understand that. Thanks in advance.
Not that I would use it myself but your package can be simplified down, like this:
create or replace package ctn_pub_cntl_extract_publish is C_DTFORMAT constant varchar2(30) := 'YYYY-MM-DD HH24:MI:SS'; function getXMLData (p_table_name in varchar2, p_pub_tms in date) return xmltype; function getCTNData (p_id in number) return clob; end ctn_pub_cntl_extract_publish; / create or replace package body ctn_pub_cntl_extract_publish is function getXMLData (p_table_name in varchar2, p_pub_tms in date) return xmltype is v_query varchar2(32767) := q'{select * from $$TABLE_NAME where record_update_tms <= to_date(:1, 'YYYYMMDDHH24MISS')}'; ctx dbms_xmlgen.ctxHandle; doc xmltype; begin execute immediate 'alter session set nls_date_format = "'||C_DTFORMAT||'"'; v_query := replace(v_query, '$$TABLE_NAME', dbms_assert.simple_sql_name(p_table_name)); ctx := dbms_xmlgen.newContext(v_query); dbms_xmlgen.setBindValue(ctx, '1', to_char(p_pub_tms, 'YYYYMMDDHH24MISS')); dbms_xmlgen.setRowSetTag(ctx, p_table_name); dbms_xmlgen.setNullHandling(ctx, dbms_xmlgen.DROP_NULLS); doc := dbms_xmlgen.getXMLType(ctx); dbms_xmlgen.closeContext(ctx); return doc; end; function getCTNData (p_id in number) return clob is doc clob; begin select xmlserialize(document xmlelement("PUBLISH" , xmlelement("PUBLISH_HEADER" , xmlforest( 'CNT' as "SOURCE_APLCTN_ID" , 'VALUE' as "SOURCE_PRGRM_ID" , 'VALUE' as "SOURCE_CMPNT_ID" , to_char(sysdate, C_DTFORMAT) as "PUBLISH_TMS" ) ) , xmlelement("PUBLISH_BODY" , getXMLData(t.table_name, t.last_pub_tms) ) ) ) into doc from ctn_pub_cntl t where t.ctn_pub_cntl_id = p_id; return doc; end; end ctn_pub_cntl_extract_publish;
Function getXMLData() generates a canonical XML document out of the table that is passed as a parameter.
Function built getCTNData() code XML "PUBLISH", the document using SQL/XML functions, the getXMLData() call in the process and returns the content serialized as a CLOB.
Maybe you are looking for
-
By clicking on a link upens two tabs
As I got FF 14.0.1 I had a problem maybe 33% come from the time I click a link, or FF in Outlook and FF will open then two tabs for the link. This is ongoing since I've upgraded to 14.0.1 and it is aggravating.
-
HP 15-AY019TU: need drivers hp
Hello I want drivers for windows 7, as I unable to get them. specifically, I want drivers wifi for the mentioned model number. Thanks in advance.
-
I need to connect laptop to tv?
I have the dv6000 and I like to watch movies from the laptop to the tv Can someone tell me what I need to buy for this? Thank you
-
Dear all, recently I received an email that said I'm one of the 10 people in the world who won a making $ 500 000,00. It's because of the Microsoft program. Quote: "This is to inform you that our office as the regional coordinator of.Microsoft Canada
-
HelloI am trying to install a trial version of Acrobat Reader DC.On installation the message "conflict of Application - Safari must be closed in order to proceed to the Installation of Acrobat. Please close and try again. "continues to appear.Safari