An extra parameter for Summary function..
Why cant oracle give an extra parameter for summary function like MAX and MIN
For example
select max(salary,2)
from empWill give the second max salary...
Edited by: 884476 on Dec 19, 2012 7:13 AM
Just a thought..
Hi,
884476 wrote:
Frank Kulash wrote:
The built-in function NTH_VALUE (new in Oracle 11.2) does that.This is not an actual GROUPING function, right..?That depends on what you mean.
NTH_VALUE and GROUPING are two separate functions. MAX and GROUPING are also separate functions.
If, by "actual GROUPING function" you mean something other than a single-row function, then, yes, it is an actual grouping function. The value returned by the function can depend on all the values in the group, and not just the arguments from one row.
Are you asking if NTH_VALUE is an aggregate function? No, it is only an analytic function; it does not have an aggregate version. If you want aggregate-style results from analytic functions, then use SELECT DISTINCT.
In Oracle 9.1 (or higher) you can write a user-defined function.:)I should have said you can write a user-defined aggregate function. Starting in Oracle 7, you could write user-defined functions, but they were not generic. For example, you could write a function that returned the n-th highest sal from scott.emp, but it wouldn't return anything from hr.employees, nor could it return the n-th highest empno from scott.emp. Using dynamic SQL, you could write a fucntion where you passed a table name and a column name as well as n, and it would return the n-th highest value, as long as that column had the right datatype.
Similar Messages
-
Abap object as export parameter for remote function module
Hello all,
I would like to know if there is any possibility to use an abap object as parameter within a remote function module.
Thanks in advanceNo. You can't pass the Object Reference as the Parameters of the FM which could be run as an independent object like RFC FM, Update Task FM.
If you have an object and you want to pass the data to the subsequent FM (RFC), you need to move the attributes to structures or variables before calling the FM and use these variables to pass the data to your RFC.
Regards,
Naimesh Patel -
How to pass parameter into extract function (for XMLTYPE)
I have a table PROBLEMXML with XMLTYPE field xml_column. In this column there are several deffinitions for the problem. There is no max amount of deffinitions and it can be no definition at all. I need to return all definitions for every problem as a string wirh definitions separated by ";".
Query
SELECT extract(prob.Def,'/Definitions/Definition[1]/@var') || ';'|| extract(prob.Def,'/Definitions/Definition[2]/@var')
FROM PROBLEMXML j ,
XMLTABLE (
'/problem'
PASSING j.xml_column
COLUMNS probid VARCHAR (31) PATH '/problem/@id',
Def XMLTYPE PATH '/problem/Definitions') prob
where PROBLEM_ID =1;
returns exactly what I want a;m.
But
declare
my_var varchar2(2000) :=null;
n1 number;
n2 number;
begin
n1:=1;
n2:=2;
SELECT extract(prob.Def,'/Definitions/Definition[n1]/@var') || '|'|| extract(prob.Def,'/Definitions/Definition[n2]/@var') into my_var
FROM ETL_PROBLEMXML_STG_T j ,
XMLTABLE (
'/problem'
PASSING j.xml_column
COLUMNS probid VARCHAR (31) PATH '/problem/@id',
Def XMLTYPE PATH '/problem/Definitions') prob
where PROBLEM_ID =1;
dbms_output.put_line(my_var);
end;
returns NULL.
Is there is a way to pass parameter into extract function?I need to return all definitions for every problem as a string wirh definitions separated by ";".In XQuery, there's the handy function "string-join" for that.
For example :
SQL> WITH etl_problemxml_stg_t AS (
2 SELECT 1 problem_id,
3 xmltype('<problem id="1">
4 <Definitions>
5 <Definition var="var1"></Definition>
6 <Definition var="var2"></Definition>
7 <Definition var="var3"></Definition>
8 </Definitions>
9 </problem>') xml_column
10 FROM dual
11 )
12 SELECT j.problem_id,
13 prob.probid,
14 prob.def
15 FROM etl_problemxml_stg_t j,
16 XMLTable(
17 'for $i in /problem
18 return element r
19 {
20 $i/@id,
21 element d { string-join($i/Definitions/Definition/@var, ";") }
22 }'
23 passing j.xml_column
24 columns
25 probid varchar2(30) path '@id',
26 def varchar2(100) path 'd'
27 ) prob
28 ;
PROBLEM_ID PROBID DEF
1 1 var1;var2;var3 -
How send parameter in prerender() function for query
Sir I use requestbean for sending data to next page
Because want use this parameter in query
I get data as per this parameter
But when I call next page not pass parameter value to next page and query use blank parameter
I write code in prerender()
See my code
public void prerender() {
try {
getSessionBean1().getTripRowSet().setObject( 1, parameter1..getValue());
tripDataProvider.refresh();
} catch (Exception e) {
error("Cannot switch to person " + “no record “);
log("Cannot switch to person " + “no record , e);
Please give me idea how I send my parameter in prerender() function for query
Thank’s
aamirsir i try SessionBean but same as result
sir you see my full problem
I use studio creator
I create two page first for sending data to other page such as user login page
I add property in SessionBean, RequestBean and bind to data with my user name textfield
and in next page I bind to data with other textfield
after this I try to use this textfield use in
public void prerender() {
try {
getSessionBean1().getChartofaccRowSet().setObject(1, textfield1.getValue());
chartofaccDataProvider.refresh();
} catch (Exception e) {
error("Cannot switch to person " + �noooo�t);
log("Cannot switch to person " + �noooo�, e);
In this line I use that textfiled that bind to data form login page
getSessionBean1().getChartofaccRowSet().setObject(1, textfield1.getValue());
but sir this public void prerender() { function t not get textfield1 value in this function textfield give me null value
but when page complete run then show value in textfield
it mean this public void prerender() { function run befor SessionBean, RequestBean and not get SessionBean, RequestBean value
please give me idea how I pass value in public void prerender() { function form other page and I use this value in query
such as example
getSessionBean1().getChartofaccRowSet().setObject(1, textfield1.getValue());
this is my sessionbean query
SELECT ALL FNET.CHARTOFACC.PARENT,
FNET.CHARTOFACC.CHILD,
FNET.CHARTOFACC.ACCID,
FNET.CHARTOFACC.TITLE,
FNET.CHARTOFACC.CAMPID,
FNET.CHARTOFACC.ACTIVE,
FNET.CHARTOFACC.FSTATUS,
FNET.CHARTOFACC.COMHEADID,
FNET.CHARTOFACC.FIX_VARIABLE,
FNET.CHARTOFACC.VARI_PER
FROM FNET.CHARTOFACC
WHERE FNET.CHARTOFACC.CAMPID = ?
please give me idea
thank�s
aamir
SELECT ALL FNET.CHARTOFACC.PARENT,
FNET.CHARTOFACC.CHILD,
FNET.CHARTOFACC.ACCID,
FNET.CHARTOFACC.TITLE,
FNET.CHARTOFACC.CAMPID,
FNET.CHARTOFACC.ACTIVE,
FNET.CHARTOFACC.FSTATUS,
FNET.CHARTOFACC.COMHEADID,
FNET.CHARTOFACC.FIX_VARIABLE,
FNET.CHARTOFACC.VARI_PER
FROM FNET.CHARTOFACC
WHERE FNET.CHARTOFACC.CAMPID = ? -
What is the values and meaning for parameter TCLAS in functions
what is the values and meaning for parameter TCLAS in functions like
HR_INFOTYPE_OPERATION
regards
janHi Jan,
Good Morning,
In TCLAS,
A, B , T will be there.
A- Master data and time data.
B- Applicant data.
T- Shift Schedule.
So, here we can say the default value will be integrated according to the above ABT.
Means in the feature ABKRS, if you give the default values for all the three, your payroll area will appear in Master Data and Time data. And in recruitment ( Appicant data ) and work schedules. Means you are getting ingrated to all the three.
And you can observe the feature PINCH also.
If you dont want to get integrate with Master data, then dont give the default value under the A- Master date and Time data. And if you want to get integrate with Recruitment , then give the default value under B.
I think u got the clear idea about TCLAS.
Dont forget to give the points
Thanks in Advance
Cheers
Vijai -
Passing parameter for the bean function that deletes record from DB
I need to delete some record from the DB without updating the reset of the user screen.
I use commandButton with immediate attribute as true, because validation should be skipped.
So, I can't rely on backing bean values being updated, but need to pass a param to the function that does the delete (deleteTemplate) function below.
The value of this param is selected value in another comboBox called "template".
Code below is not parsing. Could you advise how to do it?
<a4j:commandButton id="deleteTemplate" value="Delete"
action="#{qtBeanParam.deleteTemplate(param['piPerformanceReturnsForm:template'])}" immediate="true" reRender="template,templateList,templateOwner,templateOwnerList"
styleClass="blue-button">
</a4j:commandButton>Error Parsing: #{qtBeanParam.deleteTemplate(param['piPerformanceReturnsForm:template'])}Thank you for your reply.
Could I pass the value that is entered in some other field as a "parameter" though?
<f:param name="anyName" value="parameter" />
For example the value from the following comboBox?
<rich:comboBox id="template" width="250" value="#{qtBeanParam.templateName}" enableManualInput="true"
converter="#{templateConverter}" valueChangeListener="#{qtBeanParam.changeTemplate}" >
<a4j:support event="onselect" reRender="template,templateList" ajaxSingle="true" />
<a4j:support event="onchange" reRender="template,templateList" ajaxSingle="true" />
<f:selectItems id="templateList" value="#{qtBeanParam.templateList}" />
</rich:comboBox> -
How to create Function Module with TABLE parameter (for internal table)
Hi Guys,
I am trying to create a function module by using TABLE parameter. I have to pass an internal table to this function module for processing.
But it saying : TABLES parameters are obsolete!
And I am not going further.
Please suggest any work arround.
ThanksHi,
create a table type in SE11..
Then use that in your function module importing/exporting/changing parameter for passing internal tables..
Thanks,
Naren -
Creating a function which you can execute with a parameter for date range
Hi Everyone,
Hope you can help me.
I have specific data that I am looking at that I require to query from a function. This function will require that I specify a parameter for a specific date which will only list the date criteria f my choosing.
Here is the data..
StudentID
FirstName
LastName
ClassName
ClassStartDate
ClassEndDate
GPA
1
John
Davids
Soft Dev
11/1/2013 9:00
11/30/2013 12:00
3.25
2
John
Davids
Database
10/1/2013 9:00
10/30/2013 12:00
3.5
3
John
Davids
Web Design
10/1/2013 9:00
10/30/2013 12:00
4
4
John
Davids
Psychology
10/1/2013 9:00
10/30/2013 12:00
3.25
So here is an example function which will need to be altered. I am hoping someone could help me figure this out. I thought the below may have been correct, but it just errors out.
SET
ANSI_NULLSON
GO
SET
QUOTED_IDENTIFIERON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE
FUNCTIONStudentGPATimePeriod
@startdate
AS
BEGIN
selectFirstName,LastName,ClassName,ClassStartDate,ClassEndDate,GPA
fromdbo.Students
whereClassStartDate
=@startdate
END
GOHi Saravana,
If I would to execute this function, how would the parameter be entered?
exec dbo.StudentGPATimePeriod
i think what you need is PROCEDURE, try below
--For a single date
Create PROCEDURE StudentGPATimePeriod
( @startdate datetime )
AS
Begin
select FirstName,LastName,ClassName,ClassStartDate,ClassEndDate,GPA
from dbo.Students
where ClassStartDate >=@startdate and ClassStartDate < dateadd(day,1,@startdate)
End
GO
--for multiple dates
CREATE PROCEDURE getStudentGPAMultipledate
( @startdate datetime,@enddate datetime )
AS
BEGIN
select FirstName,LastName,ClassName,ClassStartDate,ClassEndDate,GPA
from dbo.Students
where ClassStartDate >=@startdate and ClassStartDate < dateadd(day,1,@enddate)
END
GO
EXEC StudentGPATimePeriod @startdate='2014-11-12'
GO
EXEC getStudentGPAMultipledate @startdate='2014-11-12',@enddate='2014-11-13' -
Why does the Summary function give a datatype error when opening a data model for editing?
I have two datasets (G1 and G2) within a data model; i've used a field in G2 and placed it into G1 as a Summary Function of G2. The datatype of this field in G2 is Integer, however if you set the Summary field in G1 to the same datatype - Integer, an error appears.
Oracle have provided a patch.
We are running OBIEE at patchset 11.1.1.7.140715, Oracle have provided us with a patch p17563277 backported to the 140715 patchset.
This fix will presumably be incorporated in later releases. -
Performance of SUM summary function
Hi All,
I would like to know a little bit about the SUM function from a cost perspective.
I've a SQL query where I'm getting the total time for all users by using "SUM" summary function. The SQL query also has some inetmediate joins/merges
Now my boss says that from the cost perspective we should use application code instead of SUM. He also cited a reason that since the SQL query has so many joins, it would be better to use application code to do the calculations.
Can anyone gimme some insite on this issue?
Appreciate your time
venkI agree with 4 that is unlikely you could write application code that could join better than Oracle. You might be able to write application code that sums better (unlikely, but concievable). However, if you tried, you would probably blow out both the memory on the application server and the bandwidth on the network.
Even if you could write application code to do the joins and summing 10 times as fast as Oracle does (and if you can, you could certainly get a job with Oracle), the benefit would almost certainly be eliminated by the extra time to move the raw data across the network, and to allocate and free the enormous amounts of memeory that would be required.
Real databases are made to join, sort and aggregate, that's why we buy them.
John -
Can we use OUT or IN OUT parameter mode in function?
Can we use OUT or IN OUT parameter mode in function & if YES then what's limitations?
hi,
Yes we can have OUT and IN OUT parameters for a function.
As per my knowledge there are no limitations , but as per the convention we will use OUT ,IN OUT Parameter modes for only procedures .
Thanks,
P Prakash -
How to use a table as Parameter to a function?
Hi,
I would like to know how we can use a "nested table " ( pl/sql collection)
as parameter in a function and that function also return a table.
How we execute this type of function in a pl/sql block?
Thanks
Jobin JSP
Edited by: Jobin .SP on Dec 18, 2008 1:45 AMSome thing like this?
SQL> create or replace type tbl is table of number(10)
2 /
Type created.
SQL> create or replace function my_fn (ptbl in tbl) return tbl
2 as
3 ltbl tbl;
4 begin
5 ltbl := ptbl;
6
7 for i in 1..ltbl.count
8 loop
9 ltbl(i) := ltbl(i) + 10;
10 end loop;
11
12 return ltbl;
13 end;
14 /
Function created.
SQL> select * from table(my_fn(tbl(1,2,3,4,5,6,7,8,9,10)))
2 /
COLUMN_VALUE
11
12
13
14
15
16
17
18
19
20
10 rows selected. -
How to pass input value to the IN parameter in a function
Hi ,
I'm new to pl/sql programming.
The below function is used inside a package and the package is invoked in visual studio.
The function uses 2 input parameters.
Out of which 'in_report_parameter_id' value comes thru job processor service 's job request.
The second IN paramter values are hard coded in the function.
I'm not able to understand this.
If the values are hard coded , how to make sure that only the hard coded values are the right ones?
Please anyone could explain to me?
I really dont have good idea about how to pass INPUT parameter to the functions or procedure
Is there any nice document which could give me good understanding about what are the ways or types we could pass values to the input parameter in subprograms?
thanks in advance.
CREATE OR REPLACE FUNCTION get_class_text_str
in_report_parameter_id IN NUMBER,
in_which IN VARCHAR2 DEFAULT 'SELECT'
RETURN VARCHAR2
IS
end_text VARCHAR2 (50) := '';
my_class_text_str VARCHAR2(10000) := '';
my_class_value_str VARCHAR2(10000) := '';
CURSOR class_text(c_1_text VARCHAR2, c_2_text VARCHAR2) IS
SELECT c_1_text || report_parameters.report_parameter_value
|| c_2_text
|| report_parameters.report_parameter_value
|| '" '
FROM report_parameters
WHERE report_parameters.report_parameter_id = 3690
AND report_parameters.report_parameter_group = 'CLASS'
AND report_parameters.report_parameter_name = 'CLASS'
GROUP BY report_parameters.report_parameter_value
ORDER BY CAST(report_parameters.report_parameter_value AS NUMBER);
BEGIN
IF (in_which = 'SUM') THEN
OPEN class_text ( 'SUM(NVL("Class ', '", 0)) "Class ' );
ELSIF (in_which = 'PERC')THEN
OPEN class_text ( 'ROUND((("Class ', '" / "Total") * 100), 2) "Class ' );
end_text := ', DECODE("Total", -1, 0, 100) "Total" ';
ELSE
OPEN class_text ( 'SUM(DECODE(bin_id, ', ', bin_value, 0)) "Class ' );
END IF;
LOOP
FETCH class_text INTO my_class_value_str;
EXIT WHEN class_text%NOTFOUND;
my_class_text_str := my_class_text_str || ', ' || my_class_value_str;
END LOOP;
CLOSE class_text;
my_class_text_str := my_class_text_str || end_text;
RETURN my_class_text_str;
END get_class_text_str;
/Edited by: user10641405 on Nov 19, 2009 8:16 AM
Edited by: user10641405 on Nov 19, 2009 8:30 AMThis is not a design I would use, but should work if coded properly. I would probably build a reference cursor query as text and use one open fetch and close.
You have 2 input parameters, in_report_parameter_id and in_which. I could not find where in_report_parameter_id was used in the program, but the value passed in for in_which is being used in IF logic to decide how to open the cursor. After the cursor is open rows are being fetched and eventually the cursor is closed.
The values in_which are compared to are hard-coded. It is the programmer's job to make sure the values listed are the right values and the actions taken are also correct. Your program is assuming that if the first 2 values are not encountered the third one listed is the one you want.
To pass input values to a procedure you merely provide the values as a literal or variable in the call, something like
whatever := get_class_text_str(1,'SELECT'); -
Syntax for Evaluate function in OBIEE
Hi
I have browsed through the docs but couldn't find syntax for Evaluate function. Could someone pass me the full syntax and if possible a helpful example against essbase.
ThanksHi
definitely
syntax:- EVAULATE('your db function(%1,%2)', parameter list)
here %1 and %2 are the no.of parameters (columns or may constant values) to be passed for the db-function
if you have 3 parameters then you need to use %3 also.. means the columns to be passed.
following exapmples are for ORACLE db,
ex1: EVALUATE('upper(%1)', 'kishore kumar') gives the result as -> KISHORE KUMAR
ex2: EVALUATE('upper(%1)', 'Markets.Region') here Markets.Region is column.
you also can call the user-defined functions through evaulate
EVALUATE('functioname(%1,%2), column1, column2)
the above function has 2 parameters to be inputted
Thanks & Regards
Kishore Guggilla
Edited by: Kishore Guggilla on Jan 16, 2009 11:00 PM -
Need code for a function module- Urgent
Hi friends,
I have a requirement where I am giving material description as an import parameter in the function module. ( Material description could be a wild search -- say - Mat* ) I want a sub routine in the function module which should get all the materials from the database ( mara or makt..not sure ) for the user entered Material description.
I want this particular code to be written using a sub-routine using formal parameters inside this fm . Could any one send me the code for this.
Thanks in advance,
Vishnu.Hi Vishvanath,,
Please find the below code.
DATA : BEGIN OF itab OCCURS 0,
matnr LIKE makt-MATNR,
MAKTX LIKE makt-MAKTX,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
matnr LIKE makt-MATNR,
MAKTX LIKE makt-MAKTX,
END OF itab1.
data : a(5) type c value 'TEST'.
perform mat_no using a.
form mat_no using p_a.
data : lv_temp(4) type c.
select matnr maktx from makt into table itab.
loop at itab.
lv_temp = itab-maktx+0(4).
if lv_temp = p_a.
move itab to itab1.
APPEND ITAB1.
endif.
endloop.
loop at itab1.
write :/ itab1.
endloop.
endform. " mat_no
Thanks.
Amjad.
Maybe you are looking for
-
Macbook pro takes long to boot up 30 minutes
Hi all, First of all, thanks for all the help this community has provided so far. Unfortunately I haven't been able to find a solution so far. Product: MacBook Pro (13-inch, Mid 2010) OS X 10.6.8 2.4GHz Intel core 2 duo 4GB 1067 MHz DDR3 It is quite
-
How to search a .csv file for data using its timestamp, then import to labview
Hi, I'm currently obtaining density, viscosity and temperature data from an instrument, adding a timestamp and writing it to a .csv file which I can view in Excel. This works fine (see attached code) but what I need to do now is to search that csv fi
-
CI (ABAP+Java) & DB in one AIX box and dialog Instance on a Linux box
We trying to install SAP, CI+DB in one AIX box and dialog Instance on a Linux box. We are facing problem when trying to install Java Dialog Instance. Is it possible and recomended to install in the above manner? Has anyone done this? please share you
-
Merge form responses for review?
We have a scholarship application PDF form which requires submission of three references. Currently, each reference is submitted on a separate PDF reference form. What is the best way to include all three references with each submitter's application
-
Polling log and BPEL instance limitation
Hi all, I have following queries regarding the polling... 1. For all instances in the polling, log file will be created only one. And instances will be running parallelly, so will the log also be mixed for all logs. I mean first log msg from first in