Trying to use lexical parameter in ORDER BY
I'm using BIP in EBS and I have a report that needs to be sorted based on parameters selected in conc. pgm. I'm trying to use lexical parameters to accomplish this, however, it's not working. I have defined my lexical parameter in Package Spec and I'm setting it accordingly in Package Body(BeforeReport trigger). In my data template (dataQuery section) I have the following SQL
SELECT 'AP_BANK_ACCOUNTS_ALL' as "table_audit2",
a.bank_account_id,
to_char(a.audit_timestamp,'DD-MON-YYYY HH:MI P.M.'),
a.audit_transaction_type ,
a.audit_user_name,
a.bank_account_name,
a.bank_account_num,
a.account_type,
a.org_id,
a.bank_branch_id,
a.xxap_field_changed,
a.xxap_new_value,
a.xxap_old_value,
b.bank_name,
d.short_name
FROM xxap_bank_accounts_all_gtmp a,
ap_bank_branches b,
hr_organization_information c,
gl_sets_of_books d
WHERE a.bank_branch_id = b.bank_branch_id
AND a.org_id = c.organization_id
AND c.org_information_context = 'Operating Unit Information'
AND c.org_information3 = d.set_of_books_id
ORDER BY &lv_order_by
The IF statments below are being used in package to set lexical parameter
note: p_order_by_1 & 2 are from conc.pgm
IF p_order_by_1 IS NOT NULL
THEN
lv_order_by := to_char(p_order_by_1);
lv_order_1 := 'Y';
END IF;
IF p_order_by_2 IS NOT NULL
THEN
IF lv_order_1 = 'Y'
THEN
lv_order_by :=lv_order_by||','||to_char (p_order_by_2);
lv_order_2 := 'Y';
ELSE
lv_order_by := to_char(p_order_by_2);
lv_order_2 := 'Y';
END IF;
END IF;
Any help will be greatly appreciated!!!! I'm a newbie to EBS and BIP so you can probably imagine how frustrated I am.
Message was edited by:
user631051
The conc. pgm completes successfully but my report is not sorted. Data Template below:
<properties>
<property name="include_parameters" value="true" />
<property name="include_null_Element" value="true" />
<property name="xml_tag_case" value="upper" />
<property name="db_fetch_size" value="500" />
<property name="scalable_mode" value="off" />
<property name="include_rowsettag" value="false" />
<property name="debug_mode" value="off" />
</properties>
<parameters>
<parameter name="p_start_date" dataType="date"/>
<parameter name="p_end_date" dataType="date"/>
<parameter name="p_org_id" dataType="number"/>
<parameter name="p_data_priority" dataType="character"/>
<parameter name="p_include" dataType="character"/>
<parameter name="p_account_type" dataType="character"/>
<parameter name="p_order_by_1" dataType="character"/>
<parameter name="p_order_by_2" dataType="character"/>
<parameter name="p_order_by_3" dataType="character"/>
</parameters>
<dataQuery>
<sqlStatement name="Q1">
<![CDATA[SELECT 'AP_BANK_BRANCHES' as "table_audit1", a.bank_branch_id as "bank_branch_id",
to_char(a.audit_timestamp,'DD-MON-YYYY HH:MI P.M.') as "audit_timestamp",
a.audit_transaction_type as "audit_transaction_type", a.audit_user_name as "audit_user_name",
b.bank_name as "bank_name", b.bank_branch_name as "bank_branch_name",
to_char(b.bank_number) as "bank_number", a.active_date as "active_date", a.xxap_field_changed,
a.xxap_new_value, a.xxap_old_value
FROM xxap_bank_branch_gtmp a,
ap_bank_branches b
WHERE a.bank_branch_id = b.bank_branch_id
]]>
</sqlStatement
<sqlStatement name="Q2">
<![CDATA[SELECT 'AP_BANK_ACCOUNTS_ALL' as "table_audit2",
a.bank_account_id as "bank_account_id",
to_char(a.audit_timestamp,'DD-MON-YYYY HH:MI P.M.') as "audit_timestamp",
a.audit_transaction_type as "audit_transaction_type",
a.audit_user_name as "audit_user_name",
b.bank_name as "bank_name",
a.bank_account_name,
a.bank_account_num as "bank_account_num",
a.account_type as "account_type",
to_char(a.org_id) as "org_id",
a.bank_branch_id as "bank_branch_id",
a.xxap_field_changed,
a.xxap_new_value,
a.xxap_old_value,
d.short_name as "short_name"
FROM xxap_bank_accounts_all_gtmp a,
ap_bank_branches b,
hr_organization_information c,
gl_sets_of_books d
WHERE a.bank_branch_id = b.bank_branch_id
AND a.org_id = c.organization_id
AND c.org_information_context = 'Operating Unit Information'
AND c.org_information3 = d.set_of_books_id
ORDER BY &lv_order_by
]]>
</sqlStatement>
</dataQuery>
<dataTrigger name="beforeReportTrigger" source="XXAP_RPT_BANK_AUDIT_EXT_PKG.BeforeReport"/>
<dataStructure>
<group name="G_Bank_Branches" source="Q1">
<element name="table_audit1" value="table_audit1"/>
<element name="bank_branch_id" value="bank_branch_id"/>
<element name="audit_timestamp" value="audit_timestamp"/>
<element name="audit_transaction_type" value="audit_transaction_type"/>
<element name="audit_user_name" value="audit_user_name"/>
<element name="bank_name" value="bank_name"/>
<element name="bank_branch_name" value="bank_branch_name"/>
<element name="bank_number" value="bank_number"/>
<element name="active_date" value="active_date"/>
<element name="xxap_field_changed" value="xxap_field_changed"/>
<element name="xxap_new_value" value="xxap_new_value"/>
<element name="xxap_old_value" value="xxap_old_value"/>
</group>
<group name="G_Bank_Accounts_All" source="Q2">
<element name="table_audit2" value="table_audit2"/>
<element name="account_type" value="account_type"/>
<element name="bank_account_id" value="bank_account_id"/>
<element name="audit_timestamp" value="audit_timestamp"/>
<element name="audit_transaction_type" value="audit_transaction_type"/>
<element name="audit_user_name" value="audit_user_name"/>
<element name="bank_name" value="bank_name"/>
<element name="bank_account_name" value="bank_account_name"/>
<element name="bank_account_num" value="bank_account_num"/>
<element name="org_id" value="org_id"/>
<element name="xxap_field_changed" value="xxap_field_changed"/>
<element name="xxap_new_value" value="xxap_new_value"/>
<element name="xxap_old_value" value="xxap_old_value"/>
<element name="short_name" value="short_name"/>
</group>
</dataStructure>
</dataTemplate>
Similar Messages
-
How to use lexical parameter in report
i want to use lexical parameter in report and pass parameter from form how it is possible in detail
A.RHi,
typically you fill your lexical paramter in the after-paramform-trigger out of the values of your bind-parameters (giving end users directly control over lexical parameters might not be a good idea). Inside PL/SQL a lexical parameter is referenced like bind parameters with ":". In the query it's referenced via "&" and represents a part of the query.
A simple example.
- p_deptno as bind parameter
- p_where as lexical paramter
- end user choose value for p_deptno (10,20,... or nothing)
- Trigger: if :p_deptno is not null then
:p_where := 'WHERE deptno = :p_deptno'
else
:p_where := null;
end if;
- Query select ... from emp &p_where
Regards
Rainer -
HOW TO USE LEXICAL PARAMETER IN FORMS9I
CAN I USE LEXICAL PARAMETER IN FORMS9I I WANT TO CREATE QUERY LIKE THIS
SELECT * FROM &TABLE_NAME
WHERE &CHOICE
WHERE &TABLE_NAME = EMP, AND &CHOICE EMPNO=12344
PLS HELPNo, you can do it in sqlplus or reports but not in forms.
If this is a datablock query you need to use set_block_property.
If it is in a trigger you need to use execute immediate. -
Report are not working using lexical parameter
Hi !
i am using oracle 10g and i my query i have laxical parameter as follow
&to_date
in after paramform we have
IF :P_DATE_TO IS NOT NULL THEN
:TO_DATE := 'AND to_date(head.updated_date,'||chr(39)||'DD/MM/RRRR'||chr(39)||') between TO_DATE(t2.term_start_date,'||chr(39)||'DD/MM/RRRR'||chr(39)||') AND TO_DATE('||CHR(39)||:P_DATE_TO||CHR(39)||','||chr(39)||'DD/MM/RRRR'||chr(39)||')';
--ELSE
--:TO_DATE := NULL;
END IF;
after compile this report when i run this report then i have following error
REP-304: '&' in SELECT statement was not followed by a valid lexical parameter.
any body can tell me how can i resove it.What denis is trying to say that change the TO_DATE parameter to any other name because TO_DATE is actually reserve word. So instead of TO_DATE try for example P_TO_DATE or any other name.
-Ammad -
How to use a parameter with Order By?
I am trying to pass in a parameter to a procedure (like 'ColumnName ASC, ColumnName DESC') to use with ORDER BY, but I can't get it to order on the passed in parameter? I have read a few posts but non of my attempts have worked.
Procedure getEquipmentList(io_cursor OUT ref_cursor_Equipment), orderString IN VARCHAR2, RecordStart IN NUMBER, RecordEnd IN NUMBER) IS
Equipment_Cursor refCursor_Equipment;
Use_Order NUMBER := 1;
BEGIN
OPEN Equipment_Cursor
FOR SELECT *
FROM TABLE(
PACKAGE_EQUIPMENT.getRecordSetOfEquipment(
CURSOR(
SELECT * FROM (SELECT idEquipment, strEquipmentName, deletedFlag, Row_Number() OVER (ORDER BY DECODE(Use_Order, 1, orderString)) AS r FROM tblEquipment) WHERE r >= RecordStart AND r <= RecordEnd)));
io_cursor := Equipment_Cursor;
END;
If I replace orderString in the DECODE with say strEquipmentName it orders correctly. If I try 'strEquipmentName' then it does not work. Any ideas would be helpful.SQL>
SQL> create or replace procedure test2(ord in varchar2)
2 is
3 TYPE TCUR IS REF CURSOR;
4 CUR TCUR;
5 v_name varchar2(30);
6 begin
7 open cur for 'select first_name from employees where rownum<=10 order by '||ord;
8 loop
9 fetch cur into v_name;
10 exit when cur%notfound;
11 dbms_output.put_line(v_name);
12 end loop;
13 end;
14 /
Procedure created
SQL> exec test2('employee_id');
Steven
Neena
Lex
Alexander
Bruce
David
Valli
Diana
Nancy
Daniel
PL/SQL procedure successfully completed
SQL> exec test2('salary');
Diana
Valli
David
Bruce
Daniel
Alexander
Nancy
Lex
Neena
Steven
PL/SQL procedure successfully completed
SQL> -
Use lexical parameter in select statement
Hi,
I have a report like below:
select d.dname, &par1 mgrSal, &par2 empSal from emp e, dept d where d.deptno=e.deptno
and d.deptno = :dno;
Here the &par1 and &par2 are calling a function like:
:par1 := ' f(:dno, :job)';
in the after parameter form. the function returns a number ( something like count(*) or max(sal) ).
Now the reports server (6i) generats error message:
inlalid column or miss expression.
What is the right way for this kind of report? Please help me.
Any help is greatly appreciated.Hi,
I have a report like below:
select d.dname, &par1 mgrSal, &par2 empSal from emp e, dept d where d.deptno=e.deptno
and d.deptno = :dno;
Here the &par1 and &par2 are calling a function like:
:par1 := ' f(:dno, :job)';
in the after parameter form. the function returns a number ( something like count(*) or max(sal) ).
Now the reports server (6i) generats error message:
inlalid column or miss expression.
What is the right way for this kind of report? Please help me.
Any help is greatly appreciated.
Try debugging it in the same good old way.
What you have stated seems to have no problem
but you never know. So In the after param form see whether it is actually setting a value to your parameter.
If that is Ok I dont think you should have problems.
But there are two things which look odd here. since the Parameter value is not changing after the after param form why do you need it in the query?
Second If you are trying to display the departments thier emp count and max salary I think You can use straight selects than anyhting else.
Try doing it
vij -
How to call a sales order form using a parameter?
hi
i am creating a custom form and upon quering the form i am getting all the records
and
i have a button and when i click on that button it should take me to oracle apps order form ?
what i tried doing ?
IF :parameter.actions='Order' THEN
v_startup_mode := 'ORDER';
v_header_id :=:SSWMS_SHIPMENT_LINES.ORDER_HEADER_ID;
FND_FUNCTION.EXECUTE(
FUNCTION_NAME=>:parameter.call_function,
OPEN_FLAG=>'Y',
SESSION_FLAG=>'Y',
ACTIVATE_FLAG=>'ACTIVATE',
OTHER_PARAMS=>'STARTUP_MODE="'||v_startup_mode||'" HEADER_ID="'||v_header_id||'"');
END IF;
i am doing for that line id? can someone help me as how to call this form?
sudharshanHi Prashanth,
I dont think so OPEN_FORM will work out here.
If we want to call new form/open form insted of using call_form / open_form/ New _form
we need to use FND_FUNCTION.EXECUTE which allows you to open forms without bypassing Oracle Applications security, and takes care of finding the
correct directory path for the form.
here FND_FUNCTION.EXECUTE is similar to APP_NAVIGATE.EXECUTE,
except that APP_NAVIGATE.EXECUTE allows a form to be restarted if
it is invoked a second time.
So in the parameters of FND_FUNCTION.EXECUTE,
open_flag indiacates Y/N.
’Y’ indicates that OPEN_FORM should be used;
’N’ indicates that NEW_FORM should be used.
You should always pass ’Y’ for open_flag, which
means to execute the function using the Oracle
Forms OPEN_FORM built–in rather than the
NEW_FORM built–in
i think sudharshan is using the right method FND_FUNCTION.EXECUTE.
--Basava.S -
Lexical parameter in select statement showing null or column name in xml tag instead of value
Hi,
i am using lexical parameter in report select statement as
Select &order value from oe_order_headers_all a where order_number ='7889'
and setting : order:='a.order_number'; in after parameter form trigger.
lexical parameter intial value set to null
when i run this report , its not showing order number in output ,its showing null or a.order_number as text.
Please help.try this
Select &order data_show
from oe_order_headers_all
where order_number ='7889'
and setting :order:='order_number'; in after parameter form trigger.
Hope this helps
Hamid -
I am Timewarner cable, and trying to use their app in order to watch tv on my computer. (My cable box is broken) At timewarner cable, they say I need version 4 of firefox, but I have checked with my version and it says I am up to date, and it is version 30.0. What can I do? Thanks for your help!
Firefox 4 was referring to the old [http://website-archive.mozilla.org/www.mozilla.org/firefox_releasenotes/en-US/firefox/4.0/releasenotes/ 4.0 (four.zero) released back on March 2011] as the current version is [http://www.mozilla.org/en-US/firefox/30.0/releasenotes/ Firefox 30.0 (thirty.zero) released June 10, 2014].
-
How to use a parameter field value as a substring in a "like" statement?
Hi all,
I'm trying to use a parameter field in a Record selection formula where the parameter field value would be a substring of the data stored in the field.
My parameter field (SlctResearcher) is constructed as follows:
Type: string
List of Values: static
Value Field: (Reports) RptAuthors
(in Value Options) Allow custom values?: True
{Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
{Reports.RptAuthors} like "*{?SlctResearcher}*"
When I hit F5 to generate the data, I get no results (and the parameter prompt field does not even come up...)
If I modify the formula to put a hard-coded string, like
"*Jones*"
after the 'like', I get results (all the reports where "Jones" is a substring in the RptAuthors string.) If I modify the formula to just use the parameter field without the quotes/stars like:
{Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
{Reports.RptAuthors} like {?SlctResearcher}
I do get the parameter prompt field, but still no results even if I put in a valid substring value (since it is not searching for a substring anymore...)
How can I do this?
Thanks,
Will1st thing... Make a copy of your report before doing anything!!!
To use a SQL Command, you'll want to open the Database Expert and look at the Current Connections. Expand the data source and the 1st option you see is the Add Command option.
To find the SQL That CR is currently using, choose Database from the menu bar and select Show SQL Query...
You can copy this and paste it directly into the command window. (If you you can write your own SQL you don't need copy CR's, it's just an option.)
You'll also want to take not of any parameters that you have, you'll need to add them the the Parameter List of the command as well... be sure to spell them EXACTLY as they are in the design pane.
Anyway, once the SQL statement is in the Command window you'll be able to alter the WHERE clause to use the wild cards.
For future reference... What type of database are you reporting against???
Jason -
Lexical parameter in SELECT INTO (Very Urgent)
I have to write a query which takes some value & put it into a variable. but i have to use lexical parameter in my query.
e.g
select sal into v_sal
from emp
where deptno=20 &p_lexpara;
the form amd report builder do not compile this syntax & give error on &p_lexpara
Pl. help me out
ThanksIn Report Builder you can not use clause INTO.
Correct one is:
select sal
from emp
where deptno=20 &p_lexpara
In Forms you can not use lexical parameter but you can create lexical parameter in CREATE_GROUP_FROM_QUERY. So you can create record group in this way and then use lexical parameter like:
DECLARE
rg_name VARCHAR2(40) := 'Salary';
rg_id RecordGroup;
errcode NUMBER;
BEGIN
** Make sure group doesn't already exist
rg_id := Find_Group( rg_name );
** If it does not exist, create it and add the two
** necessary columns to it.
IF Id_Null(rg_id) THEN
rg_id := Create_Group_From_Query( rg_name,
'select sal from emp where deptno=20 '||p_lexpara;
END IF;
** Populate the record group
errcode := Populate_Group( rg_id );
END;
and then with Get_Group_Number_Cell you can retrive values of SAL e.g something like:
status := Populate_Group( rg_id );
*/ *** Zero status is success*** /
IF status = 0 THEN
match := Get_Group_Number_Cell('Salary.SAL',1);
Message('The Salary is '||to_CHAR(match));
ELSE
Message('Error creating query record group.');
RAISE Form_Trigger_Failure;
END IF; -
Hi all
i need to make a dynamic report using lexical parameter but in the SQL Part when I write the SQL(select name,ID from &p_where)
it gives me syntax error ....i tired to use report query builder also telling me query builder not support lexical parameter....i need help in that matter please..To use lexical parameters in Reports, use need to specify a default value. If you don4t do this, Reports will return an error. Hope that helps you.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by wafaa ahmed:
Hi all
i need to make a dynamic report using lexical parameter but in the SQL Part when I write the SQL(select name,ID from &p_where)
it gives me syntax error ....i tired to use report query builder also telling me query builder not support lexical parameter....i need help in that matter please..<HR></BLOCKQUOTE>
null -
Lexical Parameter in Matrix Report
Hi ,
I am faced a problem when i used lexical Parameter in Matrix Report.
I design Query and Report in Group Above Mode The Lexical Parameter
Show the Values in the Field but when I make This Report in Matrix then
This Lexical Parameter Showes The Value Null I try many Solution
But it shows null value in the Output
Thanksi think you didn't read that i'm mentioned
in datatemplate
<parameters>
<parameter name="P_YOUR_PARAM" dataType = "number" defaultValue="0"></parameter>
</parameters>
<sqlStatement name="Q_DATA">
<![CDATA[
select &your_columns
from &your_tables
where &your_where_clause
]]>
</sqlStatement>
</dataQuery>
<dataTrigger name="beforeReportTrigger" source="XX_YOUR_PKG.BeforeReport"/>
<dataStructure>
...in package
FUNCTION BeforeReport RETURN BOOLEAN IS
BEGIN
IF P_YOUR_PARAM = 'some_value' THEN
your_columns := 'column1, column2';
your_tables := 'table1, table2';
your_where_clause := 'table1.id = table2.id';
ELSE
your_columns := 'column3, column4';
your_tables := 'table2, table3';
your_where_clause := 'table2.id = table3.id';
END IF;
END;you can use another way - create your xml output by package like
fnd_file.put_line(fnd_file.output, '<ROWSET>');
fnd_file.put_line(fnd_file.output, '<ROW>');
fnd_file.put_line(fnd_file.output, '<DAT>' || some_value || '</DAT>');
fnd_file.put_line(fnd_file.output, '</ROW>');
fnd_file.put_line(fnd_file.output, '</ROWSET>');in package you can use all that you want -
Problem when using WEB.SHOW_DOCUMENT and passing in lexical parameter
Hi,
I got a blank page with error "An error has occured while trying to use this document" when I tried to use web.show_document and passing a lexical parameter to 10g report on 10gAS. The URL in the web.show_document is:
http://<srvname>:<portnum>/reports/rwservlet?server=repserver90&report=myrpt.rdf&destype=Cache&desformat=pdf&userid=<usr>/<pw>@<db>&where_clause=where%20product_type%20in%20('REPORT')
If I change the desformat to htmlcss, it is fine to display the report. But doesn't work with desformat=pdf. The pdf file has been generated in the cache. Why can't it display on the screen.
Also I tried to use double quote the value for where_clause. The pdf report showed up. But it ignored the where clause.
Experts please help.
YingI use lexical parameters and they work fine, but I use a parameter list. The code is contained in a form that is called by all forms that wish to run a report. This way you only need the logic for printing in a single form. If you want the form, email me at [email protected]
-
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...
Maybe you are looking for
-
Memory issues on Production system
Hello, We are facing memory dumps and slow SAP performance on our PRODUCTION ECC EHP4 system. Many work process also goes to PRIV mode frequently But we have very good response Time also. I checked ST06 and see, CPU Idle % = 40% IO wait % = 16% CPU c
-
Why Can't I attach a file on iOS devices?
I've got a web form together, and I want respondents to be able to attach files from the iphone. I haven't tried it on other smartphone platforms.
-
Hi. I want to be able to print an invoice once. When I print for the second and subsequent times my form should be printed with the words 'REPEAT' or 'COPY'. Which tables can I use to get that such information. It looks like table NAST does not cover
-
Hi Just wondering, is there a problem using a database link from 8.1.6.0.0 to 9.0.1.3.0? I'm getting tnsnames.ora errors all the time even tough I have put the correct parameters into the tnsname file. Connecting from 9.0.1.3.0 to 8.1.6.0.0 is workin
-
Static Object Vs. Lots of referece passing...
I am implementing a discrete event simulator for which there is only ever one "executor" object and one "output manager" object used to advance time and deal with output to files. However many objects in the simulator need access to these objects and