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
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;
} -
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 -
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; -
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] -
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. -
Update table with BC4J results in ORA-1002: fetch out of sequence
In our BC4J application, any table updates result in an ORA-1002: fetch out of sequence error message. The code looks something like this:
EmpViewImpl voEmp = getEmpView ();
voEmp.setWhereClause ("id = :0");
voEmp.setWhereClauseParam (0, iEmpId);
voEmp.executeQuery ();
if (voEmp.hasNext ()) {
EmpViewRowImpl rowEmp = (EmpViewRowImpl) voEmp.first ();
rowEmp.setFirstName ("Larry");
getTransaction ().postChanges ();
getTransaction ().commit ();
This has something to do with a bug (according to the Oracle JVM release notes). Still, this is fairly basic BC4J code, copied straight from the BC4J documentation. So why won't it work? Is there a workaround?
I'm currently replacing all this code with straightforward executeCommand ("update emp set firstname='.......") commands. This isn't problem-free either, because the remaining BC4J-code isn't always directly aware of any changes made in the database this way.
We use Oracle 8.1.6.1.0 on Linux RedHat 6.2, and JDeveloper 3.1 on Windows 2000. We've deployed the BC4J application modules as EJB's into the Oracle 8i JVM.
Any help is much appreciated!!!We've got the exact same problem!
Please help us.... -
Java.sql.SQLException: ORA-01002: fetch out of sequence
We are getting 'Fetch out of sequence' error whrn we try to execute a 'for update' query.
We are first inserting values into the DLX_ASSET table and if there is image to be inserted the particualr row is fetched using the query. The insert query inserts values into the database.
'SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE'. While executing this query we are getting this exception. This is not happening when we are trying it from our local machine. But its happening everywhere else where its deployed.
We are using Websphere Application Server 6 and Oracle 9i. We have set autommit to false before the method is called and are commiting the transaction only after the whole set of queries are executed.
Please see below the code snippet,
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
logger.logInfo("QUERY is...."+query);
logger.logInfo("Connection closed:"+ con.isClosed());
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery(); logger.logInfo("inside updating high res image 1");
while (rsHighRes.next()) {
logger.logInfo("inside while high res image 2");
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
logger.logInfo("before update high res");
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
logger.logInfo(" after update query asset id: " + assetId);
logger.logInfo(" query high res:: " + UPDATE_QRY);
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
logger.logInfo("after update high res");
//checking if thumbnail is present: if bulk upload thumb nail won't be present
the exception is occuring in the line 'rsHighRes = (OracleResultSet) psHighResObj.executeQuery();'
This is exception trace
java.sql.SQLException: ORA-01002: fetch out of sequence
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java(Inlined Compiled Code))
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java(Compiled Code))
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:1198)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2400)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at com.deluxe.imax.dataaccess.impl.extended.TelevisionAssetCustomDAOImpl.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.ejb.TelevisionFacadeJBean.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.handler.TelevisionHandler.createWebElectronicTrailersAsset(Unknown Source)
at com.deluxe.imax.business.television.action.WebNewAction.processExecute(Unknown Source)
at com.deluxe.imax.business.framework.BaseAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1284)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1241)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:136)
at com.deluxe.imax.business.framework.security.SecurityFilter.doFilter(Unknown Source)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:121)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:82)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:671)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3003)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:221)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1958)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:88)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:472)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.ja
Please share your feedback.
Thanks in advance!
Edited by: Sanu Sasidharan on May 11, 2011 4:26 AMHi Peter,
We tried pointing to the same database from local as well as QA. Works from local but not from QA.
assetId is the generated primary key in the same method.
Yes the exception is thrown from execute statement itself. the logger put just after the execute is not coming.
This is the method
public boolean createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO, OracleConnection con) throws DAOException {
methodName ="createWebElectronicTrailersAsset(TelevisionResultDTO[] teleResultDTO,OracleConnection con) :: ";
//Value to be returned by method
boolean createInd = false;
OraclePreparedStatement psHighResObj = null;
OraclePreparedStatement psThumbnailObj = null;
OracleResultSet rsHighRes = null;
OracleResultSet rsThumbnail = null;
PreparedStatement psmt = null;
OraclePreparedStatement stmt1 = null;
OraclePreparedStatement stmt2 = null;
OrdImage highResImg = null;
OrdImage thumbnailImg = null;
ImaxGroupsTO groupsTO = null;
try {
long tvAssetId = 0;
long assetId = 0;
long cst_dwnld_asset_id = 0;
AssetCustomTO assetCustomTo = null;
AssetCustomDownloadTO assetCustDwnldTO = null;
CustomTVAssetTO tvAssetTo = null;
String DLX_ASSET_QRY = "";
String UPDATE_QRY = "";
String DLX_ASSET_TV_QRY = "";
String DLX_CUSTOM_DOWNLOAD_ASSET = "";
int k = 1;
for (int iCount = 0; iCount < teleResultDTO.length; iCount++) {
tvAssetId = (int) OraclePKGenerator.getInstance().getKey(InternalConstants.TV_ASSET_SEQUENCE);
assetId =(long) OraclePKGenerator.getInstance().getKey(InternalConstants.ASSET_SEQUENCE);
assetCustomTo = teleResultDTO[iCount].getAssetCustomTO();
tvAssetTo = teleResultDTO[iCount].getTv_Asset();
groupsTO= teleResultDTO[iCount].getGroupsTO();
if (assetCustomTo.getHighResolutionImageIn() != null) {
DLX_ASSET_QRY ="INSERT INTO DLX_ASSET("
+ "ASSET_ID,"
+ "CREATED_BY,"
+ "CREATED_DATE,"
+ "REVISED_BY,"
+ "REVISED_DATE,"
+ "FILE_NAME,"
+ "FILE_SIZE,"
+ "FILE_TYPE,"
+ "SYS_FILE_NAME,"
+ "HIGH_RES_IMAGE,"
+ "THUMBNAIL_IMAGE,"
+ "ASSET_STATUS_ID,"
+ "DMX_PART1_REF,"
+ "DMX_PRODUCT_ID_REF,"
+ "DMX_PRODUCT_DESC_REF,"
+ "ASSET_AVAIL_1_IND,"
+ "DMX_PART_2,"
+ "DMX_PRODUCT_2,"
+ "DMX_PRODUCT_DESC_2,"
+ "ASSET_AVAIL_2_IND,"
+ "EFFECTIVE_DATE,"
+ "EXPIRATION_DATE,"
+ "FILE_NAME1,"
+ "SYS_FILE_NAME1,"
+ "ASSET_TYPE_ID,"
+ "MATERIALS_CATEGORY,"
+ "PART_1_NOTES,"
+ "PART_2_NOTES,"
+ "PHY_ORDER_STATUS)"
+ "VALUES (?,?,SYSDATE,?,SYSDATE,?,?,?,?,ORDSYS.ORDImage.init(),"
+" ORDSYS.ORDImage.init(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
}else if(){
// condition if images are not uploaded
psmt = con.prepareStatement(DLX_ASSET_QRY);
k=1;
psmt.setLong(k++, assetId);
psmt.setString(k++, assetCustomTo.getCreated_by());
psmt.setString(k++, assetCustomTo.getRevised_by());
if(assetCustomTo.getAssetTextIn()!=null ){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
/* UPLOAD PREVIEW VIDEO FILE INTO FILE SYSTEM .....*/
Util.upLoadFile(assetCustomTo.getAssetTextIn(),assetCustomTo.getSys_file_name());
}else if(assetCustomTo.getAssetTextIn()==null && assetCustomTo.getSys_file_name() != null
&& assetCustomTo.getSys_file_name().trim().length() != 0){
psmt.setString(k++, assetCustomTo.getFile_name());
psmt.setString(k++, assetCustomTo.getFile_size());
psmt.setString(k++, assetCustomTo.getFile_type());
psmt.setString(k++, assetCustomTo.getSys_file_name());
} else{
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_status_id());
if(assetCustomTo.getDmx_product_desc_1()!=null && assetCustomTo.getDmx_product_desc_1().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_1());
psmt.setLong(k++, assetCustomTo.getDmx_productId_1());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_1());
psmt.setString(k++, assetCustomTo.getAsset_order_status_1());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_2()!=null && assetCustomTo.getDmx_product_desc_2().trim().length()!=0){
psmt.setLong(k++, assetCustomTo.getDmx_part_2());
psmt.setLong(k++, assetCustomTo.getDmx_productId_2());
psmt.setString(k++, assetCustomTo.getDmx_product_desc_2());
psmt.setString(k++, assetCustomTo.getAsset_order_status_2());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.INTEGER);
psmt.setNull(k++,Types.VARCHAR);
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getEffectiveDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getEffectiveDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
if(assetCustomTo.getExpirationDate()!=null){
psmt.setTimestamp(k++, assetCustomTo.getExpirationDate());
}else{
psmt.setNull(k++,Types.TIMESTAMP);
psmt.setString(k++, assetCustomTo.getHighresFileName());
if(assetCustomTo.getSys_file_name1()!=null && assetCustomTo.getSys_file_name1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getSys_file_name1());
}else{
psmt.setNull(k++, Types.VARCHAR);
psmt.setLong(k++, assetCustomTo.getAsset_type_id());
psmt.setLong(k++, assetCustomTo.getMaterialCategory());
if(assetCustomTo.getPart_notes_1()!=null && assetCustomTo.getPart_notes_1().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_1());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getPart_notes_2()!=null && assetCustomTo.getPart_notes_2().trim().length()!=0){
psmt.setString(k++, assetCustomTo.getPart_notes_2());
}else{
psmt.setNull(k++,Types.VARCHAR);
if(assetCustomTo.getDmx_product_desc_1()!=null){
psmt.setLong(k++,assetCustomTo.getPhy_asset_status());
}else{
psmt.setNull(k++,Types.INTEGER);
psmt.execute();
if (assetCustomTo.getHighResolutionImageIn() != null) {
/* UPDATE HIGH RESOLUTION IMAGE INTO DLX_ASSET TABLE */
logger.logInfo("inside IF condition ,,,,,,,,,,,"+assetId);
String query ="SELECT HIGH_RES_IMAGE FROM DLX_ASSET WHERE ASSET_ID ="+assetId+ " FOR UPDATE ";
psHighResObj =(OraclePreparedStatement) con.prepareStatement(query);
logger.logInfo("inside updating high res AFTER prepare statement"+psHighResObj);
rsHighRes = (OracleResultSet) psHighResObj.executeQuery();
while (rsHighRes.next()) {
highResImg =(OrdImage)rsHighRes.getCustomDatum(1,OrdImage.getFactory());
highResImg.loadDataFromInputStream(assetCustomTo.getHighResolutionImageIn());
assetCustomTo.getHighResolutionImageIn().close();
UPDATE_QRY = "UPDATE DLX_ASSET SET HIGH_RES_IMAGE = ? WHERE ASSET_ID=" + assetId;
stmt1 =(OraclePreparedStatement) con.prepareCall(UPDATE_QRY);
highResImg.setSource(assetCustomTo.getHighresFileType(),"",assetCustomTo.getSys_file_name1());
highResImg.setContentLength(Integer.parseInt(assetCustomTo.getHighresFileSize()));
highResImg.setProperties();
stmt1.setCustomDatum(1, highResImg);
stmt1.execute();
The connection in the method is passed from the service layer.
Thanks
Edited by: Sanu Sasidharan on May 12, 2011 2:30 AM -
ORA-01002 fetch out of sequence issue
Hi,
I am facing a weird ORA-01002 issue where I am passing the payload by opening a cursor to a separate package which has the merge statement. This fails with ORA-01002 error when there are multiple updates for a single record on target. I read through the Oracle documentation which states "MERGE is a deterministic statement. That is, you cannot update the same row of the target table multiple times in the same MERGE statement."
My use case is such that there can be multiple updates in a day for an account and I have to maintain history for this on the target and I have a merge to do this. I am implementing SCD using triggers. What do you guys suggest to implement this solution? I need to update the same target table record multiple times in the same MERGE statement.
Calling procedure:
declare
acct load_<package>.account_list;
begin
OPEN acct FOR
SELECT DISTINCT<cols>
FROM <table> where action_type='UPDATE' order by account_updatedate;
load_<package>.<proc>(acct);
CLOSE acct;
end;
Merge package/procedure:
PROCEDURE merge_<proc(acct IN account_list)
AS
BEGIN
MERGE INTO <target_table> d USING (
SELECT DISTINCT *
FROM TABLE(<pipelined_proc>(acct))
) s
ON (<condition>
WHEN NOT MATCHED THEN INSERT (
<cols>
) VALUES (
<cols> );
COMMIT;
END;
Thanks,
VikramThe thread title's ORA-01002: fetch out of sequence error is potentially from the merge statement restarting to get a consistent view of the data.
It looks like "acct" is a REF CURSOR. If the merge decides to restart, the cursor cannot be restarted, so you will get a ORA-01002: fetch out of sequence error. That's a problem with using a ref cursor inside a SQL statement that modifies data - the statement can restart.
E.g. see AskTom: Ask Tom &quot;BEFORE Triggers Fired Multiple Times &quot;
The current URL for the statement
If the triggering statement of a BEFORE statement trigger is an UPDATE or DELETE statement that conflicts with an UPDATE statement that is running, then the database does a transparent ROLLBACK to SAVEPOINT and restarts the triggering statement. The database can do this many times before the triggering statement completes successfully. Each time the database restarts the triggering statement, the trigger fires. The ROLLBACK to SAVEPOINTdoes not undo changes to package variables that the trigger references. To detect this situation, include a counter variable in the package.
is PL/SQL Triggers -
Error ORA-01002: fetch out of sequence
Hi all,
I created 3 cursors. The scenario is like following :
Begin Cur A
Begin FOR xx IN Cur B LOOP
Begin FOR xx IN Cur C LOOP
End LOOP Cur C;
commit;
End LOOP Cur B;
End Cur A;
When i run the program its display error ORA-01002: fetch out of sequence.
The objective of my program is to insert into table and commit every transaction.
Kindly share info with me why this error happened.
TQ.
timTim,
Refer to the following:
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.
HTH,
Thierry
Edited by: Thierry H. on May 4, 2011 12:30 PM Reformatting -
ProC code- error ORA-1002 fetch out of sequence
Hi,
we have an application currntly running on an HP UX system that uses Oracle 9i database.
the pro*C codes work fine with Oracle 9i, on the older system. however now we are migrating it to LINUX system (ORACLE 10g). in the new system we are facing issues with fetch statement
here is how we have the code:
the cursor statement:
EXEC SQL DECLARE diff_cns_list CURSOR FOR
select PREV.CNS_CODE,
PREV.CNS_DESCRIPTION,
PREV.CGP_CODE,
CURR.CNS_DESCRIPTION,
CURR.CGP_CODE
from NCIP_CNS_LIST PREV, NCIP_CNS_LIST CURR
where CURR.SAMPLE_DATE =
to_date('01' || :currdate || ' 00:00','ddyymm hh24:mi')
and PREV.SAMPLE_DATE =
to_date('01' || :prevdate || ' 00:00','ddyymm hh24:mi')
and PREV.CNS_CODE = CURR.CNS_CODE
and (PREV.CGP_CODE != CURR.CGP_CODE or
PREV.CNS_DESCRIPTION != CURR.CNS_DESCRIPTION);
======================
currdate=1106 (i.e. june 2011)
prevdate=1105 (i.e. may 2011)
======================
cursor is opened and then following fetch statement is run:
while( 1 )
exec sql FETCH diff_cns_list INTO :prev_vcns,
:prev_vdesc,
:prev_vcgp,
:curr_vdesc,
:curr_vcgp;
/* If no data found then exit from loop */
if( sqlca.sqlcode == 1403 )
break;
else if( sqlca.sqlcode != 0 )
vLOG_Msg(LOG_MSG_ERROR,"fniCmpNcipCnsList",
"ORACLE error on fetching diff_cns_list %s", sqlca.sqlerrm.sqlerrmc);
return( ERROR );
oravarterm( prev_vcns );
oravarterm( prev_vdesc );
oravarterm( prev_vcgp );
oravarterm( curr_vdesc );
oravarterm( curr_vcgp );
fprintf( output_fp,"'%s','%s','%s','%s','%s'\r\n",prev_vcns.arr,
prev_vdesc.arr,
prev_vcgp.arr,
curr_vdesc.arr,
curr_vcgp.arr);
the code runs fine in the old operating system (HP UX) where oracle 9i was used.
but fails in Oracle 10g(OS-LINUX).
the probable reason that we found out is that:
the fetch statement returns zero rows, that is the reason why this error is being displayed.
but Oracle 9i seemed to work out well with this.
we tried reducing the cursor conditions, where it fetches 3 rows. this is when is the fetch statement works fine.
the functionality of the code is that it should work fine even with no rows selected. Is there a way we can modfy the code to work with zero rows as well.
the error we are getting is : ORA-01002: fetch out of sequence
==========================
as per what is given in Oracle sites:
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.
========================
we have checked:
1>this is not the case and ORA-1403 not returned
2>No update statements involved , there is a insert statement which inserts data in this table
3>i am not clear with this one.
Could anyone please guide us through this, please?Note the name of this forum is SQL Developer (Not for general SQL/PLSQL questions) - so for issues with the SQL Developer tool. Please post these questions under the dedicated OCCI forum (you've posted there before).
Regards,
K. -
ORACLE 11g + PHP5 problem: "fetch out of sequence" on remote database link
Hi!
I have a new server with oracle 11g (11.1.0.7) database and apache/php5 (actual build) on linux.
connection type is dedicated.
when doing a connection to a remote AS/400 database I always get this error:
"Warning: oci_fetch_array() http://function.oci-fetch-array: ORA-01002: fetch out of sequence ORA-02063: preceding line from..."
when doing the same simple "select * from database link" at my old server with oracle 9i and apache/php5 no problem occurrs.
this happens at AS/400 database link only. normal oracle database links work fine.
Anyone an idea how to solve this problem or where the problem is????
further info:
when doing " select * from [ database link ] where rownum < 11 " it works, but when doing the query with more than 10 results I get the error. Any idea?
bye,
Oliver
Edited by: user501548 on 10.10.2008 02:20well a fetch out of sequence usually indicates that a cursor has been closed before the process has finished fetching or some such thing.
I'm not aware of there being a specific problem with the situation you outline, but maybe if you could provide all the connection setup and how you are trying to connect that may give a better idea.
Also, you may be better asking on the General Database Discussions forum as this isn't really a SQL or PL/SQL problem -
Oracle Report raises ORA-01002 Fetch out of sequence
ORA-01002 Fetch out of sequence in runtime execution of
oracle report 3.0 and 2.5 in client/server environment.
The same sql query works in sqlplus without any problem.
If I change the criteria (where clause) the error sometime
disappear. I can't explain this weird behaviour.
Oracle server version is 7.1.5 on Digital VMS.
Any Help will be welcome.
nullORA-01002 Fetch out of sequence in runtime execution of
oracle report 3.0 and 2.5 in client/server environment.
The same sql query works in sqlplus without any problem.
If I change the criteria (where clause) the error sometime
disappear. I can't explain this weird behaviour.
Oracle server version is 7.1.5 on Digital VMS.
Any Help will be welcome.
null
Maybe you are looking for
-
Maintaining formats(layouts) on Crystal report with different database
I was just needing some help maintaining the layout of a report but using a different database. The databases are very similar for example, a field for the database in use is line1xxxx what I wish to do is keep all the formating & point it line2xxxx
-
Hi Gurus.. In Billing Document Type thers a check box for in General Control for Posting Block. My Question is do we have to put the tick for Credit memo request.Coz in my organization some of the billing type which is std invoice has been block for
-
Don't like the update. There is a solution.
Call verizon. Have them forward you to motorola help line. Talk with someone that barely speaks english. (I'd bet their spanish isn't much better.) Tell them your having issues with it. You don't like it and want the older version back.They will tell
-
Open a doxc word document on a Mac OS 10.6.8
How can I open a Microsoft Word .docx document on my Mac with an older verision of Word?
-
Trying to get iCal to sync with iCloud on my mac
Hi there, I have a 2009 Macbook Pro running Yosemite. Since upgrading to mavericks, and subsequently Yosemite, I cannot get iCal to sync with the iCloud. All my calenders were sucked onto the cloud, and I can access them via my Iphone 5s and online,