SQL & PL/SQL :: Passing Multiple Values To IN Clause In Function?
Jun 22, 2010
I have a function that returns the total sum of an account. From reports I call the function passing the account code. The function sums the values for that specific account code and returns the value. In my function I have the following code :
where account_code = P_CODE.
Eg. The value of :P_CODE is 'CS'.
I now want to pass multiple account codes ('CS','TV',LJ') to the function. How do I change the IN clause in the function to accommodate multiple values.
I have tried using the instr function, but it does not work. eg. AND instr(o.ACCOUNT_CODES,','||P_CODE||',') > 0
I have created a Data block - 'CONTACTS' (Database data block) and has database item - 'Code', 'Descr'
The number of records displayed is set to 5.
Value When checked - 'Y' Value When Unchecked - 'N' Check box mapping of other values - 'unchecked'
The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.
Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.
I have tried using basic loop as well as while loop but things havmt worked. Below is a basic code which will work for one record, request to guide me with muliple checkbox ticked.
IF :contacts.cb = 'Y' THEN
IF p_where is null then
p_where := :contacts.code; else p_where := p_where ||','||:contacts.code; end if; end if; p_where:= 'where code in ('||p_where||')';
My need is to pass multiple values as single input parameter into pipelined function. For example - "2" and "3" are values of input parameter "t":
with data as ( select 1 as t from dual union all select 2 as t from dual union all select 3 as t from dual union all select 4 as t from dual union all select 5 as t from dual ) select * from data where t in (2,3)
,I have a queryIn my query iam passing parameters using IN clause.The parameters contains in two tablesfor ex..select a.deptno, b.deptnofrom dept1 a, dept2 bwhere a.deptno = b.deptnoand NVL (a.deptno, b.deptno) in (10, 20, 30,.....) is this correct way to use NVL like this.i have a deptno consists in both the tables. How can i use this condition.
I am strugling hard to pass a cursor to my function as in parameter.here is my code
Function migrate_audits (sys_audit_ids SYS_REFCURSOR ) return number; Function migrate_audits (sys_audit_ids in sys_refcursor ) return number is v_return number; v_sys_audit_id number; begin LOOP FETCH sys_audit_ids INTO v_sys_audit_id; [code]....
passing cursor to a function is not possible in oracle? what other option I have to pass collection to the function ?
Ex: Cursor C_employees(C_empid number, C_cityname varchar2) is select emp_name, office_name from employee where employees where empid = c_empid and city = c_city_name;
I know we can pass one parameter to the cursor but I do not know how to pass multiple parameters.
I am trying convert number value in date. I know somewhere I doing mistake. But I cant get it.
Here is my Partial Code
create or replace PROCEDURE "REPORT_ARTICLEMOSTVIEWED2" (
[Code]....
Error starting at line 5 in command: EXEC REPORT_ARTICLEMOSTVIEWED2(null,null,null,null,:RC) Error report: ORA-01858: a non-numeric character was found where a numeric was expected ORA-06512: at "IIS_ORACLE_11GR2_LIVE.REPORT_ARTICLEMOSTVIEWED2", line 22 ORA-06512: at line 1 01858. 00000 - "a non-numeric character was found where a numeric was expected" *Cause: The input data to be converted using a date format model was incorrect. The input data did not contain a number where a number was required by the format model. *Action: Fix the input data or the date format model to make sure the elements match in number and type. Then retry the operation. RC
How do I put condition for Null value in this procedure And set dateTo = sysdate if v_day,v_month,v_year are null.
I have an requirement to create an function which takes table or hierarchy of tables as input and returns xml output in hierarchy. Below given is the Tables hierarchy.
Requirement: Initially input was table name and using table as the root node output should generate xml of all the records of child tables.But now requirement is to give the flexibility to user to select what hierarchy he needs i.e he may select AAAA, CCC and in the nodes C1,C2,C3 and C4 if he doesn't want C3 then that node should not be shown in output.
I have created Hierarchy table having 3 columns SI.No, ParentNode and ChildNode and entered the above hierarchy relation.
1. What is the best to way (design)to pass input parameter for the function.
2. How to generate hierarchy in xml using DBMS_XMLGEN
CREATE OR REPLACE FUNCTION fn ( p_salesrep_id IN jtf_rs_salesreps.salesrep_id%TYPE, p_org_id IN jtf_rs_salesreps.org_id%TYPE, p_cnf_date IN emcint_ord_headers_all.creation_date%TYPE
[Code]....
Invoking Functions
select fn(-3,293,'1/1/1952'), resource_id from jtf_rs_salesreps where rownum < 5 ORA-06552: PL/SQL: Statement ignored ORA-06553: PLS-382: expression is of wrong type
How to pass a values from one to another, but without using parameters or globals. I've used parameters and every time i have to list the values of the form that values have been passed to, it ask do you want to save... even if I didn't passed any values. It's because my code in where-new-form instance, where i give values to a parameters.
I have a form in which the user selects values above from a LOV and then selects a run query button which then uses the values selected in the LOV to refine the query and output the appropriate values.
What i have done in the pre-query trigger is: (the block i am querying is called cars where the block i am selecting values from the LOV is called selection)
:cars.make := :selection.make; (repeated for other fields)
this worked fine untill i introduced a from and to date in my form in which i passed the data through to the query like this:
declare v_dates_between varchar2(1000); begin v_dates_between := 'reg_date between ''' || :selection.from_date || ''' and ''' || :selection.to_date; Set_Block_Property( 'cars', DEFAULT_WHERE, v_dates_between ) ;
Now i have added the above bit of code the from and to date work fine, but when a car make is selected it still bring back every car make and not just the one selected.
is it possibly because i am setting the where clause in the block property? perhaps i need to now incoperate my other selections into this where clause? are the two blocks exclusive to eachother? and if i put the whole code into the block property I assume i will get problems. E.G. the user leaves a selection criteria blank (if they want to query all car models they wouldnt select one from the list) i assume the query would only return back values which contain no car model which would be 0 records.
I have two page , from first page to second page I am passing some values using url parameter passing but some values contains comma ex :- P1_ NATION text field contains INDIA,USA,UK
but apex treated that as these are separate values and assign it to separate items
suppose my intention is like P2_NATION,P2_EMPLOYEE,P2_EMPID :INDIA,USA,UK,SAGAR ,123
but apex treating it as P2_NATION = INDIA :P2_EMPLOYEE=USA :P2_EMPID = UK
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production PL/SQL Release 11.1.0.6.0 - Production "CORE 11.1.0.6.0 Production"
I have a form which has few textboxes, and few dropdown, and 3 links. Data is entered in few boxes, and then when a link is clicked, it goes to another page, but i want to pass the text in the text boxes, and the selected value from the dropdown also, to be passed as parameters to this link... But since these values are not yet saved, its not getting passed.. like it is something like this in the address bar add_new_event?&event_ id= &event_ name= & event_dt=
<script language="JavaScript" type="text/javascript"> function f_setglp(pThis,p_app_item,p_other_record_level_item) { var curr_id = $x(pThis).id; // OK ! var curr_glp = $x(p_app_item).id; // returns undefined var curr_orli = $x(p_other_record_level_item).id; // returns undefined
[Code]...
The Javasxcript function fires OK on click in the "Product" attribute but: PMO_GLP_PK is an Application Item that Javascript can´t reference as I called YES_NO is another tabular form attribute and the reference returns also "undefined"
this modal popup, it works correctly but not passing values from page page1 to my page3. How do i pass these paramater values to page3,
function modalWin() { if (window.showModalDialog) { window.showModalDialog("f?p=&APP_ID.:3:&SESSION.:POP:NO::P3_EMPNO:#P1_CUSTOMER_ID#::","name","dialogWidth:600px;dialogHeight:400px");
select * from nrc_trans_descr where type_id_nrc=60013 -- it has 18 columns and i have hard coded 60013 for simplification here.60013 is derived from 3 other table Output is ( it can have many rows too.typically for each type_id_nrc there is one row ).
TYPE_ID_NRC TRIGGER_STATUS INSTALLMENT_TYPE_ID_NRC --------------------------------------------------------------------- 60013 0 61013 i have to pass TYPE_ID_NRC and INSTALLMENT_TYPE_ID_NRC to restriction_id column in a different table. currently i am doing like this select * FROM DISCOUNT_RESTRICTIONS WHERE discount_id in (12085,12086) and (restricted_id in ( select type_id_nrc from nrc_trans_descr where type_id_nrc=60013) or restricted_id in ( select installment_type_id_nrc from nrc_trans_descr where type_id_nrc=60013));
am using ORACLE 10GR2(solution for 11gr2 is welcome too)
I have a view that contain multiple tables with ( UNION all ) clause , is there any way that if i query from this view I can explicitly specify the table that i need the data from ?
Let say i have view that contain salaries of 2011
Create view sals_2011 as select * from sals_jan2011 union all sals_feb2011 ..... union all select * from sals_dec2011.
if i issued select * from sals_2011 where emp_id >500 and date < 01-feb-2011 the explain plan show me that full tables and indexes are in processing, while i know that i need only to scan sal_jan2011, and of course it is taking much longer time than selecting from the original table only.
I need to calculate the sum of values over a period of exactly one month (including the current row). Now if I use a windowing clause of "range between interval '1' month preceding and current row", the total period length is 1 month plus one day (being the day in the current record).
Basically, I want to sum over a period starting at "add_months(startdate, -1) + 1" up until startdate of each row.
drop table window_tst; create table window_tst ( id number primary key
[Code]....
So instead of having 01-feb going back to 01-jan, it should only include 02-jan till 01-feb
I could of course recalculate the period length back to a number of days for each row, but that is not really what I would prefer, as it would make the code rather unreadable.