Dynamic Parameter LOV Select Statement
I have a parameter form with a value for the fiscal year and equipment ID. I want to populate the equipment ID list of values based on the fiscal year that is selected.
My query for the equipment ID list of values would be SELECT EQPID,NAME FROM EQPLIST WHERE FY = :FY.
When I tried to add this query to the list of values of the equipment ID parameter I get REP-0781: Bind variables are not allowed in the Select statement.
Is there a way to dynamically generate the list of values select statement in a reports trigger?
Hi,
What version of Oracle Reports are you using?
Unfortunately, it is a limitation of Oracle Reports to not restrict values based on other parameters - for sure until Reports 6i and I believe until the recent new versions.
The other way to do what you want to do is to do it outside of Reports, if you have an Oracle Forms application. For example, you can create a simple Oracle Form that captures the Report parameters and then submits the report from the Forms. In Forms, you can implement the solution you are looking for - restricting values based on values of other parameters. In reports, you can't do that.
If you have a few other reports that have similar requirements, then you can create a form to launch reports and submit all your reports from there after capturing all your parameters there.
Venkat
Similar Messages
-
Dynamic field in Select Statement
I am able to create a dynamic statement to insert into the where clause of my sql, but I am unable to dynamically create a select statement. Oracle Reports produces the following error:
REP-0499: Column " selected by the query is incompatible with report definition.
Here is an example of my select:
Select
&dynamic_field
from
any_table
Any help is appreciated.I figured it out. Thanks
-
Getting Username to pass into LOV select statement
Hello!
I'm wondering if its possible to get the username of the current user logged in and pass it as a variable into a select statement used in a dynamic LOV in Oracle AS Portal?
What I'm attempting to do is pull all the values from a table that equal the current user's username to user on a portal report
so (as a rough example)
select color from mytable where username = 'whatever the user name is would be here'
And then the current user would get a list of values from which to select based off of the values entered in this table.
The issue I'm having is determing how to fill the 'whatever the user name is would be here' portion with the actual logged in user's username (or even if its possible). I know on the actual portal one can do #USER.FULLNAME# to display their username, is there a similar "variable" one may use to get the username for a LOV sql call?
I can get it to work if I statically fix the username to a particular value (ex: where username = 'Joe.Hacker') but I'm unsure if theres a variable or bind value (for lack of a better term) to grab the username on the fly.. dynamically.portal.wwctx_api.get_user can be used in the SQL query of your portal report to get the user_name of the currently logged-in portal user. For more info on wwctx_api, see the 10.1.2 or 10.1.4 portal API docs at http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1012/index.html or http://www.oracle.com/technology/products/ias/portal/html/plsqldoc/pldoc1014/index.html
-
Specify database field's name dynamically in a select statement
Hi to all!!
I have the following problem:
I got a paraneters statement where the user is to choose the month of the year,once i have the month, i need to make a query on a database(select field_name) of a field whose name deppend on the month that the user chose before, is it possible?
What I need? I think i can do it using field simbols but I've never worked with field simbols and I have no time to learn it now.
Thanks everybodyHi,
<b>Below code is the Simple one:</b>
<b>DATA: DYN_FIELD(15)
SELECT single (DYN_FIELD)
into corresponding fields of <IT_TABLE>
from <TABLE> where XXX = YYY.</b>
This is the complex program, have a look at it ...
REPORT zdany_dynamic_select.
* We use some parameters to dynamically control the select, this is not very
* clever but this is just a test program !!
PARAMETER : p_tabnam TYPE tabname DEFAULT 'SFLIGHT',
p_selfl1 TYPE edpline DEFAULT 'CARRID',
p_selfl2 TYPE edpline DEFAULT 'CONNID',
p_selfl3 TYPE edpline DEFAULT 'FLDATE',
p_selfl4 TYPE edpline DEFAULT 'PRICE',
p_selfl5 TYPE edpline DEFAULT 'CURRENCY',
p_where1 TYPE edpline DEFAULT 'PRICE > 300',
p_where2 TYPE edpline DEFAULT 'AND CURRENCY = ''EUR'''.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
<ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
lt_group TYPE TABLE OF edpline,
l_having TYPE string,
l_wa_name TYPE string,
l_sel_list TYPE edpline,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
* Creation of the output table including a non standard field, f_count
* see ABAP FAQ #14 for more information on this topic
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
* We remove the unnecessary fields
LOOP AT comp_tab INTO comp_fld.
IF comp_fld-name <> p_selfl1 AND
comp_fld-name <> p_selfl2 AND
comp_fld-name <> p_selfl3 AND
comp_fld-name <> p_selfl4 AND
comp_fld-name <> p_selfl5.
DELETE TABLE comp_tab WITH TABLE KEY name = comp_fld-name.
ENDIF.
ENDLOOP.
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
CREATE DATA dref TYPE HANDLE struct_type.
ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields and the "group by" clause
APPEND p_selfl1 TO lt_sel_list.
APPEND p_selfl1 TO lt_group.
APPEND p_selfl2 TO lt_sel_list.
APPEND p_selfl2 TO lt_group.
APPEND p_selfl3 TO lt_sel_list.
APPEND p_selfl3 TO lt_group.
APPEND p_selfl4 TO lt_sel_list.
APPEND p_selfl4 TO lt_group.
APPEND p_selfl5 TO lt_sel_list.
APPEND p_selfl5 TO lt_group.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
* creation of the "where" clause
APPEND p_where1 TO lt_where.
APPEND p_where2 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
WHERE (lt_where)
GROUP BY (lt_group)
HAVING (l_having)
ORDER BY (lt_group).
* display of the results
LOOP AT <lt_outtab> ASSIGNING <ls_outtab>.
LOOP AT comp_tab INTO comp_fld.
ASSIGN COMPONENT comp_fld-name OF STRUCTURE <ls_outtab> TO <l_fld>.
WRITE: <l_fld>.
ENDLOOP.
SKIP.
ENDLOOP.
Have a look at the link, this link will have lot of examples :-
http://www.susanto.id.au/papers/DynOpenSQL.asp
Regards
Sudheer -
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 -
Dynamic sql for select statement
Hi,
Please help me with the below code:
It is updating null if the select statment returns one values. If it fetches multiple values then it throughs the below error msg when running the program.
Please let me know how to modify the below code. Or let me know is there anyother way to write this code.
Logic for development:
* View name should be passed as dynamic.
CREATE OR REPLACE
PROCEDURE "PKEP_LOAD_SO_EU" (p_var1 IN VARCHAR2)
IS
lv_sql VARCHAR2 (4000);
lv_name VARCHAR2 (20);
BEGIN
lv_sql :=
' SELECT DISTINCT LEVEL2
FROM BIIO_SALES_OB_IMPORT_'|| p_var1;
EXECUTE IMMEDIATE lv_sql
INTO lv_name;
BEGIN
UPDATE BIIO_SALES_OB_IMPORT_NA2 --table name for updation
SET SOB_1 = NULL,
SOB_DATE_1 = NULL
WHERE level2 = lv_name; -- validation ( eg. Select distinct level2 from biio_sales_ob_import_'||p_var1)
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLERRM);
NULL;
END;
END;
BEGIN
PKEP_LOAD_SO_EU ('NA1');
end;
Error report:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "DEMANTRA.PKEP_LOAD_SO_EU", line 11
ORA-06512: at line 2
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
Thanks.
PadmaPadu wrote:
Please let me know whether is anyother way to write this code as im a beginner for SQl.You dont need to have a seperate SELECT statement. Just a single UPDATE will do the job for you.
create or replace procedure pkep_load_so_eu
p_var1 in varchar2
as
begin
lSql := ' update biio_sales_ob_import_na2 ' ||
' set sob_1 = null ' ||
' , sob_date_1 = null ' ||
' where level2 in ( ' ||
' select level2 ' ||
' from biio_sales_ob_import_' || p_var1 ||
execute immediate lSql;
end; -
Passing parameter into select statement by using function in discoverer
I have created two functions in database named Period_in and Period_out and a global variable g_period_name
I have called Period_out function in VIEW(Select statement where condition).
I have registered Period_in function in discoverer admin then created calculation (called Period_in(:input parameter))in discoverer plus.
My expectation is user will enter period name and that will hit Period_in function and returns 1 and stores entered period name in g_period_name at runtime. then VIEW will executed and fetches data.
But i am getting no data found.
Problem is 2 functions running at the same time in select statement. Please help me to overcome this. Thanks in advance
FUNCTION period_in (p_period VARCHAR2)
RETURN NUMBER
AS
BEGIN
g_period_name := p_period;
RETURN 1;
END period_in;
FUNCTION period_out
RETURN VARCHAR2
AS
BEGIN
RETURN g_period_name;
END period_out;You can use this code:
WITH cte
AS ( SELECT EmpID ,
EmpName ,
[dbo].[udf_testFunction](EmpID) AS testfunctionvalue
FROM #Temp
SELECT EmpID ,
EmpName ,
testfunctionvalue ,
testfunctionvalue * EmpID ,
testfunctionvalue + 2
FROM cte
But using scalar functions in select clause can hurt the performance. Please see this link:
SQL Server Scalar User Defined Function Performance
T-SQL Articles
T-SQL e-book by TechNet Wiki Community
T-SQL blog -
Dynamic fields in select statement
Hi all,
In selection screen we are having period as select option.The values for period are 01 to 16. Based on
the values entered in selection screen for period we need to select HSLXX from FAGLFLEXT.
For example if we enter 01 to 03 in selection screen then we need to select HSL01 HSL02 HSL03
from FAGLFLEXT.
Like this we need to select fields dynamically in select statement. Can any one tell me how to restrict fields dynamically.
Regards,
Swethahi Swetha,
the third select statemnet will work for you..
try this..
_Dynamic where clause in select query.._
* With a variable, result: AND rbusa = '5145'
concatenate 'AND rbusa = ' '''' i_tab-zgsber ''''
append where_clause to where_tab.
* Select
select * from zcostfreq
where (where_tab).
endselect.
_Using a dynamic table name_
parameters:
p_tab type tabname.
start-of-selection.
select count(*) from (p_tab) into l_count.
_Dynamic retrieval and writing of data_
FIELD-SYMBOLS:
<row> TYPE ANY,
<component> TYPE ANY.
PARAMETERS:
p_tab TYPE tabname.
CREATE DATA dataref TYPE (p_tab).
* The variable dataref cannot be accessed directly, so a field symbol is
* used
ASSIGN dataref->* TO <row>.
SELECT *
FROM (p_tab) UP TO 10 ROWS
INTO <row>.
NEW-LINE.
DO.
* Write all the fields in the record
ASSIGN COMPONENT sy-index
OF STRUCTURE <row>
TO <component>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE <component>.
ENDDO.
ENDSELECT.
Regards,
Prabhduas -
Passing value as a parameter in select statement
Hi,
Very simple query, how do I pass the values that i get in the cursor to a select statement. If table1 values are 1,2,3,4 etc , each time the cursor goes through , I will get one value in the variable - Offer
So I want to pass that value to the select statement.. how do i do it?
the one below does not work.
drop table L1;
create table L1
(col1 varchar(300) null) ;
insert into L1 (col1)
select filter_name from table1 ;
SET SERVEROUTPUT ON;
DECLARE
offer table1.col1%TYPE;
factor INTEGER := 0;
CURSOR c1 IS
SELECT col1 FROM table1;
BEGIN
OPEN c1; -- PL/SQL evaluates factor
LOOP
FETCH c1 INTO offer;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(offer);
select * from table1 f where f.filter_name =:offer ;
factor := factor + 1;
DBMS_OUTPUT.PUT_LINE(factor);
END LOOP;
CLOSE c1;
END;Hi Greg,
Thanks for the response, No there is no ODB.net involved here.
If I remove the : from :offer. I get this error now.
Changed SQL is:
select * from table1 f where f.filter_name =offer ;
Error report:
ORA-06550: line 16, column 23:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 16, column 9:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action: -
Dynamic table in select statement
Hi All,
I have a requirement where i have a select option in which the input is table name , i need to use this input in my select statement and fetch entries in the table where bname is eq to ' ' or uname eq ' '.
the challenge that i am facing is not all the tables have both the fields (uname and Bname).
Request your help on how to code the above requirements.
Thanks,
Bhanu.Bhanu,
I don't know what exactly is your requirement but I don't see any reason why a business user enters a table name as input in the selection screen.
MANDT NAME TYPE NUMB SIGN OPTI LOW HIGH
223 ZPROGNAME P 0001 I EQ XXX ZTABLENAME
You can maintain an entry like the above in TVARVC table and get the table name using a select query on TVARVC and then use the table as below
SELECT SINGLE * FROM (l_tabname)
into g_wa_tab2
WHERE quosrc EQ g_wa_tab1-quosrc AND
quotyp EQ g_wa_tab1-quotyp AND
quotno EQ g_wa_tab1-quotno AND
quotdate EQ g_wa_tab1-quotdate.
Funda is using TAVRVC to maintain the table names and determine the table based on a condition and the using the table in the select query.
Thanks,
K.Kiran. -
Dynamic rowsize from select statement.
Hi, I'm trying to get the lenght if the returned row from a select statement but I'm not sure how to do this properly.
The statement contains 530 columns of different type, mostly VARCHAR but also different number formats and timestamps.
I've tried to use LENGTH() + LENGTH() but our interactive SQL client is not very happy with the enormous statement size.
Thank you in advance.
/76...I think you need something like this:
select column_name "name", data_type "type",
data_length "length", nullable "null"
from all_tab_columns
where table_name =' Your table_name' -
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 -
Sending Package as Parameter into SELECT Statement
Hi,
Im Facing a very typical Problem
I have a table with 5 columns...
Select EMPNO,ENAME,SAL,JOB,DEPTNO from emp;
Now my package actually returns 30 records
select * from TABLE(PKG_SEARCH.DOC_PROPERTY(29)
which actually returns 7 columns with 30 records...
My requirement is -
i want the package to be sent as column to the Select EMPNO,ENAME,SAL,JOB,DEPTNO from emp;
Is there any way that we can create bind variables for this scenario?
Plz Help
Regards,
~ Srii want the package to be sent as column to the Select EMPNO,ENAME,SAL,JOB,DEPTNO from emp;Why not
Select EMPNO,ENAME,SAL,JOB,DEPTNO, PKG_SEARCH.DOC_PROPERTY(29) doc_property from emp;? -
Need a help in the Select statement
How to use the table name dynamically in the Select Statement in Oracle 9.i ?
This?
sql>
select *
from &table
old 2: from &table
new 2: from dual
D
X
Or this..?
sql>
declare
tab varchar2(31) := 'dual';
v varchar2(10);
begin
execute immediate 'select * from '||tab into v;
dbms_output.put_line(v);
end;
X
PL/SQL procedure successfully completed
jeneesh -
Dynamic parameter doesn't bring in all the data
Hi All,
Crystal 11.5.10.1263
Ok, I'm stumped.
I created a query that brings in all the data.
I pasted the query in the report and it brings in all the data.
I created a simple dynamic parameter to select the "ID" field.
I looked for ID 1539 and saw that tons of IDs were missing,
including 1539.
I've already broken down the report and created tests,
keeping them as simple as possible.
The report without a parameter shows all the data.
I also tried a static parameter just to see what would happen,
and I got the same results as the dynamic parameter - lots of missing data.
I guess that proves it's not the parameter, so I'm stumped.
Signed,
Stumped Jimmyhey stumped jimmy,
you can increase the number of parameter values via a reg key...
HKEY_CURRENT_USERSoftwareBusiness ObjectsSuite 12.0Crystal ReportsReportView
uisng the decimal value for "PromptingLOVBatchSize".
please see the support note [here |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333333383331333333363331%7D.do]for more info.
cheers,
jamie
Maybe you are looking for
-
VERY VERY DISAPPOINTED IN APPLE
Simultaneous release in 21 countries??? What a bunch of idiots at Apple and AT&T!! It's not rocket science to know that when you're gonna pound the system with 1 million times the normal volume, you gotta PREPARE FOR IT!! What did they do, slap toget
-
How to send e-mail using PL/SQL
I need to send e-mail using PL/SQL. Is it possible? Thanks in advance, Agnaldo
-
Export Aperture library objects to Finder folders
Inspired by the posted message by user http://discussions.apple.com/profile.jspa?userID=616539 I wrote a script that will do the following: 1. Sync Folders/SubFolders/Albums/Projects..etc hierarchy tree from Aperture to a Finder folders tree 2. At ru
-
KR TAX LOCALIZATION REPORT 실행시의 ORA-20000, ORA-06512 ERROR MESSAGE
제품 : FIN_AP 작성날짜 : 2002-12-02 KR TAX LOCALIZATION REPORT 실행시의 ORA-20000, ORA-06512 ERROR MESSAGE =================================================================== PURPOSE Multi-Org 환경속에서 Kr Tax Localization Report 실행시의 ORA-20000, ORA-06512 Error Me
-
How to implement extra password policies
What is the best way to configure additional password policies? We are using the DefaultAuthenticator, and its only password policy is Minimum length. We'd like to add policies that force a change every 6 months, require a mix of numbers and alphas,