SQL Query - Banging My Head
I've been struggling with this for a couple of days and could use some help -
I have 3 tables
Books (with an ID and Title)
Authors (with a Book_Link and a Name)
Publications (with a Book_Link and a Publication_Date)
Each book can have 0 or more authors. Each book can have 0 or more publications. I ultimately need a report that shows
Book Title/Author Name/Publication Date
So, let's say there are 3 books (ID/Title)
#1 - Book One
#2 - Book Two
#3 - Book Three
Book One has 2 authors and 3 publication dates.
Book Two has 1 author and 1 publication date
Book Three has no authors or publication dates.
With regular joins, I get:
Book One - Author 1A - Pub Date 1-1
Book One - Author 1A - Pub Date 1-2
Book One - Author 1A - Pub Date 1-3
Book One - Author 1B - Pub Date 1-1
Book One - Author 1B - Pub Date 1-2
Book One - Author 1B - Pub Date 1-3
Book One - Author 1C - Pub Date 1-1
Book One - Author 1C - Pub Date 1-2
Book One - Author 1C - Pub Date 1-3
Book Two - Author 2A - Pub Date 2-1
Book Three - null - null
What I need to report to my user is:
Book One - Author 1A - Pub Date 1-1
Book One - Author 1B - Pub Date 1-2
Book One - null - Pub Date 3
Book Two - Author 2A - Pub Date 2-1
Book Three - null - null
I am using Apex so any functions or whatnot would be helpful.
One other condition - this is a query that I am building dynamically, based on the user selecting which fields they want reported on. So any solution needs to account for the fact that the select statement and whatnot need to be constructed as string.
Thanks.
ID TITLE
1 Book One
2 Book Two
3 Book Three
BOOK_LINK NAME
1 Author 1A
1 Author 1B
2 Author 2A
BOOK_LINK PUBLICATION_DATE
1 01-JAN-07
1 02-JAN-07
1 03-JAN-07
2 01-JAN-07
create or replace function udf_GetAuthorsForBook( Book in int)
RETURN varchar2
IS
authorArr htmldb_application_global.vc_arr2;
authorList varchar(2000);
i integer :=1;
BEGIN
null;
for r in (select name
from authors
where authors.book_link = Book
order by name)
loop
authorArr(i) := r.name;
i := i +1;
end loop;
authorList := htmldb_util.table_to_string( authorArr, ', ' );
return authorList;
END;
create or replace function udf_GetPublicationsForBook( Book in int)
RETURN varchar2
IS
publArr htmldb_application_global.vc_arr2;
publList varchar(2000);
i integer :=1;
BEGIN
null;
for r in (select publication_date
from publications
where publications.book_link = Book
order by publication_date)
loop
publArr(i) := r.publication_date;
i := i +1;
end loop;
publList := htmldb_util.table_to_string( publArr, ', ' );
return publList;
END;select id, title, udf_GetAuthorsForBook(id), udf_GetPublicationsForBook(id) from books
ID TITLE AUTHORS PUBLICATIONS
1 Book One Author 1A, Author 1B 01-JAN-07, 02-JAN-07, 03-JAN-07
2 Book Two Author 2A 01-JAN-07
3 Book Three - -
Similar Messages
-
How to show the VALUE as the Column Header using SQL query?
Hi
I have a requirement to show the picked value as the column header using SQL query.
Example:
======
SELECT EMPNO FROM EMP
WHERE EMPNO=7934;
Result Should be:
7934
7934I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
SQL> set verify on
SQL> def e = 7934
old: SELECT empno "&&e" FROM emp WHERE empno = &&e
new: SELECT empno "7934" FROM emp WHERE empno = 7934
SQL> SELECT empno "7934" FROM emp WHERE empno = 7934
7934
7934
1 row selected. -
Problem with SQL query region source containing OLAP clauses
Hi team,
I believe I found a bug when HTMLDB validates the SQL Query in a report region.
My query includes an ORDER BY clause within a windowing function and HTMLDB refuses to accept the source owing to the presence of the ORDER BY and the column heading sort preference.
Clearly the order-by in a window function has little to do with the column heading sort, but this error prevents me from updating the conditional display item in the page definition.
Note also that the page was imported smoothly from the 1.5 version, so probably the region source is not checked at that time, but only when you update it "manually".
So, in the end, if I don't change anything the page works because the sql query is assumed to be correct but unfortunately I need to change the condition and I cannot.
The problem shows up in page 126 of app 21670, SQL query region.
Bye,
Flavio
PS: may be I can work around this by using the pl/sql function returning the sql query.Flavio,
We're aware of this problem. For now, your workaround is described in this thread:
HTMLDB 1.6 and "order by" in analytic functions
Sergio -
SQL Query report region that only queries on first load
Hello all,
Is there any way in which you can prevent a SQL Query report region from quering data after every refresh?
I would like to make a report that queries on the first load, but then I would like to change the individual values, and reload to show the change, but every time I reload the page the columns are queried and the original values are displayed once again...
any ideas?
-MuxChet,
I created a header process to create the HTMLDB_COLLECTION. It is something like:
HTMLDB_COLLECTION.CREATE_COLLECTION_FROM_QUERY(
p_collection_name => 'Course_Data',
p_query => 'SELECT DISTINCT COURSE_ID, HTMLDB_ITEM.CHECKBOX(14,COURSE_ID) as "checker", TITLE, SUBJECT, COURSE_NUMB, SECTION, ENROLLED, null as "temp_term", null as "temp_title", null as "temp_crse_id", null as "temp_subj", null as "temp_crse_numb", null as "temp_sect", FROM DB_TBL_A, DB_TBL_B, DB_TBL_C, DB_TBL_D, DB_TBL_E, DB_TBL_F WHERE ...');
The names were changed, for obvious reasons.
I then created an SQL Report Region to see if it would work. The SQL is:
SELECT c001, c002, c003
FROM htmldb_collections
WHERE collection_name = 'COURSE_DATA'
When I run the page it says:
ORA-20104: create_collection_from_query Error:ORA-20104: create_collection_from_query ExecErr:ORA-01008: not all variables bound
Any idea why this is happening?
I'm new to HTMLDB_COLLECTIONS, so I may be doing something wrong
-Mux -
I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option. The SQL query generated will possibly be over 32K. When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated. I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL. I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL. Our environment is on 11gR2 and using ApEx 4.2.1. I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using. Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
As a test, I created a page on apex.oracle.com with a report region with the following source:
declare
l_stub varchar2(25) := 'select * from sys.dual ';
l_sql clob := l_stub || 'union all ';
br number(3) := 33;
begin
while length ( l_sql ) < 34000 loop
l_sql := l_sql || l_stub || 'union all ';
end loop;
l_sql := l_sql || l_stub;
for i in 1 .. ceil ( length ( l_sql ) / br ) loop
dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
end loop;
return l_sql;
end;
The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K. When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed. When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g. Thoughts?
Shane.What setting do you use in your report properties - especially in Type and in Region Source?
If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
declare
mycond varchar2(4000);
begin
if :P1_REPORT_SEARCH is not null THEN
mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
end if;
return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
end;
And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
(You would than need to change the code of your function accordingly).
If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query. -
SAP Crystal Report (2008) through SQL Query parameters
Hi,
I Created a report in Crystal report (2008) based on Sql Query. I created parameters in SQL query prompt only (all single valued).
Based on this I need to show the data in detail section.
For Graph, I used another SQL query, and added one subreport to the Main report header section. Since this subreport is also using the SQL query prompts for taking parameters.
Since both the reports are using same set of parameters. I mapped Main report parameters to sub-report parameters.
So Now structure is like,
In a report there is one subreport.
Main report ....SQL query generates parameter prompt..same parameters is passed to subreport.
In subreport there are sql generated prompts. and we mapped that prompts to main report parameter prompts.
Now it is running fine from crystal report, but not from CMC. It is not showing the graph.
Made Two Experiment:
1. To check subreport is running or not , Mannualy put my name in sub report--working fine.(CMC)
2. To check the parameters are correctly mapped--printed the value in subreport--Showing all the parameters value from CMC
but it is not running the SQL query of that sub report.
Any suggestion ?? Or is there anyoption to check?? Or a CMC setting.
Please suggest and respond..
Thank you in advance.!!Hi Rajeev,
This is Crystal reports development community, you said the report is working fine in Crystal. it is problem in CMC. So the issue is at BI Server.
So i think you need to create the thread in the below community.
BI Platform
--Naga -
Hello all,
I am currently creating a web application that will allow a user to create a homepage from a template that is displayed to them. If the user is logging into the system for the first time, the template to create their homepage is displayed to them. However, if the user is logging in and has already used the template to set their homepage options, they are then forwarded to their homepage.
The users options for their homepage are stored in a database. The problem I am having is trying to generate the jsp page ( with HTML inside also ) using SQL statements that query the table that store the users options.
Eg. an SQL query queries the DB to see wht options the user has selected. Can anyone help me / advise me how to use these queries to generate the homepage. Thanks in advance!Hi aniseed,
Thanks for a prompt reply.
So for example can you tell me if the following sample approach is ok.
<html>
<head>
<body>
<sql:query name="query">
SELECT * FROM SettingsTable WHERE links == "yes"
</sql:query>
<%-- Then to use this query result to insert selected hyperlinks that the user wants in their homepage, I would do the following ....... ? --%>
<% if (query.size() == 0)
<table>
<td>
<tr>
</tr>
</td>
</table>
%>
Thanks again -
Setting current values in Multiple Select List in SQL Query based Report
Hi,
I have a report based on a sql query that contains a multiple select list. Unfortunately I cannot get the multiple select list to display the current values (p_value) correctly. I have created a page item, :p311_current_versions, that is set using a pre-header process and it returns a value with a colon delimited format e.g. '10.1.2.1.0:10.1.2.2.0'. Then this item is used in the sql query to set the current value (p_value) of the apex_item.select_list_from_query function. However when the table is displayed, instead of having two entries, 10.1.2.1.0 and 10.1.2.2.0 selected, it has an extra entry '10.1.2.1.0:10.1.2.2.0' selected.
Here is my code:
select distinct a.product, a.version from (
select distinct
apex_item.display_and_save(2,product)||apex_item.hidden(1,env_product_id) PRODUCT,
APEX_ITEM.SELECT_LIST_FROM_QUERY(3,decode(product, 'HTTP Server' , :p311_current_versions, version), 'SELECT distinct version d, version r FROM ebs_tech_stack where
product ='''||PRODUCT||'''',
decode(PRODUCT, 'HTTP Server' ,'multiple="multiple" style="width:170px"','style="width:170px"'),
'NO') as version
from ebs_environment_tech_stack
where environment_id = :p311_umgebung_id) a order by a.product
If anyone can help me figure out how to set the current values correctly I'd be really grateful!!
Thanks in advance,
JeanJean,
I don't think this is possible using the apex_item package. The select_list_from_query function accepts only a single value for the second parameter.
Scott -
I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
Here is my dilemma:
I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
Thank you,
Tony Miller
UTMB/EHN
Title changed, maybe SOMEONE has an idea on this??
Message was edited by:
Tony MillerHi,
1/ first check you are passing the bind variables and
appropriate values in the call to your report - if
the query returns no data then you get an empty page
So if your query takes :P10_USERNAME variable then
pass it to the report in the URL
f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
AME:::P10_USERNAME:MYUSER
2/ try to use the Default layout first to check your
report query really returns the data when called
3/ if you defined a header in your rtf template check
there is no & (ampersand) - if using & in the header
and preview the template from word it displays data
OK, but if you use this template in the report query
it fails to render the data (bug in Apex-> Bi
Publisher integration maybe?)
4/ If using the table in the rtf template check its
width does not overflow the page margins - there is a
problem with pdf export
5/ check
/oc4j/j2ee/home/application-deployments/xmlpserver/app
lication.log forthe information on BI Publisher runs
RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
Thank you,
Tony Miller
UTMB/EHN -
How to dynamically update columns in a where clause to a SQL query in OSB?
Hi Gurus,
I have a requirement where in we need to dynamically update a where clause to a SQL query in OSB(11.1.1.6.0).
For example:
If the JCA sql string is "select * from emp where emp_id = 100 and emp_status ='Permanent'" now i want to change this where clause and the new query has to be like "select * from emp where emp_name like 'S%' and emp_dept like 'IT' ". basically we need to change the where clause dynamically.
We can also use "fn-bea:execute-sql()" in a xquery but I don't want to use this function as creates a new connection.
I have done some home work and found out --> as per the DOC "http://docs.oracle.com/cd/E23943_01/dev.1111/e15866/jca.htm#OSBDV943" section: "25.5.2 JCA Transport Configuration for Proxy and Business Services", when a business service is created by using JCA, we can see Interaction Spec Properties under JCA Transport Tab. This will have a property "SqlString' and we can over ride it. But I am unable to figure out how to over ride the value. I have tried by using Transport Headers activity but no luck. Please guide me how to achieve this?
Thanks in advance
SuryaI solved my problem.
In my header renderer, I simply added a line to set the text to the object value "label.setText( (String) value );" (where label is an instance of a JLabel.
Thank you to who took some time to think about it.
Marc -
SQL query - Alias name (value) as parameter to an Oracle function
Hi,
I have a sql query something like
Select tbl1.valueA, tbl1.valueB, tbl2.valueX, MAX(CASE tbl2.valueY = 'XX' THEN tbl2.valueZ END) AS "ValueZ header", Function(tbl1.valueB, tbl2.valueX, "valueZ header")
FROM table1 tbl1
JOIN table2 tbl2 ON tbl1.id = tbl2.tbl1id
WHERE ...
my problem is that I need the value from MAX statement as parameter to the function and I have tried to use the alias name (valueZ header) but this is not working. I guess because of some syntax error. Can I use alias name as parameter into the function at all - if - how should I do this?Hi,
user8819407 wrote:
Hi,
I have a sql query something like
Select tbl1.valueA, tbl1.valueB, tbl2.valueX, MAX(CASE tbl2.valueY = 'XX' THEN tbl2.valueZ END) AS "ValueZ header", Function(tbl1.valueB, tbl2.valueX, "valueZ header")
FROM table1 tbl1
JOIN table2 tbl2 ON tbl1.id = tbl2.tbl1id
WHERE ...
my problem is that I need the value from MAX statement as parameter to the function and I have tried to use the alias name (valueZ header) but this is not working. I guess because of some syntax error. Can I use alias name as parameter into the function at all - if - how should I do this?You can use a column alias in the ORDER BY clause of the same query where it was defined, but that's the only place where you can use it in that query.
You could repeat the entire MAX (CASE ...) expression as the 3rd argumnet to your function, or you could compute it once in a sub-query, then reference the column alias as often as you like in the super-query, like this:
WITH got_valuez_header AS
Select tbl1.valueA
, tbl1.valueB
, tbl2.valueX
, MAX ( CASE
WEHN tbl2.valueY = 'XX' -- Don't forget the keyword WHEN
THEN tbl2.valueZ
END
) AS "ValueZ header"
FROM table1 tbl1
JOIN table2 tbl2 ON tbl1.id = tbl2.tbl1id
WHERE ...
GROUP BY ...
Select tbl1.valueA
, tbl1.valueB
, tbl2.valueX
, "ValueZ header"
, Function_x ( tbl1.valueB -- FUNCTION is not a good name for a function
, tbl2.valueX
, "ValueZ header" -- Case-sensitive
FROM got_valuez_header
; -
Default value of date picker not showing in sql query
Hi,
I have a tabular form page with a query similar to the following:
select emp_name, salary from emp_table where trunc(hire_date)=trunc(to_date(:P42_START_DATE))
where P42_START_DATE is the name of a date picker item.
I set the source type of the date picker to be "Only when current value in session state is null" and the value to be "select trunc(next_day(sysdate,'MON')-7) from dual;" - basically the monday of the current week. I set the sequence of the date picker to be 5, and the sequence of the region to be 10. Now, when I open this page, no data gets pulled. I checked the page source, and the value of the date picker input is being set to "17-NOV-2008", but it somehow isn't reflected in the sql query.
Data does get retrieved if I manually set the date in the date picker, but I'd like it to default to the monday of the current week. What am I doing wrong?
Thanksnope, still same problem.
I used javascript alerts to help debug, and here might be some useful information.
The computation to set the value of :P42_START_DATE is set to run "before header", but when I put this following javascript in the header:
<script language="javascript">
var c = $v('P42_START_DATE');
alert(c);
</script>
the alert box is blank (ie :P42_START_DATE is empty). Putting the same exact script in the footer gives 24-Nov-2008 in the alert box. Now, the SQL query is run sometime after the first alert and before the second alert, I believe. Why would the value of :P42_START_DATE not be getting set at the correct time?
P42_START_DATE is a date picker item that belongs to the region SCHEDULE (which is where the sql query is). I set the sequence of the region to 10, and the sequence of the date picker and computation to be 5 and 6. Even so, does this mean that the sql query is executing before the call to the computation, because the region needs to be created before any items can be created that belong to the region? -
SQL query using Group by and Aggregate function
Hi All,
I need your help in writing an SQL query to achieve the following.
Scenario:
I have table with 3 Columns. There are 3 possible values for col3 - Success, Failure & Error.
Now I need a query which can give me the summary counts for distinct values of col3 for each GROUP BY of col1 and col2 values. When there are no values for col3 then it should return ZERO count.
Example Data:
Col1 Col2 Col3
abc 01 success
abc 02 success
abc 01 success
abc 01 Failure
abc 01 Error
abc 02 Failure
abc 03 Error
xyz 07 Failure
Required Output:
c1 c2 s_cnt F_cnt E_cnt (Heading)
abc 01 2 1 1
abc 02 1 1 0
abc 03 0 0 1
xyz 07 0 1 0
s_cnt = Success count; F_cnt = Failure count; E_cnt = Error count
Please note that the output should have 5 columns with col1, col2, group by (col1,col2)count(success), group by (col1,col2)count(failure), group by (col1,col2)count(error)
and where ever there are NO ROWS then it should return ZERO.
Thanks in advance.
Regards,
ShivaHi,
user13015050 wrote:
Thanks TTT. Unfortunately I cannot use this solution because I have huge data for this.T's solution is basically the same as mine. The first 23 lines just simulates your table. Since you actually have a table, you would start with T's line 24:
SELECT col1 c1, col2 c2, SUM(decode(col3, 'success', 1, 0)) s_cnt, ...
user13015050 wrote:Thanks a lot Frank. It helped me out. I just did some changes to this as below and have no issues.
SELECT col1
, col2
, COUNT ( CASE
WHEN col3 = 'SUCCESS'
THEN 1
END
) AS s_cnt
, COUNT ( CASE
WHEN col3 = 'FAILED'
THEN 1
END
) AS f_cnt
, COUNT ( CASE
WHEN col3 = 'ERROR'
THEN 1
END
) AS e_cnt
FROM t1
WHERE c2 in ('PURCHASE','REFUND')
and c4 between to_date('20091031000000','YYYYMMDDHH24MISS') AND to_date('20100131235959','YYYYMMDDHH24MISS')
GROUP BY c1, c2
ORDER BY c1, c2;
Please let me know if you see any issues in this query.It's very hard to read.
This site normally compresses spaces. Whenever you post formatted text (such as queries or results) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
Also, post exactly what you're using. The code above is SELECTing col1 and col2, but there's no mention of either in the GROUP BY clause, so I don't believe it's really what you're using.
Other than that, I don't see anything wrong or suspicious in the query. -
Item Selection on a dynamic LOV (SQL Query)
Hi,
I've a dynamic LOV with an SQL query who return a list of data (one column). When i select a data in this LOV to be use as an item (sql query) in the same page the data is always null. In debug mode substitution string is null.
FYI : when the data is selected, a button is clik to perform an sql query for a report in another page.
Thanks. Sorry Abasolute beginner
Message was edited by:
user581765Thanks for Your help.
The date is in fact a CHAR display (not really a date) so that is not the error.
For your information when i select a row in the list (format char YYYYMMDD_HHMM) it seems that Apex do not catch my select in the Session state.
I've change the item name with P2_DATE_FLOW but the problem remain.
This is the debug log if can help
0.03: Application 114, Authentication: CUSTOM2, Page Template: 3644802034190382
0.06: ...Session ID 1868105032215374 can be used
0.06: ...Application session: 1868105032215374, user=Neop
0.06: ...Determine if user "Neop" workspace "2859608277950243" can develop application "114" in workspace "2859608277950243"
0.06: Session: Fetch session header information
0.06: ...Metadata: Fetch page attributes for application 114, page 3
0.06: Fetch session state from database
0.06: Branch point: BEFORE_HEADER
0.06: Fetch application meta data
0.08: Computation point: BEFORE_HEADER
0.08: Processing point: BEFORE_HEADER
0.08: Show page template header
0.08: Computation point: AFTER_HEADER
0.08: Processing point: AFTER_HEADER
0.08: Computation point: BEFORE_BOX_BODY
0.08: Processing point: BEFORE_BOX_BODY
0.08: Region: Report 1
Report 1
0.08: show report
0.09: determine column headings
0.09: parse query as: CFM_MDRE
0.12: binding: ":P2_DATE_FLOW"="P2_DATE_FLOW" value="0"
0.14: print column headings
0.14: rows loop: 15 row(s)
No data found. -
Hi all,
I've been beating my head against this for a few days now, and while
there is a workaround, I haven't found out what's causing this to
happen.
Every other SQL query except for this one particular query works fine
and returns a scrollable result set. That one query on the other hand,
returns a non-scrollable result set.
Here's the code which is calling the query:
sqlStatement = getSQLFromFile();
debug("SQL statment = " + sqlStatement);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
debug(sqlStatement);
rst = stmt.executeQuery(sqlStatement);
debug("The type is " + rst.getType());
rst.last();
For most queries, the output is "The type is 1004" - which means the
resultset is scrollable - as it should be.
For one particular query, the output is "The type is 1003" which means
that the result set is of type forward-only.
Of course, calling rst.last() fails in the second case.
If the difference between the queries was drastic, I might have
something to go on. I've tested this out with different size queries,
but the switch between having the type incorrectly changed is the
deletion of a 0x0a 0x0d on the first line.
I.E. this means the failing query reads :
"select
from........."
and the query which works reads
"select *
from........."
I've looked at the failing query in it's binary format, and that's the
only difference I can discern.
To further confuse things, there are other queries which have a
similar format - and which work.
I've read about a bug in Weblogic 5.1 SP9 which ignores the setting of
the Statement to return a ResultSet with a scrollable cursor, and
while this seems to be a bug, it doesn't seem the same bug at all -
besides, I'm using Weblogic 6.0 with SP1 on a W2K system.
Does anyone have any ideas as to what might be causing this? I'm
stumped..Ryan D'Silva wrote:
Hi Joe,
I'm using the Oracle thin driver -
oracle.jdbc.driver.OracleDriver - version #8.1.6.0.0
and the DBMS is
"Oracle9i Enterprise Edition Release 9.2.0.2.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.2.0 - Production"
Does that help?Yes. Two things: TYou should probably upgrade the oracle thin
driver, by downloading the latest appropriate one from their site,
and make sure it's ahead of all weblogic jars in the classpath the
server builds for itself. Also, let's see how simple we can make the
problem. Would you please repeat the JDBC that demonstrated the problem,
in a small standalone java program that uses a direct thin driver connection,
getting weblogic out of the picture? (The problem does sound like
and oracle driver issue).
Joe
>
>
Thanks,
- ryan
You don't say what DBMS and what JDBC driver you're using for the pool.
That is likely to be the issue. Let me know.
Joe
Here's the code which is calling the query:
sqlStatement = getSQLFromFile();
debug("SQL statment = " + sqlStatement);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
debug(sqlStatement);
rst = stmt.executeQuery(sqlStatement);
debug("The type is " + rst.getType());
rst.last();
For most queries, the output is "The type is 1004" - which means the
resultset is scrollable - as it should be.
For one particular query, the output is "The type is 1003" which means
that the result set is of type forward-only.
Of course, calling rst.last() fails in the second case.
If the difference between the queries was drastic, I might have
something to go on. I've tested this out with different size queries,
but the switch between having the type incorrectly changed is the
deletion of a 0x0a 0x0d on the first line.
I.E. this means the failing query reads :
"select
from........."
and the query which works reads
"select *
from........."
I've looked at the failing query in it's binary format, and that's the
only difference I can discern.
To further confuse things, there are other queries which have a
similar format - and which work.
I've read about a bug in Weblogic 5.1 SP9 which ignores the setting of
the Statement to return a ResultSet with a scrollable cursor, and
while this seems to be a bug, it doesn't seem the same bug at all -
besides, I'm using Weblogic 6.0 with SP1 on a W2K system.
Does anyone have any ideas as to what might be causing this? I'm
stumped..
Maybe you are looking for
-
Hello everybody! Being Italian I apologise in advance for my english, if something isn't clear feel free to ask! Now, to the problem: since two days I'm unable to use iTunes Match at all. In the past days I was organising my library in playlists, whe
-
Nokia Lumia 1320 Desktop connectivity
Hello All, I habe Problem with my phone while connecting with laptop
-
I was wondering if anyone had a LabVIEW driver for the USB version of the Garmin GPS-18. Dave David Thomson Original Code Consulting www.originalcode.com National Instruments Alliance Program Member Certified LabVIEW Architect There are 10 kinds of p
-
I have only 66 cents left in my apple ID, how can I remove the balance?
0.66$
-
Itunes not liking new computer
My old computer fried and I had to pick up a new one obviously. My wife and I both have ipod nanos and now we're having problems getting the ipods to work with itunes. Something to do with the authorized purchases. I just recently put in new tunes as