Fetch out of Sequence error isn't returned when doing a single fetch
Hi all,
As per my understanding, if we fetch all the rows from a sys_refcursor into a collection, within the pl/sql block, then it doesn't return any row to the calling program. Instead a fetch out of sequence error is encountered. This worked well. However, when I use a single fetch statement(in case the sys_refcursor contains a single row), I do not encounter "Fetch Out Of Sequence" error. It would be really helpful if anyone could please explain this behaviour.
Below is a sample code snippet that I ran in PL/SQL Developer:
CREATE OR REPLACE PROCEDURE test_cur_1(in_dept_id VARCHAR2,
out_cursor OUT SYS_REFCURSOR) IS
temp_count NUMBER;
temp_rec dept%ROWTYPE;
BEGIN
--This piece of code runs into a "Fetch Out Of Sequence" error, when trying to open up the sys_refcursor.
OPEN out_cursor FOR
SELECT *
FROM dept
WHERE dept_id = in_dept_id;--dept_id is the primary key
LOOP
EXIT WHEN out_cursor%NOTFOUND;
FETCH out_cursor
INTO temp_rec;
dbms_output.put_line('department name: '||temp_rec.dept_name);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
OPEN out_cursor FOR
SELECT SQLCODE||'->'||SQLERRM FROM dual;
END;
CREATE OR REPLACE PROCEDURE test_cur_2(in_dept_id VARCHAR2,
out_cursor OUT SYS_REFCURSOR) IS
temp_count NUMBER;
temp_rec dept%ROWTYPE;
BEGIN
--This piece of code does not run into a "Fetch Out Of Sequence" error. Instead the output sys_refcursor opens up for no rows to display.
OPEN out_cursor FOR
SELECT *
FROM dept
WHERE dept_id = in_dept_id;--dept_id is the primary key
FETCH out_cursor
INTO temp_rec;
dbms_output.put_line('department name: '||temp_rec.dept_name);
EXCEPTION
WHEN OTHERS THEN
OPEN out_cursor FOR
SELECT SQLCODE||'->'||SQLERRM FROM dual;
END;
Appreciate all your time!
When you loop through a cursor, Oracle does not know how many rows there will be in the cursor until it has fetched them all, and it cannot know it has fetched them all until it does one last fetch after getting the last row to find that ti gets nothing back. In psuedo code the fetch command works something like:
open cursor
cursor%notfound := null;
-- This is the fetch phase
ask sql engine to give me a row
if I got one then
cursor%notfound := false;
populate variables/record with values
else
cursor%notfound := true;
end if;
-- end fetch phase
go onto next command in the pl/sql blockSo, in your first procedure you fetch the last row of the cursor then go back to the top of the loop. Since Oracle does not know at this point that the last row has already been fetched so, out_cursor%notfound is still false, so it does another fetch at which point it now "knows" that the last row is fetched so notfound becomes true and your loop exits, returning control to the caller. At this point, presumably the caller attempts to fetch from the cursor. Since the cursor handle is already pointing past the last row you get the fetch out of sequence.
In your second procedure, you fetch a single row from the cursor. You know that the cursor is pointing at the "last" row since you are querying based on the PK, but Oracle does not know that yet. You now return that cursor to the caller who does one more fetch which moves the pointer past the end of the cursor. The caller "sees" no rows, but that is because your procedure already fetched the rows, but did not "check" for the last row.
John
Similar Messages
-
Hi,
I've a pro C code which is currently connecting to Oracle 9i DB through 8.0.6 client. Now I've recompiled the same code with 9.2.0.6 client. Whenever it comes to a code involving cursors, I'm getting a fetch out of sequence error. I use ref cursors with no FOR UPDATE clause. What else could be issue? PLease help
Regards,
DavidI'm pasting the relavant part.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <windows.h>
#define CREW_FETCH_STARTUP 1000
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR la_s_dbcr_crew_id_startup [1000][11];
VARCHAR la_s_dbcr_crew_name_startup [1000] [8];
short int li_cr_tmp_ind1_startup,
li_cr_tmp_ind2_startup;
SQL_CURSOR CREW_ACTIVE_CUR;
int vb_cr_sent_count = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE GP_SQL_Def;
EXEC ORACLE OPTION (MAXOPENCURSORS=20);
EXEC SQL ALLOCATE :CREW_ACTIVE_CUR;
EXEC SQL EXECUTE
BEGIN
PKG.PROCESS_CREW_STARTUP(:ls_cr_param_market_area, 2, :CREW_ACTIVE_CUR,
:dummy1, :dummy2, :return_code, :return_msg);
END;
END-EXEC;
for(ln_ctr1=0;ln_ctr1 < CREW_FETCH_STARTUP;ln_ctr1++) {
VAR_INIT(la_s_dbcr_crew_id_startup[ln_ctr1]);
VAR_INIT(la_s_dbcr_crew_name_startup[ln_ctr1]);
la_i_cr_tmp_ind1_startup[ln_ctr1] = 0;
la_i_cr_tmp_ind2_startup[ln_ctr1] = 0;
EXEC SQL
FETCH :CREW_ACTIVE_CUR
INTO :la_s_dbcr_crew_id_startup :la_i_cr_tmp_ind1_startup,
:la_s_dbcr_crew_name_startup :la_i_cr_tmp_ind2_startup;
MessageBox(NULL,lc_s_crew_tmp_msg_str,lc_s_crew_tmp_msg_str,MB_OK);
if (sqlca.sqlcode < 0) {
if (DEBUG_CE) {
sprintf(lc_s_crew_tmp_msg_str,"Error in Fetch Cursor(CREW_ACTIVE_CUR) (%s)",
sqlca.sqlerrm.sqlerrmc);
MessageBox(NULL,lc_s_crew_tmp_msg_str,lc_s_crew_tmp_msg_str,MB_OK);
return -1;
} -
ORA-01002: fetch out of sequence- error when accesing oracle sp from c#
We have a stored procedure when we exceute it from Sql plus tool ot Toad works fine. But when we call it from C# .ne code gives us the following error.
ORA-01002: fetch out of sequence ORA-02063: preceding line from SQA1
Please help.with out these lines it works
(fae_primary_agent_ind = 'X') or
((fae_primary_agent_ind is null) and (agn_agt_comp_st_cd = ‘65’)
This is the stored proc. It works in oracle. It does not work only when we call it from C#.
CREATE OR REPLACE
PROCEDURE abc (
p_report_date IN VARCHAR2,
p_cur OUT Getadrdata.t_cursor,
p_run_mode OUT NUMBER
AS
v_report_dt DATE;
backed_out NUMBER := 0;
previously_paid NUMBER := 0;
BEGIN
v_report_dt := TO_DATE (p_report_date, 'DDMMYYYY');
SELECT COUNT (*)
INTO backed_out
FROM r2t_adr_payment a, DUAL
WHERE a.fap_acctg_dt = v_report_dt
AND a.fap_status_cd = 'B';
IF backed_out = 0
THEN
SELECT COUNT (*)
INTO previously_paid
FROM r2t_adr_payment a, DUAL
WHERE a.fap_acctg_dt = v_report_dt
AND a.fap_status_cd = 'P';
END IF;
IF backed_out > 0 or previously_paid > 0
THEN
p_run_mode := 2;
OPEN p_cur FOR
SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
fae_address_ln1 address_line1, fae_address_ln2 address_line2,
fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
fae_bus_phone business_phone, fae_supv_region_cd region,
fae_territory_cd territory, fae_market_cd market,
-- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
fae_agent_type_cd status_cd, fae_first_nm first_name,
fae_last_nm last_name,
rpt_agent_bonus_class_id p_agent_bonus_class_id
FROM r2t_adr_epc_agent_info LEFT OUTER JOIN rgt_points
ON fae_agent_nbr = rpt_agent_nbr
LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
agn_agent_nbr
INNER JOIN r2t_adr_payment
ON fae_agent_nbr = fap_primary_agent_nbr
WHERE FAE_AGENT_TYPE_CD = '41'
AND rpt_acctg_dt = v_report_dt
AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
AND fap_acctg_dt = v_report_dt
AND fap_status_cd = 'B'
UNION ALL
SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
fae_address_ln1 address_line1, fae_address_ln2 address_line2,
fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
fae_bus_phone business_phone, fae_supv_region_cd region,
fae_territory_cd territory, fae_market_cd market,
-- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
fae_agent_type_cd status_cd, fae_first_nm first_name,
fae_last_nm last_name,
0 p_agent_bonus_class_id
FROM r2t_adr_epc_agent_info
LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
agn_agent_nbr
INNER JOIN r2t_adr_payment
ON fae_agent_nbr = fap_primary_agent_nbr
WHERE fae_agent_type_cd = '13'
AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
AND fap_acctg_dt = v_report_dt
AND fap_status_cd = 'B';
ELSE
p_run_mode := 1;
OPEN p_cur FOR
SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
fae_address_ln1 address_line1, fae_address_ln2 address_line2,
fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
fae_bus_phone business_phone, fae_supv_region_cd region,
fae_territory_cd territory, fae_market_cd market,
-- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
fae_agent_type_cd status_cd, fae_first_nm first_name,
fae_last_nm last_name,
rpt_agent_bonus_class_id p_agent_bonus_class_id
FROM r2t_adr_epc_agent_info LEFT OUTER JOIN rgt_points
ON fae_agent_nbr = rpt_agent_nbr
LEFT OUTER JOIN p1t_tot_agent ON fae_agent_nbr =
agn_agent_nbr
WHERE rpt_acctg_dt = v_report_dt
-- Next line for testing of a subset of data - testing purposes only
-- AND FAE_SUPV_REGION_CD ='002'
AND FAE_AGENT_TYPE_CD = '41'
AND (
(RPT_AGENT_BONUS_CLASS_ID = '3' AND SUBSTR(FAE_EMPLMT_DT,1,2) <> '01' AND ADD_MONTHS(FAE_EMPLMT_DT, 7 ) <= v_report_dt) OR
(RPT_AGENT_BONUS_CLASS_ID = '3' AND SUBSTR(FAE_EMPLMT_DT,1,2) = '01' AND ADD_MONTHS(FAE_EMPLMT_DT, 6 ) <= v_report_dt) OR
(RPT_AGENT_BONUS_CLASS_ID = '1')
AND (
(fae_primary_agent_ind = 'X') or
((fae_primary_agent_ind is null) and (agn_agt_comp_st_cd = ‘65’)
AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt
UNION ALL
SELECT fae_agent_nbr agent_nbr, fae_ssn_last_4digits ssn_nbr,
fae_address_ln1 address_line1, fae_address_ln2 address_line2,
fae_city_nm city, fae_state_cd state, fae_zip_cd zip,
fae_bus_phone business_phone, fae_supv_region_cd region,
fae_territory_cd territory, fae_market_cd market,
-- FAE_AGT_COMP_ST_CD COMP_STAT_CD,
agn_agt_comp_st_cd comp_stat_cd, fae_emplmt_dt emp_date,
fae_agent_type_cd status_cd, fae_first_nm first_name,
fae_last_nm last_name, 0 p_agent_bonus_class_id
FROM r2t_adr_epc_agent_info LEFT OUTER JOIN p1t_tot_agent
ON fae_agent_nbr = agn_agent_nbr
WHERE fae_agent_type_cd = '13'
-- Next line for testing of a subset of data - testing purposes only
-- AND FAE_SUPV_REGION_CD ='002'
AND fae_primary_agent_ind = 'X'
AND v_report_dt BETWEEN agn_start_eff_dt AND agn_end_eff_dt;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
--DBMS_OUTPUT.PUT_LINE ('no data ' || SQLERRM);
NULL;
WHEN OTHERS
THEN
--DBMS_OUTPUT.PUT_LINE ('error ' || SQLERRM);
--OPEN p_cur FOR
-- SELECT NULL
-- FROM DUAL;
RAISE;
END abc; -
Fetch out of sequence ERROR - urgent
Hi guys ..
If i try to run the program i am getting an error message as
java.sql.SQLException: ORA-01002: fetch out of sequence at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
will u pl help me how to solve this
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
import java.io.*;
class LOBTest
public static void main(String str[])
try
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection("jdbc:oracle:thin:spk/[email protected]:1521:spk");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select temp from blobtest where no = 1 for update");
BLOB bl = null;
if(rs.next())
bl = ((OracleResultSet)rs).getBLOB(1);
FileInputStream ins = new FileInputStream("map.gif");
byte br[]= new byte[ins.available()];
ins.read(br);
bl.putBytes(0,br);
}catch(Exception ept)
ept.printStackTrace();
System.out.println(ept);
}from the Oracle docs:
"ORA-01002: fetch out of sequence
Cause: In a host language program, a FETCH call was issued out of sequence. A successful parse-and-execute call must be issued before a fetch. This can occur if an attempt was made to FETCH from an active set after all records have been fetched. This may be caused by fetching from a SELECT FOR UPDATE cursor after a commit. A PL/SQL cursor loop implicitly does fetches and may also cause this error.
Action: Parse and execute a SQL statement before attempting to fetch the data. "
taken from:
http://technet.oracle.com/doc/server.804/a58312/newch221.htm#16189
Solution:
when you use "for update" in your select statement you must set the connection's auto commit to false--> Connection.setAutoCommit(false);
Jamie -
ORA-01002: fetch out of sequence error
Hello friends,
I m facing a prob using a cursor for update.
here is a piece of code:
DECLARE
CURSOR c_tot_inv_qty (p_prd_id tr_periods.period_id%TYPE) IS
SELECT total_inv_qty, item_id, period_id, dc_id
FROM inv_dc_tmp
WHERE period_id = p_prd_id + 1
FOR UPDATE OF total_inv_qty;
BEGIN
FOR pd IN ( SELECT period_id
FROM tr_periods
WHERE status_flag = 1
AND period_id >= 46
LOOP
FOR t_tot_inv_qty IN c_tot_inv_qty(pd.period_id) LOOP
BEGIN
SELECT inv_forecast_qty
INTO l_inv_fc_qty
FROM inv_dc_tmp
WHERE item_id = t_tot_inv_qty.item_id
AND period_id = pd.period_id
AND dc_id = t_tot_inv_qty.dc_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_inv_fc_qty := 0;
END;
UPDATE inv_dc_tmp
SET total_inv_qty = l_inv_fc_qty
WHERE CURRENT OF c_tot_inv_qty;
END LOOP;
END LOOP;
COMMIT;
END;
i have written commit after the loop..but still it raise an error ORA-01002: fetch out of sequence
i m unable to find out the soln
i need ur help.
Thanks
RSDI'm not sure what your code is trying to accomplish, but give this a whirl. It might be better than all that looping and cursors. I don't have any sample data/tables so I'm largely guessing here.
update inv_dc_tmp i
set i.total_inv_qty =
(select sum(t.inv_forecast_qty)
from inv_dc_tmp t
,tr_periods p
where t.period_id = p.period_id
and p.status_flag = 1
and p.period_id >= 46
and t.period_id = i.period_id - 1
and t.item_id = i.item_id
and t.dc_id = i.dc_id
where exists
(select 1
from tr_periods p
where p.period_id = i.period_id - 1
and p.status_flag = 1
and p.period_id >= 46
;Extremely UNtested. -
Procedure throwing ORA-01002: fetch out of sequence error
Hello ..
I am not using any commits inside cursors with for update statements. This was running for the last 48 hrs and suddenly started throwing errors. Can anyone help me why it has problems sporadically. Code is enclosed here.
Is Sys_refcursor a dynamic cursor?.. I have my transaction_cursor as a sys_refcursor? Is that the problem here. If so, Do I need to remove commit inside the opening and closing of this cursor. The commit is executed for every 10000 rows..
Thanks in Advance
Kris
PROCEDURE PROCESS_EXECUTOR AS
cursor jobs_cursor is
select job_id from (
SELECT DISTINCT
job_id
FROM table_x )
ORDER BY job_id ) where ROWNUM <= 10;
transaction_cursor SYS_REFCURSOR;
tran tran_type;
sql_code varchar2(1024);
err_msg varchar2(1024);
cmt_counter number := 0;
BEGIN -- Process_Executor Start
for r_csr in jobs_cursor loop
OPEN transaction_cursor FOR SELECT * FROM table_y a
WHERE a.job_id = r_csr.job_id
order by create_timestamp, task_id;
LOOP
FETCH transaction_cursor BULK COLLECT INTO tran LIMIT 10;
EXIT WHEN tran.COUNT = 0;
FOR i IN 1..tran.COUNT LOOP
begin
if cmt_counter = 0 then
savepoint last_transaction;
end if;
cmt_counter := cmt_counter + 1;
exec_process1(tran(i));
if (cmt_counter = 10000 ) then
commit;
cmt_counter := 0;
end if;
exception
when others then
rollback to last_transaction;
end;
END LOOP;
END LOOP;
CLOSE transaction_cursor;
end loop;
commit;
END PROCESS_EXECUTOR;I'm always trying to avoid loops at all cost.
Anyway your jobs_cursor contains one open* and two close brackets* (see added comments)
I don't have a database available but as usually order by is the last sql clause maybe close bracket 1 should be commented out
PROCEDURE PROCESS_EXECUTOR AS
cursor jobs_cursor is select job_id
from (SELECT DISTINCT job_id -- OPEN BRACKET 1
FROM table_x
) -- CLOSE BRACKET 1
ORDER BY job_id
) -- CLOSE BRACKET 2
where ROWNUM <= 10;
transaction_cursor SYS_REFCURSOR;
tran tran_type;
sql_code varchar2(1024);
err_msg varchar2(1024);
cmt_counter number := 0;
BEGIN -- Process_Executor Start
for r_csr in jobs_cursor loop
OPEN transaction_cursor FOR SELECT * FROM table_y a
WHERE a.job_id = r_csr.job_id
order by create_timestamp, task_id;
LOOP
FETCH transaction_cursor BULK COLLECT INTO tran LIMIT 10;
EXIT WHEN tran.COUNT = 0;
FOR i IN 1..tran.COUNT LOOP
begin
if cmt_counter = 0 then
savepoint last_transaction;
end if;
cmt_counter := cmt_counter + 1;
exec_process1(tran(i));
if (cmt_counter = 10000 ) then
commit;
cmt_counter := 0;
end if;
exception
when others then
rollback to last_transaction;
end;
END LOOP;
END LOOP;
CLOSE transaction_cursor;
end loop;
commit;
END PROCESS_EXECUTOR;Regards
Etbin -
The simple program below is a client that executes a SELECT query -
there are 13 rows in the table, of which 10 are printed when I run the
program, then after that the ORA-01002 error is reported. I am not
doing anything with LOBs, or updates. I've tried putting
con.setAutoCommit(false) as well, but that does not do anything.
Why am I getting this error? Can anyone help.
Thanks
-H
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://127.0.0.1:7001");
PreparedStatement stmt = null;
ResultSet rs = null;
UserTransaction ut = null;
try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds
= (javax.sql.DataSource) ctx.lookup ("jtaXADS");
java.sql.Connection conn = ds.getConnection();
// You can now use the conn object to create
// Statements and retrieve result sets:
ut = (UserTransaction)
ctx.lookup("javax.transaction.UserTransaction");
ut.begin();
stmt = conn.prepareStatement("select firstname,surname from
EMPLOYEE ");
stmt.executeQuery();
rs = stmt.getResultSet();
// Close the statement and connection objects when you are finished:
while (rs.next())
System.out.println("Result is " + rs.getString("firstname") + " " +
rs.getString("surname"));
ut.commit();
stmt.close();
conn.close();
catch (Exception e) {
e.printStackTrace();
// a failure occurred
finally {
try {ctx.close();
rs.close();}
catch (Exception e) {
// a failure occurred
e.printStackTrace();Thanks everybody.
I have tried this, calling ut.begin() first before getConnection,
however no difference. However the problem goes away if I call
stmt.setFetchSize(100);
But I would prefer not to have to code this in every time!!!
I see there is a setting within Weblogic Admin console to see the
row-prefetch, but that is already set to 45 rows, so why do have to
explicitly call stmt.setFetchSize(100)!!!
Thanks
-H
"Carl Lawstuen" <[email protected]> wrote in message news:<[email protected]>...
Agreed. The transaction must start before the connection. This is what
is most likely causing the error.
"Nils Winkler" <[email protected]> wrote in message
news:[email protected]...
Hi,
one more thing: The UserTransaction has to be started before you obtain
the connection, not after.
Nils
Humphrey wrote:
The simple program below is a client that executes a SELECT query -
there are 13 rows in the table, of which 10 are printed when I run the
program, then after that the ORA-01002 error is reported. I am not
doing anything with LOBs, or updates. I've tried putting
con.setAutoCommit(false) as well, but that does not do anything.
Why am I getting this error? Can anyone help.
Thanks
-H
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://127.0.0.1:7001");
PreparedStatement stmt = null;
ResultSet rs = null;
UserTransaction ut = null;
try {
ctx = new InitialContext(ht);
javax.sql.DataSource ds
= (javax.sql.DataSource) ctx.lookup ("jtaXADS");
java.sql.Connection conn = ds.getConnection();
// You can now use the conn object to create
// Statements and retrieve result sets:
ut = (UserTransaction)
ctx.lookup("javax.transaction.UserTransaction");
ut.begin();
stmt = conn.prepareStatement("select firstname,surname from
EMPLOYEE ");
stmt.executeQuery();
rs = stmt.getResultSet();
// Close the statement and connection objects when you are finished:
while (rs.next())
System.out.println("Result is " + rs.getString("firstname") + " " +
rs.getString("surname"));
ut.commit();
stmt.close();
conn.close();
catch (Exception e) {
e.printStackTrace();
// a failure occurred
finally {
try {ctx.close();
rs.close();}
catch (Exception e) {
// a failure occurred
e.printStackTrace();
============================
[email protected] -
Sql Error in Select statement when doing subquery
Hi,
I am trying to see what the error is in the subquery part of the select statement.
Subquery should be fetching the safety_stock_quantity based on the MAX(effectivity_date).
Any suggestions?
SELECT kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size,
(SELECT msc.safety_stock_quantity
FROM mtl_safety_stocks msc
WHERE msc.effectivity_date = (select MAX(msc2.effectivity_date)
from mtl_safety_stocks msc2
where msc2.inventory_item_id = itm.inventory_item_id
and msc2.organization_id = itm.organization_id)
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
FROM mtl_system_items_b itm
,mtl_onhand_quantities_detail moqd
,mtl_safety_stocks msc
,mtl_kanban_card_activity kbn
WHERE itm.inventory_item_id = kbn.inventory_item_id
AND itm.organization_id = kbn.organization_id
AND itm.inventory_item_id = moqd.inventory_item_id
AND itm.organization_id = moqd.organization_id
AND moqd.subinventory_code = kbn.source_subinventory
AND kbn.card_status = 1
AND kbn.supply_status = 5
AND msc.inventory_item_id = itm.inventory_item_id
AND msc.organization_id = itm.organization_id
GROUP BY
kbn.last_update_date,itm.segment1,itm.description,kbn.kanban_card_number,kbn.kanban_size;
Thanks
PravnHi, Pravn,
Remember the ABC's of GROUP BY:
When you use a GROUP BY clause and/or an aggregate fucntion, then every item in the SELECT clause must be:
(A) an <b>A</b>ggregate function,
(B) one of the "group <b>B</b>y" expressions,
(C) a <b>C</b>onstant, or
(D) something that <b>D</b>epends entirely on the above. (For example, if you "GROUP BY TRUNC(dt)", you can "SELECT TO_CHAR (TRUNC(dt), 'Mon-DD')").
There's a GROUP BY clause in your main query, so every item in the main SELECT clause must be one of the above. The last item, the unnamed scalar sub-query, is none of the above.
How can you fix this problem? That depends on your data, the results you want, and perhaps on your Oracle version. If you'd like help, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved. Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using.
You may have noticed that this site normally doesn't display multiple spaces in a row.
Whenever you post formatted text (including, but limited to, actual code) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing. -
I'm using the PCI 6711 board programmed in Visual Basic. I'm working from the WFMDoubleBuf example file for VB and I've modified it for continuous output on 2 analog channels. I fill the buffers with customized waveforms from files I have previously created. I often get -10608 (noTransferInProgError, No transfer is in progress for the specified resource) and -10803 (transferStoppedError , The on-going transfer has been stopped. This is to prevent regeneration for output operations, or to reallocate resources for input operations) errors when I try to output at higher rates (about 140000samples per second and up). The -10608 error generally happens after seve
ral (sometimes hundreds) of half buffers have been transfered, whereas the -10803 error usually occurs immediately after starting output. This device is supposed to be able to output at up to 1Msample per sec per channel but I don't seem to be able to do that. I have tried increasing the buffersize (up to 16777216) with no apparent effect. Is there any other information as to what causes these errors or how they can be avoided. Any ideas?Roz,
I found two KnowledgeBase entries about the most common causes of these errors.
1. Why Do I Receive the Error -10608 When Using the PCI-6711?: http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/37752a79eb6a950886256c8b006e8870?OpenDocument
2. Why am I Getting the 10800 and/or 10803 Errors?:
http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/c9097c72463d215886256a700075a6ef?OpenDocument
Have a great day. -
Outputting an error message in MV50AFZ1 when doing a VL01N - getting update
Hello. I am getting an "update terminate" message due to using a MESSAGE statement in user-exit USEREXIT_SAVE_DOCUMENT_PREPARE . We need to be able to stop a delivery from getting created and alert the user under certain circumstances (if a field is not filled in on a separate screen). I have seen under Note 415716 that we cannot use the MESSAGE statement. Is there any way to stop a delivery from being created while informing the user that they have not filled out the required field? (This field is on another tab that they may not see when creating into the delivery). I have tried various uses of the MESSAGE statment, tried perform message_handling, etc., but still no luck. Thanks for any help!
Regards,
VinceHi Vince,
I am not too sure but could you please check below subroutine of SAPMV50A-
PERFORM message_handling USING
<item#>
<number>
<type>
<id>
<msgv1>
<msgv2>
<msgv3>
<msgv4>.
Thanks
Mohit -
ERROR IN NUMBER RANGE when doing profit center distribution
hi
iam getting this error while doing distribution in profit center accounting , can anyone help me with this
ERROR:
Diagnosis
An error occurred during document number determination. No range was found for number range object GL_LOCAL, sub-object AUS2.
System Response
No document number was determined. Results could not be updated.follow steps below:
1. go to tcode snro
2. input GL_LOCAL in the object field
3. push "number ranges" button
4. push "Groups"(maintain) button
5. select "V0" group, since I use Document type 'V0' during PCA distribution
6. push 'change' button
7. insert the year you want -
Error In allocation Structure when doing settlement to GL from WBS
Hi All,
I got this error message. What should i do? I try to check my allocation structure...but it seem correct.
Complete allocation structure Z3
Message no. KD503
Diagnosis
During settlement, the system puts the sender debits into groups (assignments), which are settled using the same settlement cost element. The settlement assignment is made in the allocation structure, which is stored in the settlement rule for the sender (under settlement parameters).
Cost element 901000 cannot be assigned to a settlement cost assignment in allocation structure Z3, and therefore it cannot be assigned to a settlement cost element.
Procedure
Possible solutions are as follows:
If the posting under cost element 901000 was made to the sender because of an incorrect entry, and you can reverse the posting, and do not need to update the allocation structure. You only need to reverse the incorrectly assigned posting before repeating the settlement. Exception: For an investment measure with a line item settlement, you need to extend the allocation structure, even after the reversal.
If the posting was made correctly, you can do the following:
a) You can assign a different allocation structure to the sender: In the master data maintenance for the sender, choose "Settlement rule -> Goto -> Settlement parameters" and then enter a different allocation structure.
If necessary, also check whether the correct allocation structure is entered in the settlement profile. The allocation structure is defaulted in the settlement profile when you create sender master data or when you maintain the settlement rule.
You can update allocation structure Z3Hi Sreenivas ,
The accounting document looks weird :
Hi,
Settlement profile : ZPS001
GL, CC, Order, WBSE and FXA optional
Document type : SA (GL Account doc)
Distribution rule : 10
Residence time : 24
Allocation strucutre Z3
Default object type : FXA
tick on % settlement and equivalence no
to be settled in full
Allocation structure : Z3
Assignment : 1.Labour ,2.MAterial, 3. Subcontract
Source : 1. PSlabour , 2.PSmaterial 3. PSsubcon 4.Cost
Settlement cost center : FXA (ticl by CE), CTR (settlement cost element 90200) ; ORD (Settlement cost element 902001); GL put 747100f
I already successfully settle from WBS to GL 747100(settlement receiver) However, when i check FB03 it shows that
GL account 747100
Posting key 40
Amount 25000
GL Account 747100
Posting key 50
Amount -25000
What the problem ?
Cheers,
Nies -
2012R2-Ess. event 12072 and error 401 (not authorized) when doing checkhealth
Hello,
I installed wsus on a fresh installed Windows Server 2012R2 Essentials (german) and "wsusutil checkhealth" gives me Event 12072 and 13002
The WSUS Content Directory is not accessible (Es kann nicht auf das WSUS-Inhaltsverzeichnis zugegriffen werden.)
System.Net.WebException: Der Remoteserver hat einen Fehler zurückgegeben: (401) Nicht autorisiert.
(remoteserver gave error back: 401, not authorized)
bei System.Net.HttpWebRequest.GetResponse()
bei Microsoft.UpdateServices.Internal.HealthMonitoring.HmtWebServices.CheckContentDirWebAccess(EventLoggingType type, HealthEventLogger logger)
What I did:
installed server 2012R2 Essentials
did a domain migration from a 1-Server 2003 Domain to this 1-Server 2012 Domain the old 2003 server hosted a wsus server
installed wsus as a role, content directory: D:\wsus (not created before, was created automatically by wsus setup/config)
ran the wsus config, products: Server 2012 only
grant "Network service" Full Access in D:\ and D:\WSUS
grant "Network service" Full Access in %windir%\.Net\Framework\v4..\Temporary ASP .Net Files
tried to grant "Network service" Full Access in IIS-Manager > WSUS-Management > APIRemoting30 but got some "access denied" errors here, although i am administrator
"D:\WSUS\WsusContent\anonymousCheckFile.txt" exists, is empty
icacls D:\wsus\wsuscontent
NT-AUTORITÄT\Netzwerkdienst:(OI)(CI)(F)
ROESRATH\WSUS Administrators:(OI)(CI)(F)
NT-AUTORITÄT\Netzwerkdienst:(I)(OI)(CI)(F)
VORDEFINIERT\Administratoren:(I)(OI)(CI)(F)
NT-AUTORITÄT\SYSTEM:(I)(OI)(CI)(F)
http://localhost/connect/Server.aspx still works
Unfortunately I did not find anything about this 401 not authorized in the web :-((
Hope, anyone could help me
Regards
Uweicacls D:\wsus\wsuscontent
NT-AUTORITÄT\Netzwerkdienst:(OI)(CI)(F)
ROESRATH\WSUS Administrators:(OI)(CI)(F)
NT-AUTORITÄT\Netzwerkdienst:(I)(OI)(CI)(F)
VORDEFINIERT\Administratoren:(I)(OI)(CI)(F)
NT-AUTORITÄT\SYSTEM:(I)(OI)(CI)(F)
The USERS group appears to be missing from this list. Since it is the USERS group that grants permissions to IIS_USR for anonymous access, and the /Content v-dir is an anonymous resource, almost certainly the absence of the USERS group is causing the '401'
errors. The USERS group requires Read & Execute access on the folder tree.
Also, there may be complications because this machine is a Domain Controller. Domain Controllers and WSUS on Windows Server 2012 do not play nicely together, but it would seem you're already past most of those known hurdles. However, I do find these two
references to be ambiguous:
ROESRATH\WSUS Administrators:(OI)(CI)(F)
VORDEFINIERT\Administratoren:(I)(OI)(CI)(F)
The Administrators group should have Full Control, as should the WSUS Administrators group. If this machine is a Domain Controller, then those would actually be the DOMAIN\Domain Admins group and the DOMAIN\WSUS Administrators group. But in this instance,
these two groups have different scope references: ROESRATH vs VORDEFINIERT.
Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
SolarWinds Head Geek
Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
http://www.solarwinds.com/gotmicrosoft
The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds. -
Constanr error messages re incorrect # when doing advanced search
Every time I try to do an advanced search for a member I get the error message number is incorrect. I have tried it over and over with various ID's Anyone else see this issue. And yes, numbers are typed correctly
I have never had the issue before. I will try listening and then typing. Is this another glitch, bug, or an attempt to not be able to search any more for Ebay ID's?
-
ORA 01002 error - Fetch out of sequence
I am using COMMIT statement inside CURSOR FOR LOOP after inserting records. I am not using FOR UPDATE. But still I see fetch out of sequence error. I need to do commit intervals of every 1000 insert statements. How to resolve this error?
The reason of your error from oracle point of view is --
ORA-01002: fetch out of sequence
Cause: This error means that a fetch has been attempted from a cursor which is no longer valid. Note that a PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including: 1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned. 2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error. 3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.
Action: 1) Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch. 2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE. 3) Reexecute the statement after rebinding, then attempt to fetch again.
Now, my question is - are attempting any fetches inside any for loop - which will throw this error? Just check it - and let us know your feedback.
Regards.
Satyaki De.
Maybe you are looking for
-
All Records not showing in Report
Hi All, U just solved my amount problem.... But now i gives my earlier problem again, means displaying only 1 rows, when i executing for 1 month in selection criteria...and amount showing right total of all records... example--- Document No......Doc.
-
Task History in Email Notifications
Hi, I am sending the ADF page as an email notification to the users. This page has the history components. However, i could not see the history in the email. Do i have to do any additional settings? Thanks, Lakshmi.
-
ALV to another Drilldown ALV...???
Hi.. I have a requirement in which i have to create an ALV report. Now if any particular cell is selected.... for example... Sales Organization cell is selected... Then what i need to do is to show another ALV report as a drilldown with that sales or
-
hi, i m aon 12.1.3 , i made create employee document with integrated create employee layout but i want to change layout but unable because when i create document it shows integrator>viewer>content?review skip the layout how can i do that for assignme
-
OSB - command line build with resources of coinfiguration project
Hi! I would like to use the com.bea.alsb.core.ConfigExport class to make an OSB build. This class can create the sbconfig.jar for me but without the resources of configuration project (e.g. SMTP server component). If I make a build in eclipse I can s