Select count(*) on sql statement returning zero when a matching row exists.
Our account has an ANSI C application that checks for the existence a row on an Oracle table(s) by using the following SQL:
int iCount = 0;
EXEC SQL
SELECT count(rownum) INTO :iCount
FROM sys.all_tab_columns
WHERE table_name IN
(SELECT table_name FROM
sys.all_synonyms
WHERE upper(synonym_name) = upper(:szDestTable))
AND upper(column_name) = upper(:szColumnName)
AND owner = 'DBAUSER';
The bind variables szDestTable and szColumnName are populated with values parsed from columns on another database table. This application is executed through out the day. Occasionally, the application will report a zero in the iCount when there should be a match. I have verified the szDestTable and szColumnName are populated with the correct values which would find a match and they are correct. To make matters even stranger, the application will parse the same input values and find a match (as it should). At some point during the day, and it can be at any time, the application will NOT find a match on the same file, same values. Every subsequent execution of this application will not find a match on the same values. Once the database is brought down and started up in the evening for its normal backups, the application will find a match again on the same values. This problem does not occur every day. I could be a week or a week and a half between incidents.
I printed the contents of the sqlca.sqqlerrm.sqlerrmc field to a log file. The sqlca.sqlerrm.sqlerrmc field reported an ORA-1405 bind variable was null when the iCount was reporting a zero. When I compiled this application, I set the Proc*C flag to UNSAFE_NULLS=yes since there are other bind variable in the application that can be NULL and that is ok.
The above SQL is compiled into the C application using the Proc*C compiler. It is compiled using the Oracle 11.2.0.2 libraries. The application is executed against an Oracle 11.2.0.2 database. The database and application are executed on an HP/Unix 11.31 platform.
This problem did not start occurring until our account went from Oracle 10.2 to Oracle 11.2. Recently, I have changed the SQL to perform a “SELECT COUNT(rownum)” instead of the “SELECT COUNT(*)”. I compiled the application and executed the new application with the SELECT COUNT(rownum) against the same database where the same application with the SELECT COUNT(*) was failing to find a row that actually existed. The application with the SELECT COUNT(rownum) found the matching row as it should have. The new application has been executing in production for about 10 days now without any problems against ten various Oracle 11.2 databases.
Why would SELECT COUNT(*) and SELECT COUNT(rownum) be any different?
This forum is about C programming in general, and about using Studio C in particular.
Your question is about Oracle database programming. You are more likely to find a helpful answer in a forum about database programming. Start here:
https://forums.oracle.com/forums/category.jspa?categoryID=18
Similar Messages
-
Hi,
I have an odd situation where "select count(*) from my_view where some_clause" returns 0, but the exact same query fetching the data (ie "select * from my_view where some_clause") works fine and fetches, correctly, 4000+ records.
I have tried dropping and recreating the view, and collecting DB stats again, but the problem persists.
I had a look at the explain plans and they are very different, but both the SQL statements work fine on a copy of the database taken with impdp.
Does anyone have any suggestions on what might be going on here ?
Any help would be appreciated, I've run out of ideas !
Dave
Edited by: user10281551 on 18-Sep-2008 00:43
Edited by: user10281551 on 18-Sep-2008 00:44Maybe it's the bug that a function based index is present and gets incorrectly used in the select count(*) statement?
If that's not the case, then please show us more details, like the statement and both execution plans.
Regards,
Rob. -
SQL statement returning boolean?
Following a guide for querying Oracle databases in java and it suggests using this code to connect and get some select results:
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","chat","chat");
Statement s=con.createStatement();
ResultSet results = s.execute("SELECT * FROM users WHERE username='kaligula' AND password='1234'");
But when i try and compile this it says:
Error(97,34): incompatible types; found: boolean, required: java.sql.ResultSet
Whats going wrong here?Looking at the API
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html
I see that execute returns a boolean. You want executeQuery
Lee -
Simple stored procedure - select with an if statement, returning a cursor
Hi,
I'm trying to create a very simple stored procedure, but having never worked with them before I'm not quite sure what I'm doing wrong.
Here's my code:
create or replace
procedure contact_return(
v_contact_id IN varchar2,
p_cursor OUT SYS_REFCURSOR)
AS
begin
set sql_statement varchar2(4000) := '
SELECT URN,
FIRSTNAME,
LASTNAME,
TITLE,
CREATED_DT,
AREA_URN,
MOBILE,
WORK,
EMAIL,
ORG_NAME,
ADDRESS,
POSTCODE,
IN_USE
FROM CONTACT';
if v_contact_id is not null then
sql_statement := sql_statement || ' where urn = ' || v_contact_id;
end if;
open p_cursor for sql_statement;
end;
It's actually returning 2 errors:
Error(7,3): PL/SQL: SQL Statement ignored
Error(7,7): PL/SQL: ORA-00922: missing or invalid option
Which seem to be a problem with my set sql_statement line, but it looks correct to me?
Thanksrajendra wrote:
Dear User,
It is not allowed to declare a variable inside the PL/SQL block means after begin ( in your case line no 7 ).
Lot of errors in your code.
Tell me your exact requirement and what you want to do , after that I will be able to solve your problem.
Thanks,
Rajendra
Well, you can declare after the begin, though it'll be as part of an embedded code block e.g.
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure contact_return(empno IN number
2 ,c OUT SYS_REFCURSOR
3 ) AS
4 begin
5 declare
6 sql_statement varchar2(4000) := '
7 select *
8 from emp
9 where empno = nvl(:1,empno)';
10 begin
11 open c for sql_statement using contact_return.empno;
12 end;
13* end;
SQL> /
Procedure created.
SQL> var x refcursor
SQL> exec contact_return(7788,:x);
PL/SQL procedure successfully completed.
SQL> print x;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
so, it is allowed, as long as it's coded correctly. -
Sub selects in a SQL statement
Hi, I have a query with an obsene amount of sub selects,
for example :
SELECT p.ID,
(select something from data where id = p.id) data1,
(select somelse from data2 where id = p.id) data2,
(select someelse from data3 where id = p.id) data3,
(select someelse from data4 where id = p.id) data4,
(select someelse from data5 where id = p.id) data5,
FROM property P
WHERE ..........
this query is taking a long time to process. Is there a more efficient way of doing such a statement?
thanks in advanceGabe:
Since the original poster said "this query is taking a long time to process", I assumed that there was a one-to-one relationship between properties and each of the dataX tables, otherwise, as you pointed out, he would be complaining about ORA-01427: single-row subquery returns more than one row
In my union, I am returning a single column from each of the data tables (plus the id), and a NULL for each of the other columns in the in-line view. The MAX function just gets the single row for each column that actually has a value.
As a test case, I did:
CREATE TABLE properties AS
SELECT rownum id, object_name
FROM all_objects
WHERE rownum < 11;
CREATE TABLE data1 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data1 VALUES(1, 'ONE');
INSERT INTO data1 VALUES(2, 'TWO');
INSERT INTO data1 VALUES(3, 'THREE');
CREATE TABLE data2 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data2 VALUES(4, 'FOUR');
INSERT INTO data2 VALUES(5, 'FIVE');
INSERT INTO data2 VALUES(6, 'SIX');
CREATE TABLE data3 (id NUMBER, descr VARCHAR2(10));
INSERT INTO data3 VALUES(7, 'SEVEN');
INSERT INTO data3 VALUES(8, 'EIGHT');
INSERT INTO data3 VALUES(9, 'NINE');The original version as posted retrieves:
SQL> SELECT p.id, p.object_name,
2 (SELECT descr FROM data1 WHERE id = p.id) data1,
3 (SELECT descr FROM data2 WHERE id = p.id) data2,
4 (SELECT descr FROM data3 WHERE id = p.id) data3
5 FROM properties p
6 ORDER BY p.id;
ID OBJECT_NAME DATA1 DATA2 DATA3
1 TAB$ ONE
2 I_IND1 TWO
3 I_COBJ# THREE
4 USER$ FOUR
5 I_OBJ1 FIVE
6 I_PROXY_ROLE_DATA$_2 SIX
7 BOOTSTRAP$ SEVEN
8 I_ICOL1 EIGHT
9 UNDO$ NINE
10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
0 recursive calls
0 db block gets
93 consistent gets
0 physical reads
0 redo size
1000 bytes sent via SQL*Net to client
655 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
10 rows processedBut, it does a SELECT (hopefully indexed) of data1, data2, and data3 for each row in properties. Minimally, 9 gets per row of properties (index root, index leaf, table row for each of data1, data2, data3) without even getting any data from properties.
My query returns:
SQL> SELECT p.id, p.object_name, a.data1, a.data2, a.data3
2 FROM properties p,
3 (SELECT id, MAX(data1) data1, MAX(data2) data2, MAX(data3) data3
4 FROM (SELECT id, descr data1, TO_CHAR(NULL) data2, TO_CHAR(NULL) data3
5 FROM data1
6 UNION ALL
7 SELECT id, TO_CHAR(NULL), descr, TO_CHAR(NULL)
8 FROM data2
9 UNION ALL
10 SELECT id, TO_CHAR(NULL), TO_CHAR(NULL), descr
11 FROM data3)
12 GROUP BY id) a
13 WHERE p.id = a.id(+)
14 ORDER BY p.id;
ID OBJECT_NAME DATA1 DATA2 DATA3
1 TAB$ ONE
2 I_IND1 TWO
3 I_COBJ# THREE
4 USER$ FOUR
5 I_OBJ1 FIVE
6 I_PROXY_ROLE_DATA$_2 SIX
7 BOOTSTRAP$ SEVEN
8 I_ICOL1 EIGHT
9 UNDO$ NINE
10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
0 recursive calls
0 db block gets
12 consistent gets
0 physical reads
0 redo size
1000 bytes sent via SQL*Net to client
655 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
2 sorts (memory)
0 sorts (disk)
10 rows processedThe same result, but 1/8 of the gets. an outer join is also possible:
SQL> SELECT p.id, p.object_name, d1.descr data1, d2.descr data2, d3.descr data3
2 FROM properties p, data1 d1, data2 d2, data3 d3
3 WHERE p.id = d1.id(+) AND
4 p.id = d2.id(+) AND
5 p.id = d3.id(+)
6 ORDER BY p.id;
ID OBJECT_NAME DATA1 DATA2 DATA3
1 TAB$ ONE
2 I_IND1 TWO
3 I_COBJ# THREE
4 USER$ FOUR
5 I_OBJ1 FIVE
6 I_PROXY_ROLE_DATA$_2 SIX
7 BOOTSTRAP$ SEVEN
8 I_ICOL1 EIGHT
9 UNDO$ NINE
10 PROXY_ROLE_DATA$
10 rows selected.
Statistics
0 recursive calls
0 db block gets
12 consistent gets
0 physical reads
0 redo size
1000 bytes sent via SQL*Net to client
655 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
10 rows processedSo, the same number of gets, and it saves one sort. But if the tables are large, multiple outer joins may not be as efficient as one outer join to the union all query.
HTH
John -
Two count(*) in sql statement
hi viewers,
I need the similar query in oracle for the following Informix query.
select count(*),(select count(*) from table_name where col1=10) from table_name where col1=10;
i have a solution also but the problem is, if that table has no rows then output is not 0,0
select count(*),(select count(*) from table_name where col1=10) from table_name where col1=10 group by col1;
thanks
hariA little remark: the behavoiur you stick on is a default feature in Oracle:
SQL> select count(*) from emp where deptno = 40;
COUNT(*)
0
SQL> select count(*) from emp where deptno = 40 group by deptno;
no rows selectedThese two queries work differ. It is described in Oracle documentation:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i89203
Oracle applies the aggregate functions to each group of rows and returns a single result row for each group.
If you omit the GROUP BY clause, then Oracle applies aggregate functions in the select list to all the rows in the queried table or view
As Alex pointed out, you should not include group by clause and should use count(*) instead of a subquery.
Rgds. -
Hi, I would like to create a table with the following collumns:
"OWNER|TABLENAME|NUM_ROWS|MEASURE_DATE"
I can get owner, tablename and measure_date (sysdate) from
dba_tables easily with a
select owner, tablename, sysdate
from dba_tables
, but I am having trouble getting the num_rows for each table
seperately.
dba_tables.num_row is not an option because I am not running
statistics on this server and can't (rather: I am told not to.
So somehow I have to add the result of
select count(*) from " an individual table", dynamically.
But I am not sure how.
Eventually the table would have to look like:
JOHN EMP 433 12-JAN-01
JOHN EMP 476 12-JAN-01
MARGE LOC 198 13-JAN-01
All help is very much appreciated,
MikeHI guy's !
Thanx for all the suggestions, I have tried them all out and its
almost there. However your suggestions display the output on the
screen and I would like to insert the rows into table so to be
able to readout table growth history. I tried to alter your
statements with a create table as select ( and here your plsql)
but this doesnt seem to work. I am sorry that I do not know
pl/sql. Can anyone assist me in completing the code with an
insert into a table?
Mohit Dubey: I am getting an ORA-00952 table or view does not
exist with your code, do I need to edit smth I overlooked?
Suresh: Your code works, but as mentioned above I would like to
get the code into table instead of on the screen, could you help
me with that? I apologize for not knowing plsql.
Barbara: Your code works fine, but it does an update on the
table. Therefore, I cannot query the history of the number of
rows tables. Could you change it to do an insert instead of an
update? I tried to but failed miserably.
Again; thanx all for your suggestions! Now I just need a final
push as I myself am unable to alter the codes into an insert
statement.
Mike -
BIDS 2008 DataFlow viewer not showing even though the sql statement returns data
Have a dataflow and trying to see why no rows are being written to the destination. I popped a viewer on the connection, but it doesnt show up when I run. What can I check?
The DataFlow source runs a sql statement and it runs fine and returns a result.Why would that be if I can execute the sql statement that is being used in the OLEDB Source, and I get a result, yet the destination gets no rows afterwards. Even executing the Dataflow task by itself, no rows are written.
I do have a script task that modifies the connection before the dataflow, but this was working fine yesterday :)
Even so, if there was a problem with the connection, I would get an error. There no no errors, it just sees no rows and the dataviewer is never displayed.
What the heck can I check? -
Batching SQL Statements - Return Long Raw
I have been using the .NET Framework Data Provider for Oracle and have run into the following limitation.
I need to batch several SQL statements at one time and return a datareader (or another object) with those values. The .NET Framework Data Provider for Oracle from Microsoft doesn't support batching up SQL statements in this manner. Additionally, the values I need to return include a LONGRAW field. From the research I've done PL-SQL can only return 32KB of data for a LONGRAW field if we were to try a different approach like using a stored procedure and a REF CURSOR.
My questions are:
1.) Will the ODP support batched SQL statements? For example, can I issue the following SQL statements and get a datareader?
Select field1, field2 from table1;
Select feild1, field2 from table2;
Select feild1, field2 from table3;
2.) Is there the 32 KB limitation on LONGRAW fields and PL-SQL in Oracle 8.1.7.2.0?
3.) Any suggestions?1. With ODP.NET, you can batch your SQL statements using anonymous PL/SQL block. For example,
begin
open :1 for select * from emp;
open :2 for select * from dept;
open :3 for select col1 from test;
end;
You need to create three parameters with type OracleDbType.RefCursor and bind them as Output parameters. If you execute the above statement using OracleCommand's ExecuteNonQuery method, you would get three REF Cursors in the Value property of OracleParameter object. You can create an OracleDataReader or populate the Data Set using any or all of these REF Cursors in any order. If you execute the above statement using OracleCommand's ExecuteReader method, you would get OracleDataReader for the first REF Cursor and you would be able to get the OracleDataReader for other REF Cursors using OracleDataReader's NextResult method. Note that ODP.NET does not impose a limitation of closing the first OracleDataReader before opening the second one.
2. Long/Long Raw 32K limitation is imposed by PL/SQL and one way to bypass that limitation is to use LOBs instead. Having LOBs in the stored procedure or anonymous PL/SQL blocks allow you to access data upto 4GB. -
How to put the SQL-statement returned value into the field (as a default)
Hi,
I am using Developer/2000 (Forms Designer) under windows 98.
Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
There is a message box which ask 'Do you want to save the changes?'.
2) Place the SQL-statement before execute enter_query. There is still a
message box which ask 'Do you want to save the changes?'.
Any hints? Thanks. Urgent.solved it!
1) Suppress DEFAULT save message
if form_failure then
raise form_trigger_failure;
end if;
2) Place the default value before enter-query.
Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
form level trigger
============
WHEN-NEW-ITEM-INSTANCE
=======================
if :system.mode = 'ENTER-QUERY' then
:block.item := 'default waarde';
end if;
3) Suppress the changes whenever leaving the default field.
if :block.item is null then
-- assign statement
end if; -
Help Using Count and SQL statements
Hello
This problem has been bugging me incesantly and I would be reaaaaaaally grateful if someone could help here
I want to create query that woud count the number of times a certain unedited word would be matched against different edited words
This query works well in MS ACCess but not in java
query =" SELECT Count(*) AS WordCount, Segmentations.EditedWord FROM [select Segmentations.EditedWord FROM Segmentations where Segmentations.UneditedWord = '"+Word+"']. AS c GROUP BY Segmentations.EditedWord";
I've tried removing the Segmentations. and changing it to
query =" SELECT Count(*) AS WordCount, EditedWord FROM [select EditedWord FROM Segmentations where UneditedWord = '"+Word+"']. AS c GROUP BY EditedWord";
But still nothing
I think that is due to the fact that you can't call Count(*) and another field at the same time
pleas eif anyone knows a way around this send it ASAP
thanxWhy not use,
query = "SELECT Count(*) AS WordCount, EditedWord FROM Segmentations WHERE UneditedWord = ? GROUP BY EditedWord"and use PreparedStatement to optimize.
HTH -
SQL code returns triple copies of each row
I want to select from my schema and another schema, and sum(total period_activity_a). the code returns triplicate copies of each row, how can I avoid the triplicate rows. I need just one row for each row.
select a.segment3, b.descr, b.leader, sum(a.period_activity_a) from payman.snp_op_detail a,
hrman.organisation_t b
where a.segment3 = b.org_member_id and
a.segment3 between 4000 and 5999 and
a.segment2 != 6651 and
a.segment2 between 5400 and 8999 and
a.period_name in ('JAN-11', 'FEB-11', 'MAR-11', 'APR-11', 'MAY-11', 'JUN-11',
'JUL-11', 'AUG-11', 'SEP-11','OCT-11','NOV-11', 'DEC-11')
group by ROLLUP(a.segment3,b.descr, b.leader);
result
SEGMENT3 DESCR LEADER SUM(A.PERIOD_ACTIVITY_A)
4001 CLOSED: RF-CASSAVA MOSAIC DIS. S.SHOLOLA 0
4001 CLOSED: RF-CASSAVA MOSAIC DIS. 0
4001 0
4005 Closed: BELG. STRAT MUSA-ESARC S.SHOLOLA 0
4005 Closed: BELG. STRAT MUSA-ESARC 0
4005 0
4006 Closed: BELG. STRATEG MUSA KUL S.SHOLOLA 0
4006 Closed: BELG. STRATEG MUSA KUL 0
4006 0
4007 Closed: BELG STRATEG MUSA ONNE S.SHOLOLA 0
4007 Closed: BELG STRATEG MUSA ONNE 0
4007 0
4009 Closed: EEC-OFAR II REIMB EXPs S.SHOLOLA 0
4009 Closed: EEC-OFAR II REIMB EXPs 0
4009 0
Edited by: OlaTunde on 19-Jan-2012 04:41Hi,
OlaTunde wrote:
I want to select columns and total only not subtotal. the only thing I can think about is rollup. but rollup brings rollup for each column. how can I get total without repeating the rows?Sorry, it's unclear what you want. Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. Explain how you get those results from that data.
If you can show your problem using commonly available tables (such as scott.emp) then you don't need to post any sample data; just the results and the explanation.
Always say which version of Oracle you're using.
As Johan said, GROUP BY (without ROLLUP) produces only one row for each combination of the values in the GROUP BY clause.
Analytic functions can produce the same total as aggregate functions, without changing the number of rows at all.
GROUP BY GROUPING SETS is very flexible about getting subtotals and totals in the same query.
It all depends on your data, what you want from that data, and your version. If you're willing to share what you know about those things, other people will share what they know about SQL. -
'lag' works in normal SQL statement, but not when in a view (resolved)
hi,
got a problem when using 'lag' in a view.
if i set up a select statement using 'lag' and execute it, all the results are correct.
when i stick the exact same select into a view, then the results for the 'lag' entries are not correct any more.
has anyone experienced this ?
any hints would be good.
thanks
Martin
using Oracle 10g Express
version 10.2.0.1.0
can not download the patch because i can not log into metalink - no CSI
setting to resolved.
Message was edited by:
user614086Hi again,
I think the problem is more with your expectation of what LAG should be doing than with LAG itself.
LAG must calculate based on the result set, in your stand alone query that means what's left after the WHERE clause is applied.
In the view that means across all rows the view produces. THEN you apply the where clause to the calculated values. You can see this in the example below.
So what you'd need to do is define this view in a manner in which the WHERE clause won't make a difference to the logical window produced.
That would mean using some columns in the partition by clause and order by clause, or leaving the lag function outside the view.
create table test_lag (column1 number, column2 varchar2(10), column3 date);
insert into test_lag values (1, 'ONE', trunc(sysdate,'DD') - 1);
insert into test_lag values (2, 'TWO' trunc(sysdate,'DD') );
insert into test_lag values (3, 'THREE', trunc(sysdate,'DD') + 1);
insert into test_lag values (4, 'FOUR', trunc(sysdate,'DD') + 2);
commit;
create or replace view test_lag_v
as
select column1, column2, lag(column2, 1) over (order by column1 asc) AS laggery, lag(column1) over (order by column3 desc) as laggery_2
from test_lag;
ME_XE?select *
2 from test_lag_v
3 where column1 <> 3;
COLUMN1 COLUMN2 LAGGERY LAGGERY_2
4 FOUR THREE
1 ONE 3
2 rows selected.
Elapsed: 00:00:00.50
ME_XE?
ME_XE?select *
2 from test_lag_v;
COLUMN1 COLUMN2 LAGGERY LAGGERY_2
4 FOUR THREE
3 THREE ONE 4
1 ONE 3
3 rows selected.
Elapsed: 00:00:00.68 -
How to always hide the SQL statements for users when they run User Queries?
Hi,
from the IT dept. position, I don't want users to see and be so curious about the SQL commands.
How can I always hide the textbox of Display Query Structure?
thanks.Hi,
Unfortunately system design has short of this function. If users are allowed to run those queries, you can not hide the query structure.
You may post a DRQ here: /community [original link is broken]
Thanks,
Gordon -
Java executed SQL statement to XML - large number of rows
Hello,
I have to write some code to generate XML as the result of a query. AFAIK I am using the latest versions of the relevant Java libraries etc.
I have found that using a max_size function above 2000 results in 'Exception in thread "main" java.lang.OutOfMemoryError' errors
I thought I could overcome this by reading the data in batches using the skip_rows functionality.
I have included the code I am using below and would appreciate any help.
Best Regards,
Mark Robbins
import java.sql.*;
import java.math.*;
import oracle.xml.sql.query.*;
import oracle.xml.sql.docgen.*;
import oracle.jdbc.*;
import oracle.jdbc.driver.*;
public class XMLRetr
public static void main(String args[]) throws SQLException
String tabName = "becc";
String user = "test/test";
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//initiate a JDBC connection
Connection conn =
DriverManager.getConnection("jdbc:oracle:oci8:"+user+"@test");
// initialize the OracleXMLQuery
OracleXMLQuery qry = new OracleXMLQuery(conn,"select * from "+tabName+" where TRUNC(SAMPLED) < \'14-NOV-99\'" );
// structure the generated XML document
System.out.println("Before setting parameters");
qry.setMaxRows(8000); // set the maximum number of rows to be returned
qry.setRowsetTag("ROOTDOC"); // set the root document tag
qry.setRowTag("DBROW"); // sets the row separator tag
qry.setRaiseException(true);
qry.keepCursorState(true);
// create the document generation factory. Note: there are methods in OracleXMLQuery
// which don't require that an OracleXMLDocGen object be passed in; but rather, they
// create an OracleXMLDocGen object of their own.
OracleXMLDocGen doc = (OracleXMLDocGen) new OracleXMLDocGenString();
for (int rowCnt = 1; rowCnt < 8000; rowCnt = rowCnt + 1000)
// get the xml
System.out.println("Before skip rowCnt:"+rowCnt);
qry.setSkipRows(rowCnt); // process next batch
System.out.println("Before getXML");
// this is where I get the exception on the second iteration of the loop
qry.getXML(doc);
System.out.println("Displaying document");
// System.out.println(doc.getXMLDocumentString());
System.out.println("Row number:"+rowCnt);
System.out.flush();
System.out.println("End of document");
qry.close();
nullI used qry.getXMLString()
But called it for every row, ie, set
qry.maxRows(1) and qry.skipRows(rowcount-1).
The down side is I had to postprocess the String to remove the processing instruction and doc level tags.
Maybe you are looking for
-
Is there a way to sync apps and pictures between iphone and ipad.
I am going back to work in a few weeks and I am looking for a way to sync the iPad/iPhone so that I have quick saccess to see my son and keep track of his baby app that I use. Plus I want to be able to have easy access to any photos takne with the i
-
After working for days sticking things together I find I can't export my movie and get: "Unable to Prepare Project for Publishing. The project could not be prepared for publishing because an error occurred. (-50)" Anyone know what this error code mea
-
Install Oracle 9i in Redhat 7.1 hangs at Configuration Tools
I have upgraded the binutil to binutil-2.10.91.0.4-1. Everything seems fine until Configuration Tools. The Oracle Net Configuation Assistant shows in progress status and did not completed. In the detail box, it shows Running Listener Control /u01/app
-
How to increase the FPS of animation in JavaFX?
I tried to run the tree animation demo in the official JavaFX Documentation System.out.println("FPS " + com.sun.javafx.perf.PerformanceTracker .getSceneTracker(stage.getScene()) .getInstantFPS()); its output FPS: FPS 0.0 FPS 0.0 FPS 0.0 FPS 0.0
-
PS CS5, Owl Orphange Error Message
Hello Everyone. I am currently a Photoshop CC user, but I opened My Photoshop CS5, and I get this error message. Owl Orphanage: Photoshop.exe-System Error Would you please look at my screen-shot.. Thanks.