Simple SQL Query and Parameters and LOV
Newbie and trying to work thru building a simple sql query with a single table query and use a parameter and lov.
Can anyone point me to an example.
simple query:
select cust_id, name_desc, name_add1, name_add2, name_city
from customer_table
where cust_id = :cust_parm
This works in straight sql and in the query builder by prompting for the customer ID. When building a parameter using LOV or search, it doesn't seem to detect the variable.
Thanks..
DD
If you are using version 11g, then as soon as you save the query in the data model, it should notice the parameter and ask if you want to add the parameter to the data model. What version of BIP are you using?
What happens if you exclude the parameter from the query and simply hard-code the criteria? Can you generate XML data?
From your wording, it sounds like you're trying to create a parameter from the LOV dialog. LOVs and parameters are totally distinct. After each are created separately, then you configure the parameter to use the LOV.
Similar Messages
-
Size of SQL query before execution and after execution
hi all
I need help on how can i find out the size of SQL query before execution and after execution in java
The query can be any query select / insert / update
Can anyone help me if any system tables help to find out the required size i mentioned
Urgent help is required
Thanking in advanceI need the size in terms of bytes
like the rquirement is stated as below
select ................: 10 B , return 250 B
so i need size before and after execution in terms of bytes -
Simple SQL query statement is needed
I need a simple SQL query to fetch records which is existed in all the departments.
for example: i want to list the employees which are existed in each and every department.. not sure how should i get those.. will anyone help me please.. thanks in advanceI think it would be wise to go to the following training:
Oracle Database <version> : Introduction to SQL
You will get the information you are looking for in five days. You can go find a tutorial on ANSI SQL, as advised by this board for free, to fix your immediate problem with a simple query. But, I personally recommend a more formal class specific to Oracle, as you will also get information about PL/SQL, and you get the benefit with working with other DBA/programmers when you are learning. This will solve your immediate issue, and any future issues with the language.
You can find it in the Education section of the Oracle website. -
Different LOV behavior between SQL query data model and data template
I have noticed different behavior when using parameters linked to list of values (LOV) of type menu with the multiple selection option enabled and a SQL query data model vs a data template. Here's the example because that first sentence was probably really confusing.
SQL Query:
select
plmc.MonthCode, plmc.ModalityDim, plmc.ModalityName,plmc.RegionDim
from
DataOut.dbo.PatientLabMonthlyCross plmc
where
plmc.MonthCode = 200202
and plmc.RegionDim = 1209
and 1 =
case
when coalesce(:modalityDim,null) is null
then 1
else
case
when plmc.ModalityDim in (:modalityDim)
then 1
else 0
end
end
Putting BI Publisher into debug mode, defining a data model of type SQL Query, defining a parameter called :modalityDim linked to a LOV that allows multiple selections, and selecting a couple of values from the LOV the output of the prepared statement is:
[081607_122647956][][STATEMENT] Sql Query : select
plmc.MonthCode,
plmc.ModalityDim,
plmc.ModalityName,
plmc.RegionDim
from
DataOut.dbo.PatientLabMonthlyCross plmc
where
plmc.MonthCode = 200202
and plmc.RegionDim = 1209
and 1 =
case
when coalesce(?,?,null) is null
then 1
else
case
when plmc.ModalityDim in (?,?)
then 1
else 0
end
end
[081607_122647956][][STATEMENT] 1:6
[081607_122647956][][STATEMENT] 2:7
[081607_122647956][][STATEMENT] 3:6
[081607_122647956][][STATEMENT] 4:7
[081607_122654713][][EVENT] Data Generation Completed...
[081607_122654713][][EVENT] Total Data Generation Time 7.0 seconds
Note how the bind variable :modalityDim was changed into two parameters in the prepared statement.
When I use this same SQL Query in a data template the output is:
[081607_012113018][][STATEMENT] Sql Query : select
plmc.MonthCode,
plmc.ModalityDim,
plmc.ModalityName,
plmc.RegionDim
from
DataOut.dbo.PatientLabMonthlyCross plmc
where
plmc.MonthCode = 200202
and plmc.RegionDim = 1209
and 1 =
case
when coalesce(?,null) is null
then 1
else
case
when plmc.ModalityDim in (?)
then 1
else 0
end
end
[081607_012113018][][STATEMENT] 1:'6','7'
[081607_012113018][][STATEMENT] 2:'6','7'
[081607_012113574][][EXCEPTION] java.sql.SQLException: Syntax error converting the nvarchar value ''6','7'' to a column of data type int.
Note the exception because it is trying to convert the multiple parameter values.
Am I doing something completely wrong here? I really need to use a data template because I will need to link a couple of queries together from different database vendors.
-markThis is for 10.1.3.4 - because in 11g every SQL query is automatially part of a data model.
In 10g SQL query is for simple unrelated SQL queries.
If you need to use advance features such as:
a) multiple SQL queries that are joined in master-detail relation ships
b) before/after report triggers
Then you will need to use the data template, which is an XML description
of the queries, links, and PL/SQL calls.
hope that helps,
Klaus -
Query Bind Parameters and LOV's [JHS 10.1.3.1]
Using the JHeadstart Developer's Guide instructions (starting section 3-69) I have started to learn and then implement Query Bind Parameters in JHeadstart - but I am being met with nothing but troubles.
Is there anything 'special' that I have to do in order to get a query bind parameter to work with a LOV? I have followed the instructions in the Developer's Guide but just replaced the bind parameters that would otherwise be in a Dynamic Domain into a LOV group in the JHeadstart Application Definition file..
To be precise about all of this, I have been trying to get this to work with the HR database schema. So, like in the mini-tutorial I have a query bind parameter on a Employee table View Object set as a LOV to the ManagerId field on the Departments View Object (set in Form View).
What is actually happening when I open up my LOV, is that no rows are ever displayed in the LOV pop-up window.
What am I doing wrong?Michael,
Take a look at this thread:
Re: Group Used as LOV does not return records
You have to use a managed bean to "communicate" the value of the Employees base page to the LOV page definition.
Steven Davelaar,
Jheadstart Team. -
SQL query with JSP and WML-parameters
Hey,
Could you help me?
I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
/*parameter sending from card 1 to card help*/
out.println("<go href='#helpcard'>");
out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
/*parameter read with WML in card help */
<p>Valitse kurssi.
$valittukurssi</p>
/'parameter read with JSP by generating WML with JSP*/
out.println("<p>$valittukurssi</p>");
/* SQL query with JSP */
ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
Thanks,
RampeYou're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
>
/*parameter sending from card 1 to card help*/
out.println("<go href='#helpcard'>");
out.println("<setvar name='valittukurssi'
value='$(valittukurssi)'/>");
Above you set a var that will work on the phone, not in JSP.
/*parameter read with WML in card help */
<p>Valitse kurssi.
$valittukurssi</p>
Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
/'parameter read with JSP by generating WML with
JSP*/
out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
<p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
out.println("<go href='#helpcard'>");
String some_name = "valittukurssi";
out.println("<setvar name='"+some_name+"'
value='$("+some_name+")'/>");
//note that you may have to escape the ( and ) with a \
//so we displayed the variable above into the WML page, now we can use it in the SQL query:
/* SQL query with JSP */
ResultSet uudettulokset =
uusilause.executeQuery("select * from kurssi where
lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
Frank Krul
Got Node? -
Sql query usig round and decode together
can i get one sql quer for returning whole number using round and decode function
eg:
the value 47
if value=47
then
the query should return 50
if the value =44
then
the quer should return 40
pls give me sql query for above example using round and decode function
Edited by: user11368167 on Jul 9, 2009 3:35 AMA wild guess. If you want the ROUND Function to work only when your column value is 44 or 47 then you could use something like:
SQL> WITH test_tab AS
2 (SELECT 44 col_1
3 FROM DUAL
4 UNION ALL
5 SELECT 15 col_1
6 FROM DUAL
7 UNION ALL
8 SELECT 47 col_1
9 FROM DUAL
10 UNION ALL
11 SELECT 45 col_1
12 FROM DUAL)
13 -- end of test data
14 SELECT col_1,
15 DECODE (col_1,
16 44, ROUND (col_1, -1),
17 47, ROUND (col_1, -1),
18 col_1
19 ) rounded_value
20 FROM test_tab
21 /
COL_1 ROUNDED_VALUE
44 40
15 15
47 50
45 45
4 rows selected.
SQL> CASE Statement can be used as well instead of DECODE.
Good Luck,
Regards,
Jo -
Having troubles passing values of Shuttle control to SQL Query of Report and Chart Region
Hello,
I am very new to APEX and need help for one of the Pa.I have a shuttle control on my page which populates Categories. Once user selects Categories from this control, I wish to pass the values to following SQL query :
select * from emp_class where category IN ( LIST of VALUES FROM RIGHT SIDE SHUTTLE).
I tried various ways of doing this including writing a java scripts which reads shuttle value, converts it into below string
'Category1',Category2',Category3'. Then I set this value to a text box. And then I was expecting that below trcik would work
select * from emp_class where category IN (:TXT_VALUES)
I am sure this is not right way and hence its not working. Can you please guide me here with options?
Many Thanks,
Tushb96402b4-56f7-44ba-8952-fb82a61eeb2c wrote:
Please update your forum profile with a real handle instead of "b96402b4-56f7-44ba-8952-fb82a61eeb2c".
I am very new to APEX and need help for one of the Pa.
Don't understand what this means. What is "Pa"?
select * from emp_class where category IN (:TXT_VALUES)
I am sure this is not right way and hence its not working. Can you please guide me here with options?
This is a common fallacy. In
select * from table where columnvalue in (7788, 7839, 7876)
(7788, 7839, 7876) is an expression list and the predicate is evaluated as a membership condition.
In
select * from table where columnvalue in :P1_X
:P1_X is a scalar string, incapable of containing multiple values.
In an APEX standard report, a PL/SQL function body returning an SQL query report source with lexical substitution can be used to produce a "varying IN-list":
return 'select * from table where columnvalue in (' || :P1_X || ')';
where P1_X contains fewer than 1000 values, has been sanitized for SQL injection, and string values are properly quoted.
Some people suggest the following approach, which will also work in APEX interactive reports:
select * from table where instr(':' || :P1_X || ':', ':' || columnvalue || ':') > 0
However this is non-performant as it eliminates the possibility of the optimizer using indexes or partition pruning in the execution plan.
See varying elements in IN list on Ask Tom, and emulating string-to-table functionality using sql for efficient solutions. -
Sql query with conditions and calculations???
Hi,
how I can build a query with conditions and calculations?
E.g. I've got this table
Start | End | Working Place | Mandatory
01-JAN-13 | 11-JAN-13 | Office | 1
14-JAN-13 | 25-JAN-13 | Home Office | 0
04-MRZ-13| 15-MRZ-13 | Office | 0
11-FEB-13 | 22-FEB-13 | Office | 1
Now if column working place=Office and column mandatory=0
the new column "price" has to calculate: (End-Start)* $25.00
and if working place=Office and column mandatory=1
the "price" column has to calculate: (End-Start)* $20.60
else $0.00
I tried it with the case statement but I didn't know how
to calculate my values and display it to the virtual column "price".
Something like
case
when Working_Place = 'Office' and Mandatory=1
then ...
else '0.00'
end as PRICE
Or is it not possible?
Edited by: DB2000 on 12.03.2013 05:09Use CASE:
select start_dt,
end_dt,
working_place,
mandatory,
case
when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
else 0
end price
from tbl
START_DT END_DT WORKING_PLA MANDATORY PRICE
01-JAN-13 11-JAN-13 Office 1 206
14-JAN-13 25-JAN-13 Home Office 0 0
04-MAR-13 15-MAR-13 Office 0 275
11-FEB-13 22-FEB-13 Office 1 226.6
SQL> SY. -
I'm using the LabView Database Connectivity Toolset and am using the following query...
UPDATE IndexStation
SET Signal_Size=200
WHERE 'StartTime=12:05:23'
Now the problem is that this command seems to update all rows in the table IndexStation... Not just specifically the row where StartTime=12:05:23
I have tries all sorts of {} [] / ' " around certain characters and column names but it always seems to update all rows...
I've begun to use the SQL query tab in Access to try and narrow down as to why this happens, but no luck!
Any ideas!?
Thanks,
Chris.Chris Walter wrote:
I completely agree about the Microsoft issue.
But it seems no SQL based manual states that { } will provide a Date/Time constant.
Is this an NI only implementation? Because I can't seem to get it to function correctly within LabView or in any SQL query.
Chris.
There is nothing about the database toolkit in terms of SQL syntax that would be NI specific. The database Toolkit simply interfaces to MS ADO/DAO and the actual SQL syntax is usually implemented in the database driver or database itself although I wouldn't be surprised if ADO/DAO does at times munch a bit with that too.
The Database Toolkit definitely does not. So this might be a documentation error indeed. My understanding of SQL syntax is in fact rather limited so not sure which databases might use what delimiters to format date/time values. I know that SQL Server is rather tricky thanks to MS catering for the local date/time format in all their tools and the so called universal date/time format has borked on me on several occasions.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Hi,
I want a sql query as follows (but it seems not be as simple as that...)
select A1, A2,
select sum(B3)
from B1 = A2
where
from A
where A1 = '1001'
is it possible, in some way, to have A2 from outer select statement as a parameter to inner select statement?Hi,
user8819407 wrote:
Hi,
I want a sql query as follows (but it seems not be as simple as that...)
select A1, A2,
select sum(B3)
from B1 = A2
where
from A
where A1 = '1001'
is it possible, in some way, to have A2 from outer select statement as a parameter to inner select statement?Yes, you can reference columns from a parent query within its child query.
For example:
select A1, A2,
select sum (b.B3)
from b
where b.B1 = a.A2
from A
where A1 = '1001'
;Within the sub-query, you don't have to qualify columns from b; that is, b3 is assumed to mean b.b3. If the column name is unique, you don't have to qualify columns from table a, either. That is, if b does not have a column called a2, then a2 in the sub-query could only mean a.a2, and Oracle doesn't make you spell out which table a2 comes from, but it makes the code a lot easier to understand and debug if you do qualify the columns.
By the way, a sub-query that references its parent query like this is called a Correlated Sub-Query .
"Parameter" doesn't really apply to this situation. -
Simple SQL query SQL developer takes it, The wizzard of XE does not
Hello everybody
I wrote this simple query which SQL developer runs fine, but when I try to launch a Report based on this sql query it tells me invalid sql statement. That is true, it may be invalid because this IF clause in there..but SQL developer seems to be very tolerant or understands more...
the reason I wrote that is because obviously if there are no bosses, ie = 0 then i would get an error when dividing it by 0, so I put that 0 just to select the good ones
if count (bosses) >0
select company, postcode,
sum( bosses/staff)
from evaluation
group by company, postcode
Thank you very much
Alvarooh yes (blushed in shame as how dumb i looked like) i knew about the denominator 0 and infinite as as result i just didnt notice my zero was on the numerator :(
however, i run the query and i got this message in sql developer
Error starting at line 1 in command:
select company, postcode,
case when staff != 0 then sum( bosses/staff) end
from evaluation
group by company, postcode
Error at Command Line:2 Column:10
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action: -
I have an interesting problem and wondering how I can get this result in a single SQL query:
Here is table emp has data with a row for every year since the employee joined with the salary paid that particular year with following columns:
emp (
id varchar2(10),
name varchar2(25),
interested_year date,
salarypaid number(10)
I would like to print the results as follows:
id name previousyear_salarypaid currentyear_salarypaid
x xxxxx xxxxxx xxxxx
Is this possible to do? I have tried to simplify my actual problem so I hope I have included all necessary details.Just to clarify, the columns mentioned in the results are
previousyear_salarypaid is nothing but
salarypaid where interested_year = '2007'
currentyear_salarypaid is nothing but
salarypaid where interested_year = '2006' -
Hi,
I'm new to SharePoint 2013 I want to be able to query a MSSQL database from a SharePoint App I have tried to create an External Content Type (ECT) which is produced from a MSSQL stored Procedure, this procedure has several parameters which are needed to
filter the data correctly. From here I want to produce an external list which I can then query from a c# SharePoint app. If I leave the filters in the ECT null then the list is of course empty or if enter a default values the results are limited
for the app to query so are no good.
I want to dynamically pass values to the ECT when querying from the app, is this not possible. Should I just be returning everything in an external list and then letting the query in the app filter the data, this seems inefficient?
Is this the best way to do this or should I be doing this differently?
Please can someone point me in the right direction.
ThanksHi Pandra801,
When you create a the external content type, please try to add a filter based on your select statement.
http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
A step by step guide in designing BCS entities by using a SQL stored procedure
http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Query SQL with variables Parameters and user defined tables
Hi everyone
I got a problem about Query SQL
[dbo].[@CSOURCE] is a user defined table
select * from [dbo].[@CSOURCE]
you can get the result in following
code name
T01 newspaper
T02 TV
T03 radio
T04 friends
when I execute the following SQL Statements ,I get an error
SELECT T0.CardCode , 0.CardName ,T1.Name ,T2.SONumber
FROM OCRD T0 LEFT JOIN [dbo].[@CSOURCE] T1 ON T0.U_CSOURCE = T1.Code
LEFT JOIN (SELECT T0.CardCode ,COUNT(T0.DocNum)SONumber
FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
WHERE T1.GroupCode =111
AND (T0.DocDate >=[%0] or [%0]='')
AND (T0.DocDate <=[%1] or [%1]='')
GROUP BY T0.CardCode) T2 ON T0.CardCode=T2.CardCode
WHERE T0.GroupCode =111
and T0.CardType ='C
Is there anyone can correct it for me
thank you very much
Edited by: Li Mishan on Jul 17, 2008 9:36 AM
Edited by: Li Mishan on Jul 17, 2008 9:40 AMI am sorry .It is just a mistake of my typewriting.
The following is the whole SQL
dbo.@CSOURCE is a user table.It's content is
code name
T01 newspaper
T02 TV
T03 radio
T04 friends
declare @m int
declare @FromDate DateTime
declare @ToDate DateTime
set @m=(SELECT count(*) FROM ORDR T0 WHERE T0.DocDate >=[%0] and T0.DocDate <=[%1])
set @FromDate=[%0]
set @ToDate=[%1]
/*****************If I do not connect user tavble dbo.@CSOURCE ,I will succed *****************************************************/
SELECT T0.CardCode ,T0.CardName ,T2.SONumber,T1.Name
FROM OCRD T0 LEFT JOIN [dbo].[@CSOURCE] T1 ON T0.U_CSOURCE = T1.Code
LEFT JOIN (
SELECT T0.CardCode ,COUNT(T0.DocNum)SONumber FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
WHERE T1.GroupCode =111
AND (T0.DocDate >=@FromDate or @FromDate='')
AND (T0.DocDate <=@ToDate or @ToDate ='')
GROUP BY T0.CardCode
) T2 ON T0.CardCode=T2.CardCode
WHERE T0.GroupCode =111
and T0.CardType ='C'
when I excute the SQL, It return a error , whith says the column name '%0' is invalid.
If I delete "set @m=(SELECT count(*) FROM ORDR T0 WHERE T0.DocDate >=[%0] and T0.DocDate <=[%1])"
and rewrite "set @FromDate='2008.05.01' set @ToDate='2008.07.01' "
It Shows the following results
CardCode CardName SONumber name
1 000070 Deng. Jiahua 1 newspaper
2 000293 LU .Weijuan 1 radio
3 000313 Xie .Jifang 3 TV
Edited by: Li Mishan on Jul 18, 2008 4:42 AM
Edited by: Li Mishan on Jul 18, 2008 4:43 AM
Edited by: Li Mishan on Jul 18, 2008 5:43 AM
Maybe you are looking for
-
How to Hide a column in OBIEE 11g
Hi, I am trying to hide a column of presantation layer table in OBIEE 11g. But it is not working. I am doing the follwoing. Open the permission tab of the column. Given no access to Everyone. Given No access the user/Application Role. When i go to we
-
Save Interactive PDF Form as static form
I have an Interactive form in a Web Dynpro page. I fill in out, hit submit, it creates a PDF file on the server. This is great but when I open up the PDf that got created, it is still editable. How do I make Web Dynpro create a static or non-editable
-
SampleImage() in 4-color gradient issue
hi there I am trying a technique for logo/element removal that I saw in a post from a couple years back, where a tracked, solid "patch" is placed over the unwanted element, and a 4 color gradient effect is applied to the patch, which then uses the sa
-
I tried few times purchase item but credit card problem, how do I reset the thing due to it asked me to contact iTunes support
-
Explan the methods to fill the gaps in abap ?
Hi I am newly appoined in abap mine role is to fill the gaps between clinet and us explain me with fine example ? THis is very help ful to me in my life... thanking U