Using a URL parameter in SQL Query
Newbie question...
I have been developing a dashboard application, and I have been using input bind variables in the SQL. That all works fine.
What I would like to do is to have a user go to a page via a URL with paramaters like this:
http://atlas:7777/pls/apex/f?p=112:1:9191429456552868531:::::P1_ITM_CD_PASSED:JMINV
where P1_ITM_CD_PASSED is the parameter and JMINV is the value.
Then, I want the SQL to execute using that:
select *
from itm
where itm_cd = ': P1_ITM_CD_PASSED'
I tried testing this on a page. Set up a report region, but it appears that the paramater is not making it to the SQL. "No Records Found".
Is there a simple example out there that anyone knows of? Maybe I am missing an item, computation, process, etc. to be able to utilize the paramater?
Thanks in advance
varad
Thanks for the reply. I did try that, and same results. It seems that the parameter is not getting bound to the variable, or it's getting flushed after the page loads. Here is what debug shows me:
P1_TEST
0.08: show report
0.10: determine column headings
0.10: activate sort
0.10: parse query as: CUSTOM
*0.11: binding: ":P1_ITM_CD_PASSED"="P1_ITM_CD_PASSED" value=""*
0.11: print column headings
0.11: rows loop: 15 row(s)
no data found
Edited by: jmcclain on May 13, 2010 4:01 PM
Similar Messages
-
Can we use formula column in lexical parameter in sql query ...
hi
can we use formula column in lexical parameter in sql query ...
as example
i want to give
select * from & c_table
forumula
function c_table
if :p_sort = 1 then
return 'dept'
else
return 'emp'
end;
c_table formula column
is this possible ...
i have such example in oracle apps reports
if i try in ordinary report usinf emp table it show error ..
how we can give formula column...
please help me in this regard...
Edited by: 797525 on Feb 20, 2012 9:31 PMthanks sir,
iam not exactly saying select * from &c_table but some thing that like columns in select stmt also will be populated in user_parameters ,there are lot of table select.......from mtl_demand md, mtl_system_items msi, mtl_txn_source_types mtst, mtl_item_locations loc &C_source_from &C_from_cat
&c_source_from and &c_from_cat formula column and there are defined at report level only ......
pl/sql code &c_source_from is
function C_source_fromFormula return VARCHAR2 is
begin
if :P_source_type_id = 2 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id = 3 then return(',GL_CODE_COMBINATIONS gl');
else if :P_source_type_id = 6 then return(',MTL_GENERIC_DISPOSITIONS mdsp');
else if :P_source_type_id = 5 then
if :C_source_where is null then
return NULL;
else
return(',WIP_ENTITIES wip');
end if;
else if :P_source_type_id = 8 then return(',MTL_SALES_ORDERS mkts');
else if :P_source_type_id is null then
return(',MTL_SALES_ORDERS mkts,
MTL_GENERIC_DISPOSITIONS mdsp,
GL_CODE_COMBINATIONS gl ');
else null;
end if; end if; end if; end if; end if; end if;
RETURN NULL; end;
this is forumula column i hope that you understand what iam saying
please help me in this regard....
thanking you... -
Use realational operators in an SQL query??????
does any one knows how to use realational operators in an SQL query??????
i wud like to do something like
select decode(2<3,sysdate,sydate +1) from dual
but i know decode does not supports relational operators......
thanx and Regards
amytYou can use a CASE statement which does support relational operators, or if you must use DECODE, then you can use something like:
SELECT DECODE(SIGN(2 - 3),-1,sysdate,sysdate - 1)
FROM dual;The SIGN function returns -1 if the expression is < 0, 1 if the expression is > 0 and 0 if the expression is 0. This works for numeric comparisions. You can use the GREATEST or LEAST functions in a similar fashion for character comparisions.
TTFN
John -
How to Use the Procedures in a Sql Query
Hi Friends,
Can anyone help me out whether can we use the procedure in the sql query..
if yes help me out with an example
my requirement is
i have one sql query .. in which i need to use the procedure which returns multiple values... how can i overcome it,can anyone help me out for this..
for your reference i am pasting the sql query
SELECT paf.person_id
FROM per_all_assignments_f paf START WITH paf.person_id = p_person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
CONNECT BY PRIOR paf.supervisor_id = paf.person_id
AND paf.primary_flag = 'Y'
AND paf.assignment_type IN('E', 'C')
AND l_effective_date BETWEEN paf.effective_start_date
AND paf.effective_end_date
and paf.person_id not in (>>>I HAVE TO USE THE PROCEDURE HERE<<<<);
Thanks in advanceWe never saw your procedure, but maybe you could wrap it in a function
SQL> create or replace procedure get_members(in_something IN number, out_members OUT sys_refcursor)
is
begin
open out_members for
'select level member_id from dual connect by level <= :num' using in_something;
end get_members;
Procedure created.
SQL> create or replace type numbers as table of number;
Type created.
SQL> create or replace function members(in_something IN number)
return numbers
as
member_cur sys_refcursor;
members numbers;
begin
get_members(in_something, member_cur);
fetch member_cur bulk collect into members;
close member_cur;
return members;
end;
Function created.
SQL> select * from table(members(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.Variant on same using piplined function
SQL> create or replace function members_piped(in_something IN number)
return numbers pipelined
as
member_cur sys_refcursor;
rec number;
begin
get_members(in_something, member_cur);
loop
fetch member_cur into rec;
exit when member_cur%notfound;
pipe row(rec);
end loop;
close member_cur;
return;
end;
Function created.
SQL> select * from table(members_piped(4));
COLUMN_VALUE
1
2
3
4
4 rows selected.
SQL> drop function members_piped;
Function dropped.
SQL> drop function members;
Function dropped.
SQL> drop type numbers;
Type dropped.
SQL> drop procedure get_members;
Procedure droppedEdit:
Sorry Blu, had not seen you already posted similar thing
Edited by: Peter on Jan 27, 2011 5:38 AM -
How to add a parameter to sql query in report
Hi
How to add a parameter to sql query in report.
Parameter is from Visual studio
example:
select * from tab1 where dl=parameter???
I have VS 2008 prof CR XI R2, mysqlHello,
If you have this API available then you can modify the record selection formulae in code to add filtering:
string recordSelectionFormula = "{T_INV_RPT_ADDR.IND_PROMUS} = {?P_PROMUS?} AND {T_INV_RPT_POINT.INVOICE_DATE} = DATE(2008, 05, 31) AND {T_INV_RPT_POINT.CHECKOUT_DATE} = date(2008, 04,29)";
CrystalDecisions.CrystalReports.Engine.ReportDocument.RecordSelectionFormula = recordSelectionFormula;
You have to format and follow the rules as in the Designer so not too much work to get this to work.
CR for .NET may not have the ability so you will need to upgrade to a Developer version of Crystal Reports.
Thank you
Don -
Hi,
I am using from_date and to_date parameters. Data type and Param type for both are 'Date' and my Format string is 'dd/MM/yyyy'
I need to pass these two values to my data model which is SQL query. Whenever I use below WHERE clause I am getting
"ORA-01858: a non-numeric character was found where a numeric was expected", Please let me know how to fix this error.
trunc(a.scan_timestamp) between to_char(to_date(:p_from_date,'DD/MM/YYYY'),'DD-MON-YYYY') and
to_char(to_date(:p_to_date,'DD/MM/YYYY'),'DD-MON-YYYY')Hello,
if you choose Date for Data type and Parameter Type for the parameters then the format of your date has nothing to do with your selection.
Please try
trunc(a.scan_timestamp) between :p_from_date and :p_to_date
Wolfgang -
Passing Parameter to SQL-Query
Hello ,
i have an SQL Query as Data Source of my Crystal Report . I d like to pass the parameter to my SQL-Query.
Parameter ?city
Query1
select
Order ID,
City, -- How to pass my ?city here
Amount
from Orders,
thanx ..You can do this by using the 'Add Command' feature.
Click Add Command -> Create your ?City Parameter -> type SQL statement:
select
Order ID
where City='{?City}'
Make sure you add single quotes around your parameter.
Regards,
Zack H. -
Passing file location as URL parameter for xml query
Hi all,
A quick question regarding using a parameter to set the source URL in an XML query template.
When assigning the URL, the static text works perfectly eg:
//<servername>/<folder>/samplefile.xml . The xml is returned as required.
However, we wish to call this from a BLS txn and set the source URL dynamically.
To test this we assigned //<servername>/<folder>/samplefile.xml to Parameter no 1 and insert [Param.1] in the source URL field. No luck.
Any suggestions?
Cheers
MarkMark,
In BLS, the double slashes (escaping the single /) are only necessary if you are building the full http url string in the link editor.
If your XMLQuery template is something like http://localhost/Folder/Subfolder/[Param.1] then put in a default param value in the query template and make sure the query test works. Then configure (or reconfigure) this in your BLS transaction and generate the sample results. All you should have to do in BLS then is to assign your Transaction or Local property to the Param.1 link in your XMLQuery action block. All of the dynamic replacement and subsequent xml file retrieval should then be done by the XMLQuery itself.
If you can keep the majority of the URL in the XMLQuery itself and then just dynamically pass it the Param.1 piece it will be very easy to test and configure (also use localhost if the file lives on the xMII web server), but if you have to build the string external in BLS I would recommend using a combination of the expression editor and a Local property. If the Local string property contains the base of http://localhost/Folder/Subfolder/ (no quotes or character escaping needed for the default value of a string property) then just assign something like the following to your Param.1 property of the XMLQuery: Local.URLBase & "filename.xml" (a simple evaluate will confirm your efforts).
Regards,
Jeremy -
Using System Variables in a SQL Query
Hi!
I´m new to Oracle and SQL so i don´t know very much about it.
There is miy Problem:
Is there a way to Use the System Variable %USERNAME% in an SQL Query?
I tried .... where table.shorttag = '%USERNAME%' ;
but this doesnt work.
Is Oracle able to handle Systemvariables? Or is there another way to use the current Windows User in an SQL Query.
It is very Important to use the current Windows user and not the Oracle user.
Thank you,
MfgAre you looking for something like this ?
SQL> SELECT sys_context('USERENV', 'OS_USER') FROM dual;
SYS_CONTEXT('USERENV','OS_USER
SAUBBANE\IBM
SQL> SELECT sys_context('USERENV', 'TERMINAL') FROM dual;
SYS_CONTEXT('USERENV','TERMINA
SAUBBANEAlso you can look at the dbms_application_info package. -
Using IN keyword in an sql query in a view criteria
Hi,
I am using jdev 11.1.1.1.0 and defined an lov query/viewobject as
select a, b, c from myTable
I now need to predefine filtering for lov search functionality and need something like the following
select a, B, c from myTable where B in ('X','Y')
I could not find a way to do it (i.e. specify the use of IN Keyword) in the Create View Criteria dialog box. I tried to define OR, but is that the best way to redefine IN as i have a long list (the above is just an example)
(( ( (UPPER(B_FLAG) = UPPER('X') ) ) OR ( (UPPER(DISPLAY_FLAG) = UPPER('Y') ) ) ))If you know how many variables are in your "in" You can just write this in the sql query of your VO:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/images/t136.gif
From this tutorial:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm#ah1 -
Is there any way to use Control Break in a SQL Query
Hi,
Is there any way to use a control break on Dept column in a SQL query to have a Output-2 instead of Output-1.
Is there any way to modify the SQL query.
SQL
select dept, loc, count(*)
from dept
group by dept, locOutput-1
Dept Loc Count(*)
10 AA 1
10 BB 2
10 CC 2
20 AA 2
20 BB 2Output-2
Dept Loc Count(*)
10 AA 1
BB 2
CC 2
20 AA 2
BB 2Thanks,
DeepakDeepakJ wrote:
Hi,
Is there any way to use a control break on Dept column in a SQL query to have a Output-2 instead of Output-1.
Is there any way to modify the SQL query.
SQL
select dept, loc, count(*)
from dept
group by dept, locOutput-1
Dept Loc Count(*)
10 AA 1
10 BB 2
10 CC 2
20 AA 2
20 BB 2Output-2
Dept Loc Count(*)
10 AA 1
BB 2
CC 2
20 AA 2
BB 2
Yes, using the <tt>lag</tt> analytic function and specified ordering of the data:
select
nullif(d.deptno, lag(d.deptno) over (order by d.deptno, d.loc, e.mgr nulls first)) deptno
, nullif(d.loc, lag(d.loc) over (order by d.deptno, d.loc, e.mgr nulls first)) loc
, e.mgr
, count(*) n
from
dept d
join emp e
on d.deptno = e.deptno
group by
d.deptno
, d.loc
, e.mgr
order by
d.deptno
, d.loc
, e.mgr nulls first;
DEPTNO LOC MGR N
10 NEW YORK 1
7782 1
7839 1
20 DALLAS 7566 2
7788 1
7839 1
30 CHICAGO 7698 4
7839 1
40 BOSTON 7698 2
7902 1 -
Use of FIELD in Attribute SQL Query
Hi folks,
Back in 7.1 you could use %FIELD.[attributename]% in a sql query defining an identity store attribute's values.
Does anyone know if this functionality was lost in 7.2? Can't seem to get it to work.
Thanks,
MattHi Moritz,
did you consider that note:
Note: Both
fields must be
defined as "Single value" with presentation type "Single select"?
It does not work as soon as you use other storage or presentation types.
Regards
Norman -
Using Multi Select List in SQL Query
Hi all,
I am trying to using a Multi Select list for filtering of a report. I have :P2_RISK_SEVERITY which has has the possibility of values Very Low:Low:Medium:High:Very High. How do I use this Multi Select in the where section of a SQL query?
I need to say something along the lines of:
Select RISK_SEVERITY from TBL_RMD_RISKS where RISK_SEVERITY = (one of the options selected in the multi select)
Thanks for the help.Hi there,
The above suggestion will work perfectly as long as the table you're querying is relatively small, but keep in mind that applying the INSTR to the left side of the WHERE clause will always result in a full table scan. This means that if your table is large and RISK_SEVERITY is indexed, the index will never be used. Here is another approach (credit to AskTom) that converts your colon-delimited string of selected values to a list that can be used in an "IN(...)" clause, which will use an index on RISK_SEVERITY as long as the optimizer otherwise deems it appropriate:
-- creates a type to hold a list of varchars
CREATE OR REPLACE TYPE vc2_list_type as table of varchar2(4000);
-- converts a colon-delimited string of values to a list of varchars
CREATE OR REPLACE FUNCTION vc2_list(p_string in varchar2)
return vc2_list_type is
l_string long default p_string || ':';
l_data vc2_list_type := vc2_list_type();
n pls_integer;
begin
loop
exit when l_string is null;
n := instr(l_string, ':');
l_data.extend;
l_data(l_data.count) := ltrim(rtrim(substr(l_string, 1, n - 1)));
l_string := substr(l_string, n + 1);
end loop;
return l_data;
end vc2_list;
-- your WHERE clause
where risk_severity in(
select *
from the(select cast(vc2_list(:P2_RISK_SEVERITY) as vc2_list_type)
from dual))
...Hope this helps,
John -
Using textField input as parameter to SQL Query
Hi,
Only a newbie can ask a quetion like this. I need my user to input a value in a text box, click a button and see the results of the Query displayed. I can do that if I bind a Dropdown box to a table, but since the table is huge, my page will slow down.Hi,
Exactly,
The below peice of code may give u an idea.
this.getSessionBean1().setid(textField1.getValue().toString());
where id would be bean property.
Cheers:) -
Using CASE in a dynamic sql query
Hi,
I want to create a dynamic query using the CASE statement to replace the below 2 SQL statements:
+++++
select 'create or replace synonym '|| SYNONYM_NAME || ' for '||TABLE_OWNER||'.'||TABLE_NAME||'@'||SUBSTR(db_link,1,30)||' ;' FROM USER_SYNONYMS where db_link is not null;
select 'create or replace synonym '|| SYNONYM_NAME || ' for '||TABLE_OWNER||'.'||TABLE_NAME||' ;' FROM USER_SYNONYMS where db_link is null;
+++++
So that i have a single select query which will give the create synonym statements for all with/without db links
Using the CASE statement example like given below :
SELECT
FirstName, LastName,
Salary, DOB,
CASE Gender
WHEN 'M' THEN 'Male'
WHEN 'F' THEN 'Female'
END
FROM Employees
I am not getting how to write this CASE statement. Can someone guide me here?
Thanks,
KunwarKunwar wrote:
I am a Junior Oracle DBA. I would like to master SQL & PL/SQL concepts & tricks. Please guide me some books (apart from the oracle documentation links) which will improve my SQL & PL-SQL skills which are very weak right now. Personnally I started with the Oracle Class Training SQL&PL/SQL, then did a loooooooooooot of reading on [url http://asktom.oracle.com]AskTom (I even bought his book).
Also I tried (and I'm still trying) to answer to SQL/PLSQL problematic on this forum, then tried to see and learn from what other gave as answers.
I also spend and spent a lot of time in the Oracle Documentation. (I fear your "apart from the oracle documentation" to actually mean : apart reading the documentation)
Kunwar wrote:
TOAD alternative for create ddl statements for limited no. of objects
You need to learn to use dbms_metadata. I gave you an example, use the documentation and some self-testing to make it do what you need.
"Practice makes perfect"
And as an hint : To become a SQL & PL/SQL Master, you should first start by forgetting Toad : The real tool for learning is SQL*Plus.
Toad, as any tool, is only good in the hands of whom knows what they do and how things work.
Maybe you are looking for
-
Go figure both Apple support and Netflixs support "have never seen a problem quite like mine" the same day my free trial has ended. And no the, problem is not with my Netflixs account because they charged my debit card just fine. I'm trying to play i
-
I cannot get the "ARCKEY" value in my payload to be written to the Idoc
I am trying to write the interface filename to the ARCKEY field of an Idoc. I can see it in the Payload but the Idoc in the target system always has the GUID/MessageId in this field. I've got "Apply Control Record Values from Payload" switched on in
-
I just installed new RAM, and it's not all showing up in the system profiler. Before the upgrade I had: Riser A - 1GB - 0 - 0 - 0 Riser B - 1GB - 0 - 0 - 0 After the upgrade I had: Riser A - 4GB - 4GB - 0 - 0 Riser B - 1GB - 1GB - 0 - 0 But the syste
-
I've done the adprep32 on 2003 server standard for /forestprep, /domainprep, and /rodcprep without an error, as instructed by several docs on web. But in final stage of dcpromo on 2008 server standard, it fails with Active Directory Domain Service c
-
I was convinced that I had read on here that all ports are active simultaneously, but I have just discovered (and then read confirmation here) that an HDMI connection disables the Component output:-( I was hoping to be able to use these 2 outputs to