Using Parameters in SQL-Query not only in where clauses
Hi,
I try to use Publisher parameters in the SQL Query from a Data Set.
All of them have default values.
So far, this is no problem, unless I try to use such a parameter value as an ordinary attribute value:
>
select
case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."BETR_TEIL"
else :pv_some_Text end as Betr_Teil,
case when (:pv_Group = 'no') then "DM15D_BETRIEBSTEIL"."SUVA_NR_FORM"
else :pv_some_Text end as Suva_Nr,
case when (:pv_Group = 'no') then "DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH"
else sum("DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") end as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in (:pv_nim100)
fetch first 65001 rows ONLY
>
The parameters 'pv_Group' and 'pv_nim100' are working fine. (when or where clauses)
The parameter 'pv_some_Text' unfortunately not. (simple literals)
When I try to validate the above SQL, I get the following Error:
<font color="red">
java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46033] Datatype: 25 is not supported.
</font>
After use a cast function:
>
else CAST(:pv_some_Text AS CHARACTER)
>
I get this ERROR:
<font color="red">
java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 19002] Incorrect use of parameters. The parameters used in CAST cannot be resolved without ambiguity.
</font>
We use OBIEE 11.1.1.6.4 on a Win64-System.
Thank's for any help.
Hi Alex,
let's leave away any unnecessary details.
This is the SQL, inserted in the window 'Edit Data Set' of BIP Data Model:
>
select
'--1' as Betr_Teil,
'--2' as Suva_Nr,
sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
fetch first 65001 rows ONLY
>
Everything is fine when I click OK, the script goes back to the metadata.
Let's try this script with bind values in ORACLE SQL Developer.
This SQL is the physical part, found in the OBIEE-Log (Log level 5), except the bind values. Therefore we find, in the where clause, the join. In the logical sql, we don't have to join, because it's handled in the Common Enterprise Information Model (CEIM)
>
with
sawith0 as
select
sum(t39617.ris_vollbesch) as c1
from
dm15d_betriebsteil t39455,
dm15k_ris_fakten_pro_btt_jhr t39617
where
t39455.id_betriebsteil = t39617.id_betriebsteil
and t39455.suva_nr_form = '122-4.4'
select
d1.c1 as c1,
d1.c2 as c2,
d1.c3 as c3
from
select
:pv_some_text as c1,
:pv_some_text as c2,
sum(d1.c1) as c3
from
sawith0 d1
d1
where
rownum <= 65001
>
This SQL works fine, even with bind values for 'pv_some_text'.
But, when using the following SQL in the BIP Data Model:
>
select
:pv_Text as Betr_Teil,
:pv_Text as Suva_Nr,
sum("GDWH05"."DM15K_RIS_FAKTEN_PRO_BTT_JHR"."RIS_VOLLBESCH") as Vollbesch
from "GDWH05"
where
"DM15D_BETRIEBSTEIL"."SUVA_NR_FORM" in ('122-4.4')
fetch first 65001 rows ONLY
>
The following ERROR occurs:
<font color="red">java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 46008] Internal error: File server\Query\Optimizer\ServiceInterfaceMgr\Utility\Src\SQOIUTypeVisitor.cpp, line 643.</font>
In my opinion, either I use a wrong syntax, or BIP has a problem with parsing the script.
Thank you for your most welcome help.
Similar Messages
-
SQL QUERY How to write a sql query with a complex where clause.
I would like to get a list of all my invoices from the past year plus any open invoices that are more than a year old.
I don't want any overlapping rows.
Debra has a questionDebra,
Sorry but you have posted to a forum that deals exclusively with questions/issues about customizing and programming Microsoft Project, a planning and scheduling application. I suggest you delete this post and find a more appropriate forum.
John -
Adding h:dataTable with parameters in SQL query
Hi,
I've added a h:datatable to my web app in netbeans. I need this table to display records based on a sql query that contains a WHERE clause that has the currently logged-in user's id.
Further I need a column with buttons that each perform an operation based on the primary key of the selected row.
I have no Idea how to do any of this.
Could anyone please help where to start or point me to a good tutorial.
ThanksHi BalusC.
Thanks for the reply.
Coincidentally I discovered your blog shortly after posting this question, and it has been a great help, thanks!
I have another related problem now however. I am trying to display messages from the database, and then to allow a user to reply to these messages.
Everything displays correctly and when I click on the reply link the right text area becomes visible, but for some reason, the action event of the last command button does not fire.
Could you please help me figure out why it doesn't work.
I also don't know how to retrieve the message from the right text area input.
Thanks
Here's the code in my Home.jsp
<h:dataTable binding="#{Home.messageTable}" id="messageTable" value="#{Home.messages}" var="dataItem">
<h:column>
<f:facet name="header">
<h:outputText value=""/>
</f:facet>
<h:panelGroup layout="block" styleClass="message_main">
<h:outputText styleClass="message_label" value="FROM :"/>
<h:outputText styleClass="message_data" value="#{dataItem.sender}"/>
<h:outputText styleClass="message_label" value="DATE :"/>
<h:outputText styleClass="message_data" value="#{dataItem.dateString}"/>
<h:outputText styleClass="message_label" value="SUBJECT :"/>
<h:outputText styleClass="message_data" value="#{dataItem.subject}"/>
<h:outputText styleClass="message_label" value="MESSAGE :"/>
<h:outputText styleClass="message_body" value="#{dataItem.message}"/>
<h:commandLink styleClass="message_label" action="#{Home.selectMessage}" value="Reply" />
<h:panelGroup rendered="#{dataItem.selected}" layout="block" styleClass="reply_panel">
<h:outputText styleClass="message_label" value="Enter reply:"/>
<h:inputTextarea styleClass="message_body" />
<h:commandButton action="#{Home.sendReply}" styleClass="message_label" value="Send Reply" />
</h:panelGroup>
</h:panelGroup>
</h:column>
</h:dataTable>And the related methods
public String sendReply()
Message msg = (Message)messageTable.getRowData();
msg.sendReply(?);// Needs the string value of the correct text area
msg.setSelected(!msg.isSelected());
return null;
public String selectMessage()
Message msg = (Message)messageTable.getRowData();
msg.setSelected(!msg.isSelected());
return null;
} -
Hi,
I would like to konw how I can make multiple parameters to sql query string seperated by ,(comma) ..
For example, this parameters can be printed like 'abc,dde,ggf,eeg' ,once I use "join(Parameters!rpCode.Value,",")" with report builder ,
By the way, when I test this multiple parameters by Query Designer of report builder there was no problem,.(using Define query parameters, I put abc,dde,ggf,eeg)
however, when I run this report , it won't be executing , with (rsErrorExecutingCommand)
Plz, help me....If its sql query then it should like this
Select t.*
from table t
inner join dbo.ParseValues(@Parameters,',')f
on f.val = t.ID
ParseValues can be found him
http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
or easier way is
Select t.*
from table t
where ',' + @Parameters + ',' LIKE '%,' + CAST(t.ID AS varchar(10)) + ',%'
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Use a manual SQL query in an interface
Hello,
I would like to know if I can use a manual SQL query in an interface.
Here is what I need.
I have two tables.
T1 with 4 fields :
idT1, LibC, val, lib_val
An example of a line from T1
1, field1, 33 , value 33
2, field2, 44 , value 44
And table T2 with fields such as:
idT2, ... , field1, field2
There is no key to join T1 and T1, but I should retrieve the value of field lin_val from T2 which corresponds to the value of field1.
In SQL, the query looks like this:
SELECT t2.lib_val
FROM t2 , t1
WHERE T2.LibC = "Column_name"
AND T2.val = T1.Column_name
AND t1.idT1 = xyzYou should go for yellow interface.It will solve your problem. Here you go
http://odiexperts.com/how-to-create-a-temp-table-in-odi-interface/
https://blogs.oracle.com/warehousebuilder/entry/odi_11g_simple_flexible_powerful
Thanks. -
SQL query not calculating
gross_amount is giving the value of extended_amount and the gross_price_rc is giving the value of unit_selling_price
select customer_trx_line_id,
( extended_amount / 1- (decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) GROSS_AMOUNT,
( unit_selling_price /1-(decode(decode(attribute6,null,0)+decode(attribute7,null,0)+decode(attribute8,null,0)+decode(attribute9,null,0)/100,null,0,1,0))) gross_price_rc
from ra_customer_trx_lines_all
where attribute6 is not null or attribute7 is not null or attribute8 is not null or attribute9 is not null
whats the isuue here??
Thanksdecode(attribute7,null,0)Looking at it again, this always returns 0 or NULL, so it not really surprising
DECODE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions040.htm#i1017437
CASE
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions004.htm#i1033392 -
How to manage a "nice" url if APEX uses web pl/sql and not Apache?
Hi all,
How can I create a pretty url without using redirects or frames since APEX is using web pl/sql and not Apache? This is on version 4.0.1. We want the users to access the Apex App from a nice url without the traditional long url.
Thanks,
Veena.How can I create a pretty url without using redirects or frames since APEX is using web pl/sql and not Apache? This is on version 4.0.1. We want the users to access the Apex App from a nice url without the traditional long url.Hi,
check out the last part of this blog post:
http://ora-00001.blogspot.com/2009/07/creating-rest-web-service-with-plsql.html
- Morten
http://ora-00001.blogspot.com -
SP2-0575: Use of Oracle SQL feature not in SQL92 Entry Level.
Hi,
When I tried to login I am able to login but getting the following message:SP2-0575: Use of Oracle SQL feature not in SQL92 Entry Level.
After loging, when I tried to "SELECT SYSDATE FROM DUAL;" I am getting the following error.
ORA-00942: table or view does not exist
Can somebody please help me ?this error may be related to glogin.sql files content, what are the outputs for these -
SQL> describe dual ;
Name Null? Type
DUMMY VARCHAR2(1)
SQL> select * from dual ;
D
Xbest regards. -
Sp2-0575: Use of oracle SQL feature not in sql 92 entry level.
Hi,
While logging to sqlplus I'm getting the following message
"sp2-0575: Use of oracle SQL feature not in sql 92 entry level."
and login is successful, but I'm not able to generate next value from the sequence .
t says no rows selected when i request
for nextval a
EX: select mySeq.nextval from dual; (mySeq is sequence)
Thanx,
Ravi.What has happened is that someone has enabled the Oracle feature called as FIPS flagger.
This is a feature that Oracle provides to you if you plan to write SQL code that should be portable
to other RDBMS systems. IF you enable this flagger and use a feature which is not in the SQL standard,
Oracle will complain that use of this feature will make your application Oracle dependent, and you may not
be able to run this application against any other RDBMS.
To disable this for your SQL*Plus session do this:
SQL> set flagger off
SQL>
Once you do this it will allow you to use all SQL commands including Oracle specific extensions. -
Case Working in "TOAD" but not Working in "WHERE" clause
Hi Friends,
When I am using case in the where clause of SQL query in Oracle Reports 3.0.5, than it is giving me "Error - Rep - 0946 Unable to Parse Query"
But when I am running the same query in TOAD it is working fine.
select *from inv_stores, inv_product, inv_location
where (inv_stores.location_code in ('12', '13', '16', '17', '18') and
inv_stores.location_code = inv_location.location_code and
inv_stores.department_code = inv_product.department_code and
inv_stores.product_code = inv_product.product_code and
nvl(delete_flag, 'N') <> 'Y' and
inv_product.department_code = '11' and
(((CASE WHEN nvl(inv_product.sale_price3jd,0) = 0 THEN 0 ELSE (nvl(inv_product.sale_price3jd,0) - nvl(inv_product.cost_pricejd,0)) /
nvl(inv_product.sale_price3jd,0) END) * 100 ) <= 100))
order by inv_product.department_code, inv_product.product_codePlease Help me.......
Thanks in AdvanceHello,
When you create a SQL query in Reports, Reports will parse the SQL query in order to create the "data model".
Reports 3.0.5 is quite old, so, you can use only the SQL "supported" by the RSF included in Reports 3.0.5.
When you use TOAD , the sql query is not parsed by TOAD but by the DB just like with sqlplus or SQL Developer.
Regards -
Sql query not executed using recordset
Hi All,
I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
Dim AltProc as string
AltProc = " USE [DB_name]" & Environment.NewLine
AltProc = AltProc & " GO " & Environment.NewLine
AltProc = AltProc & " ALTER proc [proc_name] " & Environment.NewLine
'---------------------and so on
Orec.DoQuery(AltProc)
this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error. strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
any one has any idea?
thanks in advance,
BinitaHI Binita
The reason:
GO is the "command" delimiter of MS Query Editor.
It is not working with RecordSet Object.
In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
IN SQL 2008 use the Fully Qualified name instead of GO:
Dim AltProc as string
AltProc = " ALTER proc [DB_name].[dbo].[proc_name] " + vbcrlf
'---------------------and so on
Orec.DoQuery(AltProc)
it is not working on MS SQL 2008 i have tried.
'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
Regards,
J.
Edited by: Janos Nagy on Jun 22, 2009 2:55 PM -
SQL Query not using Composite Index
Hi,
Please look at the below query:
SELECT pde.participant_uid
,pde.award_code
,pde.award_type
,SUM(decode(pde.distribution_type
,'FORFEITURE'
,pde.forfeited_quantity *
pde.sold_price * cc.rate
,pde.distributed_quantity *
pde.sold_price * cc.rate)) AS gross_Amt_pref_Curr
FROM part_distribution_exec pde
,currency_conversion cc
,currency off_curr
WHERE pde.participant_uid = 4105
AND off_curr.currency_iso_code =
pde.offering_currency_iso_code
AND cc.from_currency_uid = off_curr.currency_uid
AND cc.to_currency_uid = 1
AND cc.latest_flag = 'Y'
GROUP BY pde.participant_uid
,pde.award_code
,pde.award_type
In oracle 9i, i"ve executed this above query, it takes 6 seconds and the cost is 616, this is due to non usage of the composite index, Currency_conversion_idx(From_currency_uid, To_currency_uid, Latest_flag). I wonder why this index is not used while executing the above query. So, I've dropped the index and recreated it. Now, the query is using this index. After inserting many rows or say in 1 days time, if the same query is executed, again the query is not using the index. So everyday, the index should be dropped and recreated.
I don't want this drop and recreation of index daily, I need a permanent solution for this.
Can anyone tell me, Why this index goes stale after a period of time???? Please take some time and Solve this issue.
-SankarHi David,
This is Sankar here. Thankyou for your reply.
I've got the plan table output for this problematic query, please go thro' it and help me out why the index CURRENCY_CONVERSION_IDX is used now and why it's not using while executing the query after a day or inserting some records...
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 26 | 15678 | 147 |
| 1 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 89 | 2 |
|* 2 | INDEX UNIQUE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 61097 | | 1 |
| 3 | SORT AGGREGATE | | 1 | 67 | |
|* 4 | FILTER | | | | |
|* 5 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | 67 | 2 |
| 6 | SORT AGGREGATE | | 1 | 94 | |
|* 7 | FILTER | | | | |
|* 8 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_PAYOUT_SCHEDULE | 1 | 94 | 3 |
|* 9 | INDEX RANGE SCAN | PART_AWARD_PAYOUT_SCHEDULE_PK1 | 1 | | 2 |
|* 10 | FILTER | | | | |
|* 11 | HASH JOIN | | 26 | 15678 | 95 |
|* 12 | HASH JOIN OUTER | | 26 | 11596 | 91 |
|* 13 | HASH JOIN | | 26 | 10218 | 86 |
| 14 | VIEW | | 1 | 82 | 4 |
| 15 | SORT GROUP BY | | 1 | 116 | 4 |
|* 16 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_LEDGER | 1 | 116 | 2 |
|* 17 | INDEX RANGE SCAN | PARTICIPANT_UID_IDX | 1 | | 1 |
|* 18 | HASH JOIN OUTER | | 26 | 8086 | 82 |
|* 19 | HASH JOIN | | 26 | 6006 | 71 |
| 20 | NESTED LOOPS | | 36 | 5904 | 66 |
| 21 | NESTED LOOPS | | 1 | 115 | 65 |
| 22 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 18 | 756 | 2 |
|* 23 | INDEX RANGE SCAN | KLS_IDX_CURRENCY_CONV | 3 | | 1 |
| 24 | VIEW | | 1 | 73 | 4 |
| 25 | SORT GROUP BY | | 1 | 71 | 4 |
| 26 | TABLE ACCESS BY INDEX ROWID| PART_AWARD_VALUE | 1 | 71 | 2 |
|* 27 | INDEX RANGE SCAN | PAV_PARTICIPANT_UID_IDX | 1 | | 1 |
| 28 | TABLE ACCESS BY INDEX ROWID | PARTICIPANT_AWARD | 199 | 9751 | 1 |
|* 29 | INDEX UNIQUE SCAN | PARTICIPANT_AWARD_PK1 | 100 | | |
|* 30 | INDEX FAST FULL SCAN | PARTICIPANT_AWARD_TYPE_PK1 | 147 | 9849 | 4 |
| 31 | VIEW | | 1 | 80 | 10 |
| 32 | SORT GROUP BY | | 1 | 198 | 10 |
|* 33 | TABLE ACCESS BY INDEX ROWID | CURRENCY_CONVERSION | 1 | 42 | 2 |
| 34 | NESTED LOOPS | | 1 | 198 | 8 |
| 35 | NESTED LOOPS | | 2 | 312 | 4 |
| 36 | TABLE ACCESS BY INDEX ROWID| PART_DISTRIBUTION_EXEC | 2 | 276 | 2 |
|* 37 | INDEX RANGE SCAN | IND_PARTICIPANT_UID | 1 | | 1 |
| 38 | TABLE ACCESS BY INDEX ROWID| CURRENCY | 1 | 18 | 1 |
|* 39 | INDEX UNIQUE SCAN | CURRENCY_AK | 1 | | |
|* 40 | INDEX RANGE SCAN | CURRENCY_CONVERSION_AK | 2 | | 1 |
| 41 | VIEW | | 1 | 53 | 4 |
| 42 | SORT GROUP BY | | 1 | 62 | 4 |
|* 43 | TABLE ACCESS BY INDEX ROWID | PART_AWARD_VESTING | 1 | 62 | 2 |
|* 44 | INDEX RANGE SCAN | PAVES_PARTICIPANT_UID_IDX | 1 | | 1 |
| 45 | TABLE ACCESS FULL | AWARD | 1062 | 162K| 3 |
| 46 | TABLE ACCESS BY INDEX ROWID | CURRENCY | 1 | 18 | 2 |
|* 47 | INDEX UNIQUE SCAN | CURRENCY_AK | 102 | | 1 |
Predicate Information (identified by operation id):
2 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2
"PAPS"."INSTALLMENT_NUM"=1)
4 - filter(4105=:B1)
5 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
7 - filter(4105=:B1)
8 - filter("PAPS"."STATUS"='OPEN')
9 - access("PAPS"."AWARD_CODE"=:B1 AND "PAPS"."PARTICIPANT_UID"=4105 AND "PAPS"."AWARD_TYPE"=:B2)
10 - filter("CC_A_P_CURR"."FROM_CURRENCY_UID"= (SELECT /*+ */ "CURRENCY"."CURRENCY_UID" FROM
"EWAPDBO"."CURRENCY" "CURRENCY" WHERE "CURRENCY"."CURRENCY_ISO_CODE"=:B1))
11 - access("SYS_ALIAS_7"."AWARD_CODE"="A"."AWARD_CODE")
12 - access("SYS_ALIAS_7"."AWARD_CODE"="PVS"."AWARD_CODE"(+))
13 - access("SYS_ALIAS_8"."AWARD_CODE"="PALS"."AWARD_CODE" AND
"SYS_ALIAS_8"."AWARD_TYPE"="PALS"."AWARD_TYPE")
16 - filter(TRUNC("PAL1"."LEDGER_ENTRY_DATE")<=TRUNC(SYSDATE@!) AND "PAL1"."ALLOC_TYPE"='IPU')
17 - access("PAL1"."PARTICIPANT_UID"=4105)
filter("PAL1"."PARTICIPANT_UID"=4105)
18 - access("SYS_ALIAS_8"."AWARD_CODE"="PDES"."AWARD_CODE"(+) AND
"SYS_ALIAS_8"."AWARD_TYPE"="PDES"."AWARD_TYPE"(+))
19 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_8"."AWARD_CODE")
23 - access("CC_A_P_CURR"."TO_CURRENCY_UID"=1 AND "CC_A_P_CURR"."LATEST_FLAG"='Y')
27 - access("PAV"."PARTICIPANT_UID"=4105)
filter("PAV"."PARTICIPANT_UID"=4105)
29 - access("SYS_ALIAS_7"."AWARD_CODE"="SYS_ALIAS_9"."AWARD_CODE" AND
"SYS_ALIAS_7"."PARTICIPANT_UID"=4105)
30 - filter("SYS_ALIAS_8"."PARTICIPANT_UID"=4105)
33 - filter("CC"."LATEST_FLAG"='Y')
37 - access("PDE"."PARTICIPANT_UID"=4105)
filter("PDE"."PARTICIPANT_UID"=4105)
39 - access("OFF_CURR"."CURRENCY_ISO_CODE"="PDE"."OFFERING_CURRENCY_ISO_CODE")
40 - access("CC"."FROM_CURRENCY_UID"="OFF_CURR"."CURRENCY_UID" AND "CC"."TO_CURRENCY_UID"=1)
43 - filter("PV"."VESTING_DATE"<=SYSDATE@!)
44 - access("PV"."PARTICIPANT_UID"=4105)
filter("PV"."PARTICIPANT_UID"=4105)
47 - access("CURRENCY"."CURRENCY_ISO_CODE"=:B1)
Note: cpu costing is off
93 rows selected.
Please help me out...
-Sankar -
Hi Forum
i made an application which run on JRun server.
In many of my jsps i used sql query like this:
" select id, name, rollno from student where add = 'jj';"
and retrieve the record from resultset like this:
rs.getString("id");
rs.getString("name");
rs.getString("rollno");
I got no error.
BUT WHEN I RETRIEVE THE RECORDS LIKE THIS
rs.getString("name");
rs.getString("id");
rs.getString("rollno");
i got the error:
java.sql.SQLException: [Oracle][ODBC]Invalid column number <1>.
I can not understand what is the problem ?
all the datatypes are correct.
all coding is correct.
and everything is correct.
pls help me & suggest a solution.
is there any problem of jdbc API OR of JRUN SERVER SETTINGS?
thanks
mail me at [email protected]
Arvind GoelI would advise against ever using SELECT * - the order of the columns is undetermined so you're bound to hit this problem sooner or later. Besides, it assumes the column names and you know what happens when you assume things...
I would recommend retrieving only the columns you need, in the order you want them and to call ResultSet.getXXX for each of the columns, in order. -
Question about using objects in SQL query.
I had posted this question in the SQL/PLSQL forum but I guess nobody took the time to understand exactly what I am asking so I decided to try here hoping to get the answer. So here is the thing:
I have created generic object type "tree" - the constructor takes as a parameter sql query which returns "node_id" and "parent_node_id" - this is all we need to have a tree. The object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
I also have departments table with the following fields: department_id, parent_department_id, department_name,...
all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
Now if I run the following query:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
Pls elaborate
GeorgeNot exactly sure what the question is...
As I understand, you are comparing the following two constructor calls:
+select.. tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") ... FROM ...+
+select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') ... FROM dual+
These calls are the same (besides the 1st one doing an immediate implicit call to a method of the object being constructed). The number of times these are being called depends on the number of times this SQL projection is applied - and that is determined by the number of rows being projected by the SELECT.
The latter one is against DUAL which only has a single row. So that constructor is only called once. The former can be against multiple rows. Obviously a single pass through a data set is desirable - which means that the sub-select (use by the constructor) should ideally only be executed once and makes the 2nd method more desirable.
However, I'm having a hard time understanding why the class and constructor are at all needed. Why pull data from a SQL table into PL memory? As that is where the class will need to cache and store the results of that construction parameter SQL SELECT. And once in PL memory, how does the object effectively access, search and use this cached data?
PL memory is expensive. It is not sharable.
PL data structures are primitive - these cannot be compared to SQL structures in the form of tables and columns that can be stored in a number of physical ways (index tables, hash tables, partitioned tables, clustered tables, etc). Cannot be indexed like SQL structures using B+tree, bitmap, function and other indexing methods. Cannot be sorted, grouped, analysed, filtered, etc like SQL structured data.
It makes very little sense to read SQL data into a class and then deal with that data, cached in expensive PL memory, using primitive PL structures.
And the same would be true if Java or C# was used. The best place for data is inside the SQL engine. That is the most superior environment for data. It can processes more data, scale better, perform better and offer more flexibility, than pulling data from it and then crunch that data using PL or Java or C#. -
Use parameters in SQL Server reporting services with sharepoint lists
I want to make report from sharepoint 2010 list and forms library in sql server reporting services.
but also want to apply parameters.
I tried but parameters but it is not working.
How I can apply sharepoint lists parameters in sql server reporting services ?
How to run or view report of sharepoint lists or form library in sqlserver reporting services with required parameters?Hi John,
When we use SharePoint list as datasource in SSRS it has two method to add parameter. Suppose we have a dataset (DataSet1) get data from SharePoint list. Please refer to the methods below.
Method 1: We can add parameter in the Query Designer dialog box to add parameter.
Click “Add Filter” icon in the “Applied filters” dialog box in Query Designer.
Select the corresponding field (Title), fill with specific conditions, and select Parameter option in the end of the row.
Create a dataset (DataSet2) fill with Title field.
Double click the parameter we create above, set the available values from DataSet2 field Title.
(Note: In the situation, we are get the single-value parameter.)
Method 2: It is a general method to add parameter in SSRS report.
Create another dataset (DataSet2) in the report fill with Title field.
Add a parameter (Title) get available values from DataSet2 Title field.
Add filter in the DataSet1.
(Note: This method, we can configure multi-values parameter.)
Reference:
http://technet.microsoft.com/en-us/library/aa337432(v=sql.105).aspx
If you have any questions, please feel free to let me know.
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support
Maybe you are looking for
-
How to create business card in the contact list
I would like to create a buisness card to share with other people. What the best way to do that in the contact list.
-
HELP - the application Adobe Illustrator CS2 quit unexpectly
Hi, I have a room of networked Mac's (G4) OS 10.4.6 and we have had all twenty machines running CS2 and everything working fine. Now that the machines haven't been used for a while I can only get 7 of the machines to work on CS2. I get this error mes
-
Pan and Zoom Effect, which PE version introduced it?
I like my PE 3.0 but it does not seem to offer the Pan and Zoom effect. Or am I just not seeing it. Does anyone know which later version introduced it? I know 8.0 has it, but when did it come along? The bundled version of Photoshop 5.0 it came with
-
I would like to programmatically call (load and unload) subroutines from a VI. There must be a way to do it, but I haven't quite figured it out. First the scenario: ABSTRACT SCENARIO: I have a LabView VI that will end up being compiled into an EXE.
-
Provide a start path (folder) in a file dialog box
Is there a way to have a file dialog box start in a specific folder without using the File Dialog express VI? (I also don't want to use a system exec). Thanks. Richard Solved! Go to Solution.