Invalid Cursor, Please HEPL ME!!!!!!!
I see the following error:
ERROR at line 1:ORA-01001: invalid cursor
ORA-06512: at "SYS.DBMS_SYS_SQL", line 824ORA-06512: at "SYS.DBMS_SQL", line 32
ORA-06512: at "IWF_ADMIN.SP_ESTADISTICAS", line 38ORA-06512: at line 2
with the following code:
create or replace procedure SP_ESTADISTICASisc_idsite number;c_hora number;
c_dia number;c_fail number:=0;c_incomple number:=0;c_comple number:=0;
c_qnc number:=0;c_wap number:=0;c_fax number:=0;sumbusy number:=0;
c_busy number:=0;sumtime number:=0;sumin number:=0;sumout number:=0;
fechai date;Temp varchar2(20);fechac varchar2(20);--fechac date;
fechaf date;--cursor cursor_est return (idsite tablecall.idsite%typefecha
tablecall.fecha%type, bytein tablecall.bytein%type, typecall
tablecall.typecall%type, num_busych tablecall.num_busych%type, tiempoconec
tablecall.tiempoconec%type);cursor_est tablecall2%ROWTYPE;fdbk INTEGER;
cur INTEGER := DBMS_SQL.OPEN_CURSOR;v_select varchar2(200);begin
select concat(to_char(min(fecha),'dd/mm/yyyy'),' ') into Temp from tablecall2;
for cur_idsite in (select distinct(idsite) as idsite from tablecall2) loop
for c_dia in 0..31 loop fechai:=to_date(Temp,'dd/mm/yyyy');
fechai:=fechai + c_dia; for c_hora in 0..23 loop
-- fechac:=to_date(Temp| |to_char(c_hora,'fm09')| |':00:00');
fechac:=Temp| |to_char(c_hora,'fm09');
-- fechaf:=to_date(Temp| |to_char(c_hora,'fm09')| |':59:59');
v_select:='select idsite,fecha,bytein,typecall,num_busych,tiempoconec
from tablecall2 where idsite ='| |to_char(cur_idsite.idsite,'fm0999')| |' and
to_char(fecha,'| |chr(39)| |'dd/mm/yyyy hh24:mi:ss'| |chr(39)| |') like
'| |chr(39)| |fechac| |'%'| |chr(39);
DBMS_SQL.PARSE(cur,v_select,DBMS_SQL.NATIVE);
DBMS_SQL.DEFINE_COLUMN(cur, 1, 1);
DBMS_SQL.DEFINE_COLUMN(cur, 2, sysdate);
DBMS_SQL.DEFINE_COLUMN(cur, 3, 1); DBMS_SQL.DEFINE_COLUMN(cur, 4, 1);
DBMS_SQL.DEFINE_COLUMN(cur, 5, 1); DBMS_SQL.DEFINE_COLUMN(cur, 6, 1);
fdbk := DBMS_SQL.EXECUTE(cur); LOOP
EXIT WHEN DBMS_SQL.FETCH_ROWS(cur) = 0;
DBMS_SQL.COLUMN_VALUE(cur,1,cursor_est.idsite);
DBMS_SQL.COLUMN_VALUE(cur,2,cursor_est.fecha);
DBMS_SQL.COLUMN_VALUE(cur,3,cursor_est.bytein);
DBMS_SQL.COLUMN_VALUE(cur,4,cursor_est.typecall);
DBMS_SQL.COLUMN_VALUE(cur,5,cursor_est.num_busych);
DBMS_SQL.COLUMN_VALUE(cur,6,cursor_est.tiempoconec);
if cursor_est.bytein=0 then c_fail:=c_fail+1; end if;
if cursor_est.bytein<125 then c_incomple:=c_incomple+1; end if;
if cursor_est.bytein>125 then c_comple:=c_comple+1; end if;
if cursor_est.typecall=2 then c_fax:=c_fax+1; end if;
if cursor_est.typecall=1 then c_qnc:=c_qnc+1; end if;
if cursor_est.typecall=0 then c_wap:=c_wap+1; end if; c_busy:=c_busy+1;
sumbusy:=cursor_est.num_busych + sumbusy;
sumtime:=cursor_est.tiempoconec + sumtime; sumin:=cursor_est.bytein + sumin;
sumout:=cursor_est.byteout + sumout; END LOOP; if c_busy<>0 then
sumbusy:=sumbusy/c_busy; else sumbusy:=0; end if;
execute immediate 'insert into tableest
values('| |to_char(cur_idsite.idsite,'fm0999')| |',
to_date(concat('| |chr(39)| |fechac| |chr(39)| |','| |chr(39)| |':00:00'| |chr(39)| |'),'| |chr(39)| |'dd/mm/yyyy
HH24:mi:ss'| |chr(39)| |'),'| |to_char(c_fail,'fm0999999999')| |','| |to_char(c_incomple,'fm0999999999')| |','| |to_char(c_comple,'fm0999999999')| |','| |to_char(c_wap,'fm0999999999')| |','| |to_char(c_qnc,'fm0999999999')| |','| |to_char(c_fax,'fm0999999999')| |','| |to_char(sumbusy,'fm0999999999')| |','| |to_char(sumtime,'fm0999999999')| |','| |to_char(su min,'fm0999999999')| | ','| |to_char(sumout,'fm0999999999')| |')';
commit; execute immediate 'delete from tablecall2 where
idsite='| |to_char(cur_idsite.idsite,'fm0999')| |' and
to_char(fecha,'| |chr(39)| |'dd/mm/yyyy HH24:mi:ss'| |chr(39)| |') like
'| |chr(39)| |fechac| |'%'| |chr(39);-- commit;
DBMS_SQL.CLOSE_CURSOR (cur); end loop; end loop;end loop;
end;
what is happening it?, how can to resolve it?
Thank by any idea.
null
It is very difficult to read. However, the previous reply is correct you have closed the cursor inside the loop.
Also, hoping you will take this as a suggestion, I have modified the proc to utilize 8i features and get rid of the DBMS_SQL utility (to much coding) and the CHR(39)
I would have written this in spanish but my ability to write in spanish is shamefull, but
BUENA SUERTE CON TU PROJECTO.
create or replace procedure SP_ESTADISTIC AS
c_dia number;
c_fail number:=0;
c_incomple number:=0;
c_comple number:=0;
c_qnc number:=0;
c_wap number:=0;
c_fax number:=0;
c_busy number:=0;
sumbusy number:=0;
sumtime number:=0;
sumin number:=0;
sumout number:=0;
fechai date;
Temp varchar2(20);
fechac varchar2(20);
TYPE REF_CUR IS REF CURSOR ;
CV REF_CUR ;
v_sql_stmt varchar2(2000);
TYPE CUR_REC IS RECORD
(idsite tablecall.idsite%type,
fecha tablecall.fecha%type,
bytein tablecall.bytein%type,
typecall tablecall.typecall%type,
num_busych tablecall.num_busych%type,
tiempoconec tablecall.tiempoconec%type);
CUR_DATA CUR_REC ;
BEGIN
select concat(to_char(min(fecha),'dd/mm/yyyy'),' ') into Temp from tablecall2;
for cur_idsite in (select distinct(idsite) as idsite from tablecall2) loop
for c_dia in 0..31 loop
fechai:=to_date(Temp,'dd/mm/yyyy');
fechai:=fechai + c_dia;
for c_hora in 0..23 loop
fechac := Temp| |to_char(c_hora,'fm09');
V_SQL_STMT :='select idsite, fecha, bytein, typecall, num_busych, tiempoconec '| |
' from tablecall2 where idsite = '| |
to_char(cur_idsite.idsite, 'fm0999') | |
' and to_char(fecha, ''dd/mm/yyyy hh24:mi:ss'' ) '| |
' like '''| | fechac | | '%'' ';
OPEN CV FOR v_sql_stmt ;
LOOP
FETCH CV INTO CUR_DATA ;
EXIT WHEN CV%NOTFOUND;
if CUR_DATA.bytein=0 then c_fail:=c_fail+1; end if;
if CUR_DATA.bytein<125 then c_incomple:=c_incomple+1; end if;
if CUR_DATA.bytein>125 then c_comple:=c_comple+1; end if;
if CUR_DATA.typecall=2 then c_fax:=c_fax+1; end if;
if CUR_DATA.typecall=1 then c_qnc:=c_qnc+1; end if;
if CUR_DATA.typecall=0 then c_wap:=c_wap+1; end if;
c_busy:=c_busy+1;
sumbusy := CUR_DATA.num_busych + sumbusy;
sumtime := CUR_DATA.tiempoconec + sumtime;
sumin := CUR_DATA.bytein + sumin;
-- sumout:=CUR_DATA.byteout + sumout;
END LOOP;
if c_busy<>0 then
sumbusy:=sumbusy/c_busy;
else
sumbusy:=0;
end if;
v_sql_stmt := 'insert into tableest '| |
' values(:1, :2, :3, :4, :5, :6, '| |
':7, :8, :9, :10, :11, :12 ) ' ;
execute immediate v_sql_stmt using
to_char(CUR_DATA.idsite,'fm0999'),
to_date(fechac| |':00:00', 'dd/mm/yyyyHH24:mi:ss'),
to_char(c_fail, 'fm0999999999'),
to_char(c_incomple,'fm0999999999'),
to_char(c_comple, 'fm0999999999'),
to_char(c_wap, 'fm0999999999'),
to_char(c_qnc, 'fm0999999999'),
to_char(c_fax, 'fm0999999999'),
to_char(sumbusy, 'fm0999999999'),
to_char(sumtime, 'fm0999999999'),
to_char(sumin, 'fm0999999999') ,
to_char(sumout, 'fm0999999999') ;
execute immediate
'delete from tablecall2 where idsite='
| |to_char(cur_idsite.idsite,'fm0999')
| |' and to_char(fecha,''dd/mm/yyyy HH24:mi:ss'' ) '
| |' like '''| | fechac | | '%'' ';
commit;
end loop;
close CV;
end loop;
end loop;
end;
Similar Messages
-
Invalid Cursor state Exception - Help required
Hi,
I'm having a web page(JSP), which is making use of 3 ResultSet objects. Using the first two, i'll populate two different Drop down list, with values from database(Access) while loading the page for first time.
Now if the user select any value from any (or both) of drop down list and clicks submit, i need to display all values in database, meeting the criteria from first & second drop down list. For this selection, i'm using the third ResultSet variable. While executing the query, i'm sure that 3rd ResultSet is returning some value. But when i try to retrieve the value to a string variable, i'm getting the Invalid cursor state exception.
Throughout the page, i haven't closed any of the ResultSet. When i closed the first and second ResultSets in the third function(where 3rd ResultSet is used), i'm not getting any value. Its returning like ResultSet closed.
Please help me to get this solved. It's very urgent because without this, i cannot proceed further. Please share your ideas.
Thanks in advace for your valuable helpIf you open a new resultset within the same statement, all previously opened will be closed.
Read the API docs, luke. -
Database selection with invalid cursor !
hi experts,
When execute SAP BW processchar, it occur some system error: (sm21)
Database selection with invalid cursor
The database interface was called by a cursor (in a FETCH or CLOSE
cursor operation) that is not flagged as opened. This can occur if a
COMMIT or ROLLBACK was executed within a SELECT loop (which closes all
opened cursors), followed by another attempt to access the cursor (for
example, the next time the loop is executed).
this error occur when apply bw support package 19.
sap notes 1118584 Solution is: Import Support Package 17 . but my support package is 19.
how can i solve this error?
thanks,
xwu.I am only assuming things, but it might be worth to look closely if you were experiencing an ORA- error during the execution. This could have caused a rollback and thus closed the cursor. Please check the job log, the workprocess trace (dev_wX file) and the system log SM21 and ST22 as well.
Besides that check the oracle alertlog and the usertrace destination.
Best regards, Michael -
From Last 4 hours I am trying to resolve below issue.
Please Please.......Please Help me out.
Not getting that what is the problem ???? every thing is alright, why the error is comming on different database.
SQL*Plus: Release 10.1.0.2.0 - Production on Wed Jul 25 11:57:49 2007
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning and OLAP options
JServer Release 9.2.0.6.0 - Production
SQL> select * from v$version
2 /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
SQL>
SQL> SELECT * FROM GLOBAL_NAME
2 /
GLOBAL_NAME
PNRDPD
SQL>
SQL> CREATE OR REPLACE PACKAGE ORAPDEV_PKG IS
2 PROCEDURE DUAL_DATA(P_DEPTNO IN NUMBER, RESULTSET IN OUT SYS_REFCURSOR);
3 END ORAPDEV_PKG;
4 /
Package created.
SQL>
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY ORAPDEV_PKG IS
2 PROCEDURE DUAL_DATA(P_DEPTNO IN NUMBER, RESULTSET IN OUT SYS_REFCURSOR) IS
3 BEGIN
4 OPEN RESULTSET FOR 'SELECT EMPNO FROM SCOTT.EMP WHERE DEPTNO = '||P_DEPTNO;
5 END;
6 END ORAPDEV_PKG;
7 /
Package body created.
SQL>
SQL>
SQL> VARIABLE DTA REFCURSOR;
SQL> EXEC ORAPDEV_PKG.DUAL_DATA(10,:DTA);
PL/SQL procedure successfully completed.
SQL> PRINT DTA
EMPNO
7782
7839
7934
SQL>
SQL>
SQL>
SQL> GRANT EXECUTE ON ORAPDEV_PKG TO PUBLIC;
Grant succeeded.
SQL> New Session of Another Database
SQL> CONNECT XXX/XXX@CISDPD
Connected.
SQL> create public database link PNRAPD connect to xxx identified by xxx using 'pnrapd';
Database link created.
SQL> SELECT COUNT(*) FROM ALL_TABLES@PNRAPD
2 /
COUNT(*)
722
SQL>
SQL> CREATE PUBLIC SYNONYM ORAPDEV_PKG FOR ORAPDEV_PKG@PNRAPD;
Synonym created.
SQL>
SQL> VARIABLE DTA REFCURSOR;
SQL> EXEC ORAPDEV_PKG.DUAL_DATA(10,:DTA);
BEGIN ORAPDEV_PKG.DUAL_DATA(10,:DTA); END;
ERROR at line 1:
ORA-01001: invalid cursor
ORA-02063: preceding line from PNRAPD
SQL>
SQL>
SQL> SELECT * FROM GLOBAL_NAME;
GLOBAL_NAME
CISDPD
SQL>
SQL> EXEC ORAPDEV_PKG.DUAL_DATA@pnrapd(10,:DTA);
BEGIN ORAPDEV_PKG.DUAL_DATA@pnrapd(10,:DTA); END;
ERROR at line 1:
ORA-01001: invalid cursor
ORA-02063: preceding line from PNRAPD
SQL> SELECT COUNT(*) FROM ALL_TABLES@PNRAPD
2 /
COUNT(*)
722
SQL>
SQL> select * from v$version
2 /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for Linux: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
SQL>again.....:(
how can I resolve this issue ??
PNRAPD DATABASE
CREATE OR REPLACE PACKAGE orapdev_pkg IS
TYPE rcursor IS REF CURSOR;
PROCEDURE dual_data(p_deptno IN NUMBER
,resultset IN OUT rcursor);
END orapdev_pkg;
CREATE OR REPLACE PACKAGE BODY orapdev_pkg IS
PROCEDURE dual_data(p_deptno IN NUMBER
,resultset IN OUT rcursor) IS
BEGIN
OPEN resultset FOR 'SELECT EMPNO FROM SCOTT.EMP WHERE DEPTNO = ' || p_deptno;
END;
END orapdev_pkg;
CISDPD DATABASE
SQL> var dta ORAPDEV_PKG.RCURSOR;
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
BINARY_FLOAT | BINARY_DOUBLE ] ]
SQL>
SQL>
SQL>
SQL> declare
2 vempno scott.emp.empno@pnrapd%type;
3 DTA ORAPDEV_PKG.RCURSOR;
4 begin
5 ORAPDEV_PKG.DUAL_DATA(10,DTA);
6 LOOP
7 FETCH DTA
8 INTO vempno;
9 EXIT WHEN dta%NOTFOUND;
10 DBMS_OUTPUT.PUT_LINE(vempno);
11 END LOOP;
12 CLOSE dta;
13 end;
14 /
declare
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at line 7Please help. -
ORA-01001: invalid cursor
I have the below code I am trying to execute and get the error ORA-01001: invalid cursor
create or replace PROCEDURE TESTUPDATE(pNAME VARCHAR2,pID NUMBER) IS
CN NUMBER;
CURSOR C1 IS
SELECT CODE,SOPTION,SFILE
STREET1,
STREET2
FROM TABLE1
WHERE CODE = '10';
CURSOR C2 IS
SELECT CODE,
STREET1,
STREET2
FROM TABLE2
WHERE CODE = '10;
C1_REC C1%rowtype;
C2_REC C2%rowtype;
BEGIN
OPEN C1;
FETCH C1 INTO C1_REC;
SELECT COUNT(*) INTO CN FROM TABLE2
WHERE code = '10'
IF ( C1_REC.SOPTION = 'C' ) THEN --- SOPTION is 'C"
IF (CN = 0) THEN
IF (C1_REC.SFILE = 'FILE') THEN
INSERT INTO TABLE2(ASSIGNED) VALUES('Y');
ELSE
INSERT INTO TABLE2(ASSIGNED) VALUES('N');
END IF;
ELSE /* CN > 0 */
OPEN C2;
FETCH C2 INTO C2_REC;
IF (C1_REC.SFILE = 'FILE') THEN
IF ( C1_REC.STREET1 IS NOT NULL OR
C1_REC.STREET2 IS NOT NULL ) AND
( C1_REC.STREET1 != C2_REC.STREET1 OR
C1_REC.STREET2 != C2_REC.STREET2) THEN
UPDATE TABLE2
SET ASSIGNED = 'I';
END IF;
ELSE /*IS NOT EQUAL TO 'FILE'*/
IF ( C1_REC.STREET1 IS NOT NULL OR
C1_REC.STREET2 IS NOT NULL ) AND
( C1_REC.STREET1 != C2_REC.STREET2 OR
C1_REC.STREET2 != C2_REC.STREET2) THEN
UPDATE TABLE2
SET TABLE2_status_ind = 'N';
END IF;
END IF;
END IF;
ELSIF ( C1_REC.SOPTION = 'CR' ) THEN /*SOPTION is 'CR"*/
IF (CN = 0) THEN
IF (C1_REC.SFILE = 'FILE') THEN
INSERT INTO TABLE2(ASSIGNED) VALUES('Y');
ELSE
INSERT INTO TABLE2(ASSIGNED) VALUES('N');
END IF;
ELSE /* CN > 0*/
OPEN C2;
FETCH C2 INTO C2_REC;
IF (C1_REC.SFILE = 'FILE') THEN
IF ( C1_REC.STREET1 IS NOT NULL OR
C1_REC.STREET2 IS NOT NULL ) AND
( C1_REC.STREET1 != C2_REC.STREET2 OR
C1_REC.STREET2 != C2_REC.STREET2) THEN
UPDATE TABLE2
SET TABLE2_status_ind = 'I';
END IF;
ELSE /* IS NOT EQUAL TO 'FILE'*/
IF ( C1_REC.STREET1 IS NOT NULL OR
C1_REC.STREET2 IS NOT NULL ) AND
( C1_REC.STREET1 != C2_REC.STREET2 OR
C1_REC.STREET2 != C2_REC.STREET2) THEN
UPDATE TABLE2
SET TABLE2_status_ind = 'I';
END IF;
END IF;
END IF;
END IF;
CLOSE C1;
CLOSE C2;
END IF;
EXCEPTION WHEN NO_DATA_FOUND THEN
dbms_output.put_line('e1');
CLOSE C1;
WHEN OTHERS THEN
CLOSE C1;
dbms_output.put_line('e2');
END;when I have the soption as CR and cn=0, I get the error invalid cursor. Please help me with changes to the code to overcome this error
thanks
Edited by: 890563 on 14 Nov, 2012 5:37 AM
Edited by: BluShadow on 14-Nov-2012 13:39
added {noformat}{noformat} tags to make code readable. After 48 questions (of which you still have 40 unanswered for some reason?) and a year on the forums, we would expect you to have learnt how to ask questions... but just in case you missed it... read here: {message:id=9360002}I am sorry for posting such confusing code. I changed the last part of code code to
END IF;
END IF;
CLOSE C1;
CLOSE C2;
END IF;
END IF;
EXCEPTION WHEN NO_DATA_FOUND THEN
dbms_output.put_line('e1');
CLOSE C1;
WHEN OTHERS THEN
CLOSE C1;
dbms_output.put_line('e2');
END;
and it worked with out errors
Thanks -
Java.sql.SQLException: Invalid cursor position on saving
Dear all
I'm having a problem with saving components on a JSF page. The page is plit in two parts:
1. Save report details, which are being saved correctly. Here is the code
public String btnSaveReport_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
System.out.println("Saving the report ... forsi");
int seqNumber = SequenceNumber.getNextSequenceNo("TB_REPORTS");
getSessionBean1().setReportFK(seqNumber);
String reportId = "REP_" + ((String)tfReportName.getText()).replace(' ', '_').trim();
System.out.println("ReportFK in btnSaveReport: " + getSessionBean1().getReportFK());
//SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
System.out.println("Start Date: " + calRepStartDate.getSelectedDate());
//error(calRepStartDate.getValue().toString());
//System.out.println("getvalue" + calRepStartDate.getValue());
try {
rk = tb_reportsDataProvider.appendRow();
tb_reportsDataProvider.setCursorRow(rk);
System.out.println("Setting Values ...");
tb_reportsDataProvider.setValue("REP_PK", new Integer(seqNumber));
tb_reportsDataProvider.setValue("REP_ID", reportId);
tb_reportsDataProvider.setValue("REP_ACTIVE", "Y");
tb_reportsDataProvider.setValue("REP_SESSION_FK", new Integer(getSessionBean1().getSessionId()));
tb_reportsDataProvider.setValue("REP_NAME", (String)tfReportName.getText());
tb_reportsDataProvider.setValue("REP_START_DATE", new java.sql.Date(calRepStartDate.getSelectedDate().getTime()));
tb_reportsDataProvider.setValue("REP_END_DATE", new java.sql.Date(calRepEndDate.getSelectedDate().getTime()));
System.out.println("Committing Changes ...");
tb_reportsDataProvider.commitChanges();
System.out.println("Refreshing Row ...");
tb_reportsDataProvider.getCachedRowSet().refreshRow();
getSessionBean1().getTb_reportsRowSet().refreshRow();
// tb_reportsDataProvider.refresh();
// System.out.println("Refreshing Row ...");
// tb_reportsDataProvider.setCursorRow(tb_reportsDataProvider.findFirst("REP_PK",new Integer(seqNumber)));
info("Report Data Saved Successfully!");
} catch (SQLException sqle) {
/* error("Cannot update report (SQLException): " +
reportId +
" : " + sqle.getMessage()); */
log("Cannot update report (SQLException): " +
reportId +
" : " + sqle);
info("Could not save report: " + sqle.getMessage());
sqle.printStackTrace();
//tfReportName.setValueBinding("sourceData", getApplication().
// createValueBinding("#{newReport.tb_reportsDataProvider}"));
//tfReportName.setValueBinding("text", getApplication().createValueBinding ("#{newReport.tb_reportsDataProvider.value['REP_NAME']}"));
// calRepStartDate.setValueBinding("sourceData", getApplication().
// createValueBinding("#{newReport.tb_reportsDataProvider}"));
//calRepStartDate.setValueBinding("selectedDate", getApplication().createValueBinding ("#{newReport.tb_reportsDataProvider.value['REP_START_DATE']}"));
//calRepEndDate.setValueBinding("sourceData", getApplication().
// createValueBinding("#{newReport.tb_reportsDataProvider}"));
//calRepEndDate.setValueBinding("selectedDate", getApplication().createValueBinding ("#{newReport.tb_reportsDataProvider.value['REP_END_DATE']}"));
info("Report Name: " + tb_reportsDataProvider.getValue("REP_NAME"));
tfReportName.validate(this.getFacesContext());
calRepStartDate.validate(this.getFacesContext());
calRepEndDate.validate(this.getFacesContext());
tfReportName.setDisabled(true);
calRepStartDate.setDisabled(true);
calRepEndDate.setDisabled(true);
btnNewQuery.setDisabled(false);
btnSaveReport.setDisabled(true);
return null;
}The problem is that the reportFK is losing its value when I submit the page the second time! I am trying to get the value from the provider or from the rowset, but none work. Here is the code I am trying ...
public String btnSaveQuery_action() {
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
int seqNumber = 0;
// Save the query header details to the database
try {
// Start with the query - needed for the link table
seqNumber = SequenceNumber.getNextSequenceNo("TB_QUERY");
String queryId = "QRY_" + ((String)tfQueryName.getText()).replace(' ', '_').trim();
tb_queryDataProvider.setCursorRow(queryRowKey);
tb_queryDataProvider.setValue("QRY_PK", new BigDecimal(seqNumber));
tb_queryDataProvider.setValue("QRY_CODE", queryId);
tb_queryDataProvider.setValue("QRY_NAME", (String)tfQueryName.getText());
tb_queryDataProvider.setValue("QRY_ACTIVE", "Y");
tb_queryDataProvider.setValue("QRY_SESS_FK", new BigDecimal(getSessionBean1().getSessionId()));
System.out.println("Committing Changes ...");
tb_queryDataProvider.commitChanges();
System.out.println("Refreshing Row ...");
tb_queryDataProvider.setCursorRow(tb_queryDataProvider.findFirst("QRY_PK",new Integer(seqNumber)));
getSessionBean1().getTb_queryRowSet().refreshRow();
info("Query Data Saved Successfully!");
} catch (Exception ex) {
error("Error while saving query: " + ex.getMessage());
log("Error while saving query" + ex);
ex.printStackTrace();
// Now save the link
try {
// Start with the query - needed for the link table
String sql = "INSERT INTO TB_LINK_REPORT_QUERY ( " +
"LRQ_PK, LRQ_REP_FK, LRQ_QRY_FK, " +
"LRQ_TYPE, LRQ_START_DATE, LRQ_END_DATE, " +
"LRQ_ACTIVE, LRQ_SESS_FK) " +
"VALUES (?,?,?,?,?,?,?,?)";
System.out.println("Trying to do the link");
int linkSeqNumber = SequenceNumber.getNextSequenceNo("TB_LINK_REPORT_QUERY");
PreparedStatement pstmt = DBConnection.getConnection().prepareStatement(sql);
if (getSessionBean1().getReportFK() == -1 || getSessionBean1().getReportFK() == 0)
System.out.println("reportFK = -1 or 0!!! Trying from provider.");
System.out.println("Report PK is: " + getSessionBean1().getTb_reportsRowSet().getBigDecimal("REP_PK"));
getSessionBean1().setReportFK(((Integer)tb_reportsDataProvider.getValue("REP_PK")).intValue());
System.out.println("Report Foreign Key: " + getSessionBean1().getReportFK());
System.out.println("Query Foreign Key: " + seqNumber);
pstmt.setInt(1, linkSeqNumber);
pstmt.setInt(2, getSessionBean1().getReportFK());
pstmt.setInt(3, seqNumber);
pstmt.setString(4, (String)dropDownQueryType.getSelected());
pstmt.setDate(5, new java.sql.Date(calendarQueryStartDate.getSelectedDate().getTime()));
pstmt.setDate(6, new java.sql.Date(calendarQueryEnd.getSelectedDate().getTime()));
pstmt.setString(7, "Y");
pstmt.setInt(8, getSessionBean1().getSessionId());
System.out.println("Committing Changes for Link ...");
pstmt.executeUpdate();
DBConnection.getConnection().commit();
System.out.println("Refreshing Row in link ...");
getSessionBean1().getTb_link_report_queryRowSet().setObject(
1, new Integer(linkSeqNumber));
getSessionBean1().getTb_link_report_queryRowSet().setObject(
2, new Integer(getSessionBean1().getReportFK()));
getSessionBean1().getTb_link_report_queryRowSet().setObject(
3, calendarQueryStartDate.getSelectedDate());
getSessionBean1().getTb_link_report_queryRowSet().setObject(
4, calendarQueryEnd.getSelectedDate());
tb_link_report_queryDataProvider.refresh();
info("Link Data Saved Successfully!");
} catch (Exception ex) {
error("Error while saving query: " + ex.getMessage());
log("Error while saving link: " + ex);
ex.printStackTrace();
return null;
}The part saving the query with the provider is working correctly. But the part with the link is not working at all (the part with the PreparedStatement). The fact is that the PreparedStatement cannot be executed because I am getting the error at the line
System.out.println("Report PK is: " + getSessionBean1().getTb_reportsRowSet().getBigDecimal("REP_PK"));Can anyone help please?
Thanks and Regards
Josephguys if any of you have an idea just post it. It would be of great help for me. I can't figure out my mistake and its been 2days already and still i am stuck with my problem.
It displays the table but there is an error "java.sql.SQLException: Invalid cursor position" so i cannot put the counter to the session. -
Invalid Cursor Position Error on Windows XP using CachedRowSet
Hello, I don't know if this question lies here, but I thought it would be the well suited place so please pardon me if it isn't. I am trying to access multiple pages from my database on my XP machine but I am getting an "invalid cursor position" error when trying to access the next page. I don't know how this error is coming about because it works well on a Vista machine with no errors. I don't know if it is my drivers or something that brings about the problem. I am using mysql connecter 5.1.10, JRE 1.6.0_02 and windows XP SP2
Below is a simple code that brings the error.
package Admin; import javax.sql.rowset.CachedRowSet; import com.sun.rowset.CachedRowSetImpl; public class test { public void table() { try { CachedRowSet crs=new CachedRowSetImpl(); crs.setUrl("jdbc:mysql://host:3306/database"); crs.setUsername("User"); crs.setPassword("password"); crs.setCommand("select * from myTable"); int[] keys = {1}; crs.setKeyColumns(keys); crs.execute(); crs.last(); if(crs.getRow()>500){ //new overLimit(); } crs.setPageSize(3); crs.execute(); while (crs.next()) { System.out.print("page one----"); System.out.println(crs.getString(1)); } while(crs.nextPage()){ System.out.println("page two---"); while (crs.next()) { System.out.println("in page two"); System.out.println(crs.getString(1)); } } } catch (Exception e) { e.printStackTrace(); } } public static void main(String []args){ new test().table(); } }Yes I am running the same code on both machines. The output I get on the XP machine is shown below. I modified the code I posted earlier and replaced the "page two" text with "page (then page number)" and also omitted the "in page two" text for better readability---------PAGE 0---------
DB09140110
DU35463010
EX29201810
---------PAGE 1---------
EX38341510
EX40471810
KZ280299
----------PAGE 2---------
LA130299
LC130299
MC081009
----------PAGE 3---------
RZ300502
VA130299
VI020209
----------PAGE 4---------
YX101008
ZE220299
ZF231105and vista....
----------PAGE 0---------
EX38341510
EX40471810
KZ280299
----------PAGE 1---------
LA130299
LC130299
MC081009
----------PAGE 2---------
RZ300502
VA130299
VI020209
----------PAGE 3---------
YX101008
ZE220299
ZF231105 -
SQLException, invalid cursor state
Came across the weirdest thing... Suppose i use this statement in a servlet:
ResultSet result = statement.executeQuery("SELECT City FROM Destinations");and the following code in the JSP to which the browser is redirected:
<select name="selectedCity" value="" size="1">
<% ResultSet result = (ResultSet) session.getAttribute("rstCity");
while (result.next()) { %>
<option><%= result.getString(1) %>
<% } %>
</select>This works properly in my case. (Don't think other code is necessary to provide... please tell me you think it is..)
But because result is full of duplicate rows, i want to change the line into:
ResultSet result = statement.executeQuery("SELECT DISTINCT City FROM Destinations");A ServletException and SQLException message in the browser (at index.jsp, not servlet/servletname!) both say [Micrisoft][ODBC Driver Manager]Invalid Cursor State...
Now if i (temporarily) remove the expression <%= result.getString(1) %> in the JSP file, the error no longer appears. Ofcourse the listbox <select> is now filled with about 100 empty <option>s...
I can't locate the problem this way, can't see any logic in this. It seems like by adding DISTINCT in the SQL statement, the JSP file cannot handle the getString function anymore.
Can anyone help me with this invalid cursor state thing?
Thanks!!Peter,
I'm getting the same problem with this:
String sql = "SELECT DISTINCTROW collectedwho FROM steps WHERE status = 'overdue finish' AND escalatedwho = " + util.sqlEsc(username) + " ORDER BY collectedwho";
recordset rs = new recordset();
rs.open(sql);
while (rs.rs.next()) {
accountable = rs.rs.getString("collectedwho");
(recordset is simply my own wrapper for the ResultSet class, which hides the db connection string and saves me rewriting it every time)
What happens is that the loop falls off the end of the resultset but thinks that it hasn't, ie rs.next() returns true, but there's no data when it gets to the getString and it throws an "Invalid cursor state".
Bummer.
I'm using the JDBC:ODBC bridge to an access database, by the way.
I tried changing DISTINCT to to DISTINCTROW which then worked with no errors but of course gave me the wrong results in the ResultSet!
Is this a bug in the bridge, or in the ResultSet class?
Sorry this isn't much help but at least you know you're not the only one!
David -
Oracle 10g EE Export Results in ORA-01001: invalid cursor Error
Hi,
I'm quite new to Oracle 10g and OCS10g. We have a crippled/corrupt SYSAUX tablespace (data file 3) which cannot be recovered using recover
command anymore. So metalink support instructed us to do a export of the metadata of the working tablespace which contains our system data (we are in configuration stage for OCS 10g 10.1.2) via transportable tablespaces so that I can just recreate the database in DBCA and import the metadata. So after I made a cold backup, set the "transportable" tablespaces to "READ ONLY" mode, I proceeded w/ the export command which resulted in an error, please see below:
$exp \'sys/********@ocs10gSID as sysdba\' parfile=transport.par
Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.4.2 -
Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
EXP-00008: ORACLE error 1001 encountered
ORA-01001: invalid cursor
ORA-06512: at "SYS.DBMS_SYS_SQL", line 899
ORA-06512: at "SYS.DBMS_SQL", line 19
ORA-06512: at "SYS.DBMS_TTS", line 811
ORA-00376: file 3 cannot be read at this time
ORA-01110: data file 3: '/ocfs/oradata/OCS/datafile/o1_mf_sysaux_2mgzbr51_.dbf'
ORA-06512: at "SYS.DBMS_PLUGTS", line 1444
ORA-06512: at line 1
Anyone encountered this problem before? Any recommendations or tips to get this working?
I checked this url:"http://luhartma.blogspot.com/2006/05/how-to-check-if-tablespace-is.html"
And when I try to follow the instructions and check on of the tablespace I set to and verified to be in "READ ONLY" mode, I get the same error.
SQL> connect / as sysdba
Connected.
SQL> exec dbms_tts.TRANSPORT_SET_CHECK('PORTAL',TRUE)
BEGIN dbms_tts.TRANSPORT_SET_CHECK('PORTAL',TRUE); END;
ERROR at line 1:
ORA-01001: invalid cursor
ORA-06512: at "SYS.DBMS_SYS_SQL", line 899
ORA-06512: at "SYS.DBMS_SQL", line 19
ORA-06512: at "SYS.DBMS_TTS", line 811
ORA-00376: file 3 cannot be read at this time
ORA-01110: data file 3: '/ocfs/oradata/OCS/datafile/o1_mf_sysaux_2mgzbr51_.dbf'
ORA-06512: at "SYS.DBMS_TTS", line 840
ORA-06512: at line 1
Hope someone can help on this or at least provide a suggestion. Data file 3 above is the reason we are doing a transportable tablespace export & db recreation.
BTW what we have is:
OCS 10g 10.1.2 w/ Oracle RDBMS 10g Enterprise Edition 10.1.0.4.2
RHEL4 Update2
Thanks in advance.
Regards,
-KenthHi,
The status is "RECOVER" we have actually tried to recover but unfortunately the archive logs that were needed were on disks and were lost during one of the server hardware failures. Actually that is the reason why metalink support recommended this route for getting everything in order since we don't have any application data in SYSAUX yet.
Thanks. -
Steve,
Were you ever able to look at this item? In the meantime, my work around was to do a separate xsql query for each sub-query(cursor) and then append nodes in my DOM as I went along. But, I would like to help this tool be better. I think I have determined that if one of the sub-select/sub-cursor queries doesn't return anything, I get the "invalid cursor" error. Does that make sense to you? I think that if a the result should still be a blank node
( </NODE> ). What do you think?
thanks,
chad.
-----Original Message-----
From: Chad Small
Sent: Friday, September 22, 2000 9:31 AM
To: 'Steve Muench'
Subject: RE: LONG data type and subsequent CURSOR's question/problem
I attached two files:
1. file with sql script - you'll have to change the schema.
2. file with code. Two sections
a. 1st with jdbc result set code
b. 2nd with OracleXMLQuery
I comment out one or the other code section to run one or the other.
If you need any other information, please let me know.
thanks,
chad.
-----Original Message-----
From: Steve Muench [mailto:[email protected]]
Sent: Thursday, September 21, 2000 4:14 PM
To: Chad Small
Subject: Re: LONG data type and subsequent CURSOR's question/problem
Is it possible to send me CREATE TABLE script with one row
of sample data inserted that reproduces the problem?
Thanks.
Steve Muench, Lead XML Evangelist & Consulting Product Manager
BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
Author "Building Oracle XML Applications", O'Reilly http://www.oreilly.com/catalog/orxmlapp/
----- Original Message -----
From: "Chad Small" <[email protected]>
To: "'Steve Muench'" <[email protected]>
Sent: Thursday, September 21, 2000 3:56 PM
Subject: RE: LONG data type and subsequent CURSOR's question/problem
|
| Using the same query string on both programs:
|
| String xsqlString =
| "SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
| hwp.body, " +
| "CURSOR( SELECT hws.name as section_name " +
| "FROM health.section hws " +
| "WHERE hwp.section_id = hws.section_id) as section " +
| "FROM health.publish_document hwp " +
| "WHERE hwp.publish_document_id IN (13729, 1033, 11695)";
| ____________________________________________________________________________
| ______
| This works - simple JDBC program :
|
| PreparedStatement stmt = conn.prepareStatement(xsqlString);
| ResultSet rs = stmt.executeQuery();
|
| int n=1;
| while( rs.next() ) {
| System.out.println(n+": publish_document_id =
| "+rs.getInt("publish_document_id"));
| System.out.println(n+": topic_id = "+rs.getInt("topic_id"));
| System.out.println(n+": section_id = "+rs.getInt("section_id"));
| n++;
| }
| rs.close();
| stmt.close();
| conn.close();
| ____________________________________________________________________________
| ______
| This does not work - simple OracleXMLQuery:
|
| OracleXMLQuery qry = new OracleXMLQuery(conn, xsqlString);
| System.out.println("after\n");
| // structure the generated XML document
| qry.setMaxRows(1); // set the maximum number of rows to be returned
| qry.setStyleSheet("file:D:\\xsql\\bin\\healthwise.xsl"); // sets the
| stylesheet
|
| // get the XML document in string format
| String xmlString = qry.getXMLString();
|
| // print out the XML document
| System.out.println(" OUTPUT IS:\n"+xmlString);
| conn.close();
| ____________________________________________________________________________
| _______
| -> get this:
|
| OUTPUT IS:
| <?xml version = '1.0'?>
| <ERROR>oracle.xml.sql.OracleXMLSQLException: Stream has already been
| closed</ERROR>
|
|
| java.sql.SQLException: ORA-01001: invalid cursor
|
| at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
| at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
| at oracle.jdbc.ttc7.Oclose.receive(Oclose.java:126)
| at oracle.jdbc.ttc7.TTC7Pr otocol.close(TTC7Protocol.java:493)
| at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:467)
| at
| oracle.jdbc.driver.OracleConnection.close_statements(OracleConnection.java:1
| 141)
| at oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:537)
| at com.healthecare.search.apelon.xmlquerydb.main(xmlquerydb.java:116)
| at symantec.tools.debug.Agent.runMain(Native Method)
| at symantec.tools.debug.MainThread.run(Agent.java:48)
|
|
| Please advise.
|
| thanks,
| chad.
| -----Original Message-----
| From: Steve Muench [mailto:[email protected]]
| Sent: Thursday, September 21, 2000 1:46 PM
| To: Chad Small
| Subject: Re: LONG data type and subsequent CURSOR's question/problem
|
|
| Are you able to test the query that does cause the
| problem with:
|
| -> The command-line XSU utility
| -> A simple JDBC program that creates a prepared statement
| with this query and executes it to produce a result set
|
| I want to know if the problem is in JDBC or XSU.
|
| ______________________________________________________________
| Steve Muench, Lead XML Evangelist & Consulting Product Manager
| BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
| Author "Building Oracle XML Applications", O'Reilly
| http://www.oreilly.com/catalog/orxmlapp/
|
| ----- Original Message -----
| From: "Chad Small" <[email protected]>
| To: "'Steve Muench'" <[email protected]>
| Sent: Thursday, September 21, 2000 1:09 PM
| Subject: RE: LONG data type and subsequent CURSOR's question/problem
|
|
| | The problem does NOT occur in (1) -simple query.
| | And yes, the problem does occur in (2) - in combination with CURSOR.
| |
| | thanks,
| | chad.
| |
| | -----Original Message-----
| | From: Steve Muench [mailto:[email protected]]
| | Sent: Thursday, September 21, 2000 11:44 AM
| | To: Chad Small
| | Subject: Re: LONG data type and subsequent CURSOR's question/problem
| |
| |
| | Trying to isolate the problem a little...
| |
| | (1) Does the problem occur if you do a simple query like:
| |
| | SELECT body FROM table
| |
| | with just the LONG column?
| |
| | (2) Or does it only happen in combination with CURSOR() ?
| |
| | ______________________________________________________________
| | Steve Muench, Lead XML Evangelist & Consulting Product Manager
| | BC4J & XSQL Servlet Development Teams, Oracle Rep to XSL WG
| | Author "Building Oracle XML Applications", O'Reilly
| | http://www.oreilly.com/catalog/orxmlapp/
| |
| | ----- Original Message -----
| | From: "Chad Small" <[email protected]>
| | To: <[email protected]>
| | Sent: Thursday, September 21, 2000 10:24 AM
| | Subject: LONG data type and subsequent CURSOR's question/problem
| |
| |
| | | Hello Steve,
| | |
| | | First I want to thank-you for all of the support you put into Oracle's
| XML
| | | board. I just ordered your book from Fatbrain and it's on back order!
| I
| | | tried asking my question on the board and didn't have any luck getting
| any
| | | responses - maybe people didn't understand my question. I'm desperate
| for
| | | this to work and really need some guidance.
| | |
| | | I'm using the command line to extract data from tables to XML
| | | (.bin\xsql\bin\xsql healthwise.xsql chad.xml). Everything works
| | wonderfully
| | | until I add a LONG data type to the mix. Here is my xsql before the
| LONG:
| | |
| | | <?xml version="1.0"?>
| | | <!-- healthwise_xslt.xsql -->
| | | <xsql:query
| | | xmlns:xsql="urn:oracle-xsql"
| | | connection="healthwise_dev2"
| | | max-rows="22050" >
| | |
| | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
| | | CURSOR( SELECT hws.name as section_name
| | | FROM health.section hws
| | | WHERE hwp.section_id = hws.section_id) as section,
| | | CURSOR( SELECT hwk.name as keyword_name
| | | FRO M health.keyword hwk, health.map_keyword_object
| | | hwmko, health.object hwo
| | | WHERE (hwp.publish_document_id =
| | | hwo.publish_document_id) and
| | | (hwo.object_id = hwmko.object_id) and
| | | (hwmko.keyword_id = hwk.keyword_id) ) as keywords,
| | | CURSOR( SELECT hwt.name as topic_name,
| | | CURSOR( SELECT hwts.name as topic_synonym_name
| | | FROM health.topic_synonym hwts
| | | WHERE hwt.topic_id = hwts.topic_id) as
| | | topic_synonyms,
| | | CURSOR( SELECT hwc.name as catagory_name
| | | FROM health.category hwc,
| | health.map_category_topic
| | | hwmct
| | | WHERE (hwt.topic_id = hwmct.topic_id) and
| | | (hwmct.category_id = hwc.category_id) ) as catagories
| | | FROM health.topic hwt
| | | WHERE hwp.topic_id = hwt.topic_id) as topic
| | | FROM health.publish_document hwp
| | | WHERE hwp.publish_document_id IN (13729, 1033, 11695)
| | | </xsql:query>
| | |
| | |
| | | I'm using this in combination with a XSLT and get this output -
| Beautiful!
| | -
| | | just what I want, less my LONG body field :
| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
| | | <CONTENT>
| | |
| | |
| |
| <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&
| | | ;topic=10744&item=7</URL>
| | | <TITLE>Graft versus Host Disease</TITLE>
| | | <RANK1>
| | | <RANK1_DSCR>GVHD</RANK1_DSCR>
| | | </RANK1>
| | | <RANK2/>
| | | <RANK3>
| | | <RANK3_DSCR>Rare Disorders</RANK3_DSCR>
| | | </RANK3>
| | |
| | |
| |
| <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&
| | | ;topic=910&item=4</URL>
| | | <TITLE>Hypnosis</TITLE>
| | | <RANK1/>
| | | <RANK2>
| | | <RANK2_DSCR>Hypnotherapy</RANK2_DSCR>
| | | </RANK2>
| | | <RANK3/>
| | |
| | |
| |
| <URL>http://healthecare140:7601/medical/medicalDocument.jsp?page=medical&
| | | ;topic=12344&item=9</URL>
| | | <TITLE>Low Back Problems -- Computerized axial tomography (CAT scan,
| | | CT scan)</TITLE>
| | | <RANK1>
| | | <RANK1_DSCR>CT scan (computerized tomography),
| | | back</RANK1_DSCR>
| | | <RANK1_DSCR>CT scan, back</RANK1_DSCR>
| | | <RANK1_DSCR>Back, CT scan of</RANK1_DSCR>
| | | <RANK1_DSCR>Computed axial tomography (CAT) scan,
| | | back</RANK1_DSCR>
| | | </RANK1>
| | | <RANK2/>
| | | <RANK3/>
| | | </CONTENT>
| | |
| | |
| | | BUT, as soon as I add the LONG body field into the query (in BOLD):
| | |
| | | <?xml version="1.0"?>
| | | <!-- healthwise_xslt.xsql -->
| | | <xsql:query
| | | xmlns:xsql="urn:oracle-xsql"
| | | connection="healthwise_dev2"
| | | max-rows="22050" >
| | |
| | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id,
| hwp.body,
| | | <--------- hwp.body is the LONG
| | | CURSOR( SELECT hws.name as section_name
| | | FROM health.section hws
| | | WHERE hwp.section_id = hws.section_id) as section,
| | | CURSOR( SELECT hwk.name as keyword_name
| | | FROM health.keyword hwk, health.map_keyword_object
| | | hwmko, health.object hwo
| | | WHERE (hwp.publish_document_id =
| | | hwo.publish_document_id) and
| | | (hwo.object_id = hwmko.object_id) and
| | | (hwmko.keyword_id = hwk.keyword_id) ) as keywords,
| | | CURSOR( SELECT hwt.name as topic_name,
| | | CURSOR( SELECT hwts.name as topic_synonym_name
| | | FROM health.topic_synonym hwts
| | | WHERE hwt.topic_id = hwts.topic_id) as
| | | topic_synonyms,
| | | CURSOR( SELECT hwc.name as catagory_name
| | | FROM health.category hwc,
| | health.map_category_topic
| | | hwmct
| | | WHERE (hwt.topic_id = hwmct.topic_id) and
| | | (hwmct.category_id = hwc.category_id) ) as catagories
| | | FROM health.topic hwt
| | | WHERE hwp.topic_id = hwt.topic_id) as topic, hwp.body
| | | <---------------- I tried it here too
| | | FROM health.publish_document hwp
| | | WHERE hwp.pu blish_document_id IN (13729, 1033, 11695)
| | | </xsql:query>
| | |
| | |
| | | I get this error:
| | | oracle.xml.sql.OracleXMLSQLException: Stream has already been closed
| | |
| | |
| | | However, this works:
| | |
| | | <?xml version="1.0"?>
| | | <!-- healthwise_xslt.xsql -->
| | | <xsql:query
| | | xmlns:xsql="urn:oracle-xsql"
| | | connection="healthwise_dev2"
| | | max-rows="22050" >
| | |
| | | SELECT hwp.publish_document_id, hwp.topic_id, hwp.section_id, hwp.body
| | | <--------- hwp.body is the LONG
| | | FROM health.publish_document hwp
| | | WHERE hwp.publish_document_id IN (13729, 1033, 11695)
| | | </xsql:query>
| | |
| | |
| | | Do I have to pull this out into code and stream the long into a string
| and
| | | build a DOM and then go to XML from that? Or something along those
| lines?
| | | And if this is the case, can you point me to some sample code.
| | | I don't have the option of changing the LONG to something that doesn't
| | have
| | | to be streamed as suggested in this
| | |
| |
| doc(http://technet.oracle.com/doc/oracle8i_816/java.816/a81354/basic4.htm).
| | |
| | |
| | | If we can come to a conclusion on this, I will be the xsql-long
| evangelist
| | | on the board!
| | |
| | | Thank-you for you time,
| | | chad. <[email protected]>
| | |
| | |
| |
|
nullJust wanted to post Steve's response to this question, in case others have problems with LONG data types and CURSORS in their .xsql queries (thanks Steve!):
I can reproduce the problem with your testcase.
I've filed Bug Number 1472008.
You can workaround the problem by using CLOB
instead of LONG in your table.
You can use to TO_LOB() function in a CREATE TABLE...AS SELECT...
or in an INSERT INTO TABLE...SELECT... to easily
convert existing LONG content into CLOBs.
null -
HELP! INVALID CURSOR STATE
i have this simple jsp page that will display a few data from an SQL Database... im just trying to check my connectivity. but everytime i view the page it says "[Microsoft][ODBC SQL Server Driver]Invalid
cursor state'"my JSP environment is
J2EE 1.2.1
JDK 1.3.0_02
BDK 1.1
TOMCAT 3.2.1
SQL Server 2000 Enterprise Edition
Running on Windows 2000 server
Heres my simple code:
<%@ page language = "java" import = "java.sql.*" %>
<html>
<body>
<%
Connection con = null;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:testdsn:, "sa", "");
Statement stmt = con.createStatement();
Resultset rs = stmt.executeQuery("select * from testtable");
while(rs.next());
out.println(rs.getString(1));
out.println(rs.getString(2));
catch(Exception e)
out.println(e.toString());
%>
</body>
</html>
my testtable have 2 columns and 6 rows all in varchar datatype with values:
test 1 | a
test 2 | b
test 3 | c
test 4 | d
test 5 | e
test 6 | f
is there something wrong with the code? with my environment? please help im finishing a site for a school project but i cant seem to make jsp and sql workSee if using PreparedStatement works better for you than Statement. Sometimes it has better manners.
- Saish
"My karma ran over your dogma." - Anon -
Invalid cursor error in procedure
i am writing a procedure in which i have make use of cursor........it is giving me error INVALID CURSOR
on running
i have used this cursor with WITH CLAUSE....
when i am executing or running this procedure this giving me invalid cursor error
create or replace
procedure USP_UPDATEDRUGORDERDTL
v_pServiceid IN NUMBER DEFAULT NULL ,
v_pServRendered IN NUMBER DEFAULT NULL ,
v_pSchDateTime IN DATE DEFAULT NULL ,
v_pOrdQty IN FLOAT DEFAULT NULL ,
v_billingclassid IN NUMBER DEFAULT NULL ,
v_pOrdID IN NUMBER DEFAULT NULL ,
v_UpdatedBy IN NUMBER DEFAULT NULL ,
v_prender IN NUMBER DEFAULT 0 ,
v_pInsertedByUserID IN VARCHAR2 DEFAULT NULL ,
v_pInsertedON IN DATE DEFAULT NULL ,
v_pDrugID IN NUMBER DEFAULT 0 ,
v_pRate IN FLOAT DEFAULT 0 ,
v_pBatchId IN NUMBER DEFAULT 0 ,
v_OrderSource IN VARCHAR2 DEFAULT NULL ,
v_pInsertedMacID IN VARCHAR2 DEFAULT NULL ,
v_pInsertedIPAddress IN VARCHAR2 DEFAULT NULL ,
v_pOldOrdID IN NUMBER DEFAULT NULL,
v_plocid in char DEFAULT NULL
AS
vr_pConsumptionID NUMBER(10,0);
vr_pSavedQty NUMBER(10,3);
vr_pReturnQty NUMBER(10,3);
vr_Qty NUMBER(10,3);
begin
vr_pSavedQty := 0;
vr_pReturnQty := v_pOrdQty;
declare
cursor ordDtl_cur is -----cursor declaration
with --- with clause used with cursor
Q1 AS
Select NVL(ConsumptionID,0) As ConsumptionID,Sum(OrdQty) As OrdQty,
OrdID,DrugID,BatchID, locid from Orderdtl
Where OrdID = v_pOldOrdID and DrugID = v_pDrugID And BatchID = v_pBatchID and NVL(Cancelled,0) = 0
Group By OrdID,DrugID,BatchID,ConsumptionID
Order By ConsumptionID asc
Q2 AS
SELECT NVL(OrderDtl.ConsumptionID,0) As ConsumptionID,(SUM(OrderDtl.OrdQty)) As OrdQty,
IvPatientIssueReturnDtl.OrderID as OrdID,OrderDtl.DrugID,OrderDtl.BatchID,OrderDtl.locid
FROM OrderDtl INNER JOIN
IvPatientIssueReturnDtl ON OrderDtl.OrdID = IvPatientIssueReturnDtl.NewOrderId AND
OrderDtl.DrugId = IvPatientIssueReturnDtl.ItemId AND OrderDtl.BatchId = IvPatientIssueReturnDtl.BatchId
WHERE (OrderDtl.BatchId = v_pBatchID) AND (IvPatientIssueReturnDtl.OrderId = v_pOldOrdID)
AND (OrderDtl.DrugID = v_pDrugID) and NVL(OrderDtl.Cancelled,0) = 0
Group By IvPatientIssueReturnDtl.OrderID,OrderDtl.DrugID,OrderDtl.BatchID,OrderDtl.ConsumptionID
Order By OrderDtl.ConsumptionID asc
Select
Q1.ConsumptionID,(Sum(NVL(Q1.OrdQty,0)) + Sum(NVL(Q2.OrdQty,0))) As OrdQty,
Q1.OrdID,Q1.DrugID,Q1.BatchID,Q1.locid
from
Q1 ,Q2
where
Q1.OrdID =Q2.OrdID(+)
and
Q1.BatchID =Q2.BatchID(+)
and
Q1.DrugID =Q2.DrugID(+)
and
Q1.ConsumptionID =Q2.ConsumptionID(+)
Group By Q1.OrdID,Q1.BatchID,Q1.DrugID,Q1.ConsumptionID;
TYPE ordDtl_trec is TABLE of ordDtl_cur%ROWTYPE index by PLS_INTEGER;
l_ordDtl ordDtl_trec; ---- cursor syntax
begin
if ordDtl_cur%ISOPEN then
open ordDtl_cur; --------------opening cursor
end if;
loop
-- fetch data into cursor---
fetch ordDtl_cur
bulk collect into
l_ordDtl;
-----perform logic--------------------
for indx IN 1..l_ordDtl.COUNT loop
if vr_pSavedQty <> vr_pReturnQty then
If v_pOrdQty <= (vr_pReturnQty - vr_pSavedQty) then
vr_pSavedQty := vr_pSavedQty + v_pOrdQty;
vr_Qty := v_pOrdQty;
else
vr_Qty := (vr_pReturnQty - vr_pSavedQty);
vr_pSavedQty := vr_pSavedQty + (vr_pReturnQty - vr_pSavedQty);
end if;
end if;
end loop;
exit when ordDtl_cur%NOTFOUND;
end loop;
CLOSE ordDtl_cur; ---- closing cursor
end;
end;Hello.
Very simple.
You are using cursor name before opening it.
Here is the problem.
if ordDtl_cur%ISOPEN then
open ordDtl_cur; --------------opening cursor
end if;
end if;Please change your code like this
comment IF statement use only OPEN ordDtl_cur;
---- if ordDtl_cur%ISOPEN then
open ordDtl_cur; --------------opening cursor
--- end if;Thanks,
Suri -
I have a table called cdd_merge_children where the comments field contains the following SQL.
SELECT EVENT_ID FROM EVENT WHERE ACCOUNT_ID = :ACCOUNT_NO
In my procedure I am doing the following:
--get the comments from the cdd_merge_children table where CDD_MERGE_CHILDREN_TYPE
--is of type 3. type 3 are a replica of type 2's for audit/history purposes
SELECT DISTINCT COMMENTS
INTO ls_comments
FROM CDD_MERGE_CHILDREN
where table_name = ps_tablename
and CDD_MERGE_CHILDREN_TYPE = 3 ;
--get the comments from the table and execute the dynamic sql using the looser.
OPEN col_cv FOR ls_comments USING gvloosingaccount ;
--dump the curosr values in the table
FETCH col_cv BULK COLLECT INTO loosingvals ;
For some reason or the other when I try doing the fetch I am getting invalid cursor or ORA-01001: invalid cursor error. WHY WHY
Please help !You cannot bulk-fetch from a cursor into a collection of records, you can only bulk-fetch from a cursor into one or
more collections:
DECLARE
TYPE NameList IS TABLE OF emp.ename%TYPE;
TYPE SalList IS TABLE OF emp.sal%TYPE;
CURSOR c1 IS SELECT ename, sal FROM emp WHERE sal > 1000;
names NameList;
sals SalList;
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT INTO names, sals;
END;
You cannot however,
DECLARE
TYPE NameList IS TABLE OF emp.ename%TYPE;
names NameList;
salary emp.sal%TYPE;
TYPE DeptRecTab IS TABLE OF dept%ROWTYPE;
dept_recs DeptRecTab;
CURSOR c1 IS
SELECT deptno, dname, loc FROM dept WHERE deptno > 10;
BEGIN
SELECT ename, sal BULK COLLECT INTO names, salary; -- illegal target
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT INTO dept_recs; -- illegal
END;
Ok I have a table called cdd_merge_children which has a column called comments. In this column I am storing dynamic SQL such as
SELECT EVENT_ID FROM EVENT WHERE ACCOUNT_ID = :ACCOUNT_NO
Now in my code I retrieve this SQL statement and use it as follows:
--get the comments from the table and execute the dynamic sql using the looser.
OPEN col_cv FOR ls_comments USING gvloosingaccount ;
--col_cv is a reference cursor BTW
--dump the curosr values in the table
FETCH col_cv BULK COLLECT INTO loosingvals ;
Ok at this fetch is where I am getting the following error
ORA-01001: invalid cursor
Why ? Anyhelp would be great
Thank's
Sameer Handa -
ODBC data source error, invalid cursor state??
I'm using Photoshop Album Starter Edition 3.0, on Windows XP, and I was having some trouble organizing so I deleted all the photos in the catalogue, but now I can't add any new images. After opening the program and trying to add new pictures, I get the error that the files can't be found. After that one time, every time I try to add any photos at all, it gives me this error:
The ODBC data source returned the following error:
"[Microsoft][ODBC Microsoft Access Driver]Invalid cursor state"
I've tried restarting the program, the computer... I don't know what the error even means or how to solve this problem. So if anyone has any ideas, please let me know. Oh, and I would reinstall the program, except I think it just came with the computer, I don't have a cd with it or anything. Is there somewhere else or another way to reinstall? Anyhow I'm done now, please help if you can. Thanks. :)Since this is a free software, you can download this from Adobe.com. Try reinstalling Photoshop Album Starter Edition 3.0. If Reinstall does not work, try repairing the Windows ODBC drivers.
The reason for the error may be the Windows ODBC Drivers.To repair the ODBC drivers, follow these steps:
1) Go to Start>Settings>Control Panel. Select Add/Remove Programs and select SP2 and uninstall.
2) Insert your original Win XP CD and choose the Upgrade option.
3) When completed, reinstall SP2. Go to Start>Windows Updates and select SP2.
You can also try this:
Install Windows XP Service Pack 2 _or_ install the "Microsoft Data Access Components (MDAC) 2.8" from http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506 396c&DisplayLang=en
Please let us know if that worked.
-Smriti -
Payables Open Interface Purge completes with error "Invalid Cursor"
Hello,
I'm trying to run Payables Open Interface Purge (version 115.8) and get an invalid cursor error in the beforereport trigger. Does anyone know the cause and remedy of this? A portion of the log is below. I've looked at the cursor and everything looks fine to me.
MSG-00001: (Import_purge 1) Check control table for the purge process
MSG-00001: (Check_control_table 1) Lock the control table
MSG-00003: (Check_control_table 2) Fetch import_requests
MSG-00004: (Check_control_table 3) Check concurrent program status
MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
MSG-00999: FND_CONCURRENT.GET_REQUEST_STATUS<-Check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
MSG-00999: check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
MSG-00999: (Import_purge 1) Check control table for the purge process
MSG-00999: Delete record in control table..
MSG-00999: ORA-01001: invalid cursor
REP-1419: 'beforereport': PL/SQL program aborted.
Thank you.I'm trying to run Payables Open Interface Purge (version 115.8) and get an invalid cursor error in the beforereport trigger. Does anyone know the cause and remedy of this? A portion of the log is below. I've looked at the cursor and everything looks fine to me.
MSG-00001: (Import_purge 1) Check control table for the purge process
MSG-00001: (Check_control_table 1) Lock the control table
MSG-00003: (Check_control_table 2) Fetch import_requests
MSG-00004: (Check_control_table 3) Check concurrent program status
MSG-00999: FUNCTION GET_REQUEST_STATUS ERROR, Reason:
MSG-00999: FND_CONCURRENT.GET_REQUEST_STATUS<-Check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
MSG-00999: check_control_table<-Import_purge<- Before report trigger <- APXIIPRG
MSG-00999: (Import_purge 1) Check control table for the purge process
MSG-00999: Delete record in control table..
MSG-00999: ORA-01001: invalid cursor
REP-1419: 'beforereport': PL/SQL program aborted.11i: Payables Open Interface Invoice Import Troubleshooting Guide (APXIIMPT) [ID 107628.1] -- 3. Open Interface Import Purge Fails with ORA-01001: Invalid Cursor
Thanks,
Hussein
Maybe you are looking for
-
Hi Expert. I created a report layout in crystal report that I will be attaching in an add-on program which is a document type for report viewing via PLD. However, as i was setting up my layout in the report layout manager, I cannot point my layout i
-
How to change the name of the results folder?
Hi, Result folders are stored with the name Session1, Session2 - and so on. If I want to give my own name (e.g.: SCM_09JAN13_RUN1, OM_09JAN13_RUN1) instead of default name (Session), how can I achieve this. Please let me know if there are any OATS AP
-
Is there a way to exchange files between an iPhone and a mac?
Hi there, I know the iPhone does not support bluetooth (legally), but is there a way I can share files between the phone and a macbook NOT connected to the internet? What I need to do is the following: I use the phone for work (bad choice, I know...)
-
Retirement of an investement measure
Good day! We are trying to retire an investement measure after a full settlement of an order (KO88), as we don't need it anymore and don't want someone to use the investement measure iteratively. We are using transaction ABAVN to retire the investeme
-
I have one AD RMS server installed in Dev environment. I want to ensure that users will be able to access the documents already secured and will be able to restrict access on new documents even if AD RMS server goes down for a while.I am testing it a