Java Aggregate Function
I'd like to write an aggregate funtion in Java. I've successfully implemented the types and methods in PL/SQL, but the documentation does not seem to provide any java examples. Just says, load the the CartridgeServices and ODCI packages, use a context, and have a go. I don't see the methods I used with PL/SQL:
ODCIAggregateInitialize()
ODCIAggregateIterate()
ODCIAggregateTerminate()
ODCIAggregateMerge()
I expected to see java implementations in the above packages, but maybe this is not what I should be using? Has anyone done this? Do I even need to override these functions?
Thanks,
Jason.
Hello again,
I opened a case at BEA's ticketing system and it took BEA about 3 weeks just to inform me that my company has no valid kodo-license and i therefore am not allowed to open tickets, which is not quite true, because my company has indeed a valid license - otherwise i wouldn't have been able to open a ticket in the first place.
To make a long story short, i did my best reporting this bug to BEA by posting in the forum and opening a case, and now i hope this thing's getting fixed anyway.
So long,
Markus
Similar Messages
-
Java JDBC-ODBC GROUP BY (aggregate function) error
I get the error
"java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'CUSTOMER_ID' as part of an aggregate function."
when I try to execute the following query:
PreparedStatement stmt = connection.prepareStatement(
"SELECT Customers.customer_id, Customers.customer_name, SUM(Transactions.surcharge) AS surcharge, SUM(Transactions.interchange) AS interchange, SUM(Transactions.approved) AS transactions " +
"FROM (Customers INNER JOIN Terminals ON Customers.customer_id = Terminals.customer_id) " +
"INNER JOIN Transactions ON Terminals.terminal_id = Transactions.terminal_id " +
"WHERE Transactions.transaction_date=#12/8/2003# " +
"GROUP BY Customers.customer_id, Customers.customer_name",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY
Funny thing is this query works fine when I execute it in Microsoft Access directly. I can't figure out what's causing the problem. Any help?Have you tried:
PreparedStatement stmt = connection.prepareStatement(
"SELECT Customers.customer_id, Customers.customer_name, SUM(Transactions.surcharge) AS surcharge, SUM(Transactions.interchange) AS interchange, SUM(Transactions.approved) AS transactions " +
"FROM (Customers INNER JOIN Terminals ON Customers.customer_id = Terminals.customer_id) " +
"INNER JOIN Transactions ON Terminals.terminal_id = Transactions.terminal_id " +
"WHERE Transactions.transaction_date=#12/8/2003# " +
"GROUP BY customer_id, customer_name",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY
(Who knows ?... Sometimes SQL engines are very strangely built!) -
Lookiing for example of a user define aggregate function in Java
I want to write an aggregate function in Java. Every example I found is in PL/SQL.
I have written my fair share of JSPs, but this is different in that it is methods off an object.
The documentation says it can be done in Java, but it's not clear to me how to define the ODCIAggregateInitialize, ODCIAggregateIterate, ODCIAggregateTerminate, and ODCIAggregateMerge methods.
If any one can point me to, or send me, an example, I would be very grateful.
TIAHii Greg:
You can find the code to implement a Domain Index for Oracle which uses ODCI Api in Java at.
http://dbprism.cvs.sourceforge.net/viewvc/dbprism/ojvm/src/java/org/apache/lucene/indexer/LuceneDomainIndex.java?revision=1.29&view=markup
This is the code of the implementation of the Lucene Domain Index:
http://docs.google.com/Doc?id=ddgw7sjp_54fgj9kg
The strategy to implement an use aggregate function is similar to implement a Domain Index.
The PLSQL wrapper for the above code is:
http://dbprism.cvs.sourceforge.net/viewvc/dbprism/ojvm/db/LuceneDomainIndex.sql?revision=1.20&view=markup
Take a look at the code and if you have another question just drop me an email or post again into this list.
Best regards, Marcelo. -
Does EJBQL in JDeveloper support max aggregate function ?
Does EJBQL in JDeveloper support max aggregate function ?
I can't get it to work using select max(o.time) from MyObject o; It always returns the MyObject to me.
Anybody knows how to do this ?
Thanks.No one knows how exactly this works in JDeveloper 11g? As I see it, it's most likely a bug. For one, JDeveloper already supports plenty of databases and enforces some limitations on the useability of these databases where necessary (for instance, JDBC Positioning instead of Oracle's way of binding for the bind variables in a query). However, this enforcement does not happen with the WHERE clause of the view criteria in MySQL when you choose an operator that concatenates strings together in the WHERE clause, such as "contains". You'd expect it's smart enough to use different syntax for concatenating the strings, depending on the database (e.g., CONCAT for MySQL, || for Oracle). Second, lack of this enforcement should not break functionality, and here it does (searching with wildcards in LOV is just not possible declaratively with MySQL), which resembles a bug in the software.
For now, I've completely rewritten the LOV in Java, so it's not declarative anymore, but programmatic. It works, resembles searching with "contains" and it stays that way, despite of the higher difficulty in maintenance, until this issue can be solved declaratively, by any means: via a patch release or via a workaround. I hope someone can provide me (and quite possibly others facing this issue) with insight upon this.
Thanks in advance. -
How to get the value retruned by java script function into my jsp page
Hai all,
I had a particular java script function which returns a date.
function getDate() {
var sDate;
// This code executes when the user clicks on a day in the calendar.
if ("TD" == event.srcElement.tagName)
// Test whether day is valid.
if ("" != event.srcElement.innerText)
//alert(event.srcElement.innerText);
sDate = document.all.year.value + "-" + document.all.month.value + "-" + event.srcElement.innerText;
document.all.ret.value = sDate;
var mahi=window.open("configurexml.jsp?xyz=document.all.ret.value")
return sDate;}
Now i want to display this particular date in my jsp page. can anyone tell me the correct approach or a sample code to diaplay this date in my jsp page.
<%@ page language="java"
import="javax.xml.parsers.*,java.io.*,org.w3c.dom.*"%><%@ page import="java.util.*" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <head> <title>Configuring Xml File</title>
<SCRIPT LANGUAGE="JavaScript" SRC="xyz.js"> </SCRIPT>
body bgcolor="#d0d0d0" onClick= "return getDate()" >
<form name="f1">
<b>20 october 2006 </b>
Here where i am printing the date i had to get the value from the js function. how to do that. plz help me....Are you talking about server-side java code (servlets/jsp) or client side (applet)? Given we are in the JSP forum I'll assume we're talking server side.
If so, you are making a common but fundamental mistake. JavaScript executes on the client, not on the server. If you want client data on the server it has to get there somehow. The simplest way to do this in JSP land is via HTTP. So... have your JavaScript code call a JSP (or servlet) and pass the value you want as a URL parameter. Of course this will also change the browser location, so if you don't want this to happen use a frame or iframe to capture your HTTP request.
For example:
Javascript....
function someFunction() {
return 1;
var value = someFunction();
location.href="somejsp.jsp?value=" + value; -
How to call the java method in java script function in a portal application
Hi Friends,
I am developing one application where i need to fetch the data from KM content and displaying it on the screen in regular interval. I wrote one method in JSPdynpage for fetching data from KM content now I need to call that java method in java script function.
java method(IComponentRequest request)
//Coode for fetching the KM content
function()
<b>//Need to call the java method</b>
setTimeout(function, 5000);//setting the time interval for this function
<<htmlb display code>>
If anybody can help me in calling the java method in java script function that will be very helpful for me.
Thanks in advance,
Sandeep BonamHi,
Pls see if the following links could help.
http://www.rgagnon.com/javadetails/java-0170.html
http://www-128.ibm.com/developerworks/library/wa-resc/?dwzone=web
Regards -
Trying to create a Histogram type/object for aggregate functions
Hi,
I am trying to create an aggregate function that will return a histogram
type.
It doesn't have to be an object that is returned, I don't mind returning
a string but I would like to keep the associative array (or something
else indexed by varchar2) as a static variable between iterations.
I started out with the SecondMax example in
http://www.csis.gvsu.edu/GeneralInfo/Oracle/appdev.920/a96595/dci11agg.htm#1004821
But even seems that even a simpler aggregate function like one strCat
below (which works) has problems because I get multiple permutations for
every combination. The natural way to solve this would be to create an
associative array as a static variable as part of the Histogram (see
code below). However, apparently Oracle refuses to accept associate
arrays in this context (PLS-00355 use of pl/sql table not allowed in
this context).
If there is no easy way to do the histogram quickly can we at least get
something like strCat to work in a specific order with a "partition by
... order by clause"? It seems that even with "PARALLEL_ENABLE"
commented out strCat still calls merge for function calls like:
select hr,qtr, count(tzrwy) rwys,
noam.strCat(cnt) rwycnt,
noam.strCat(tzrwy) config,
sum(cnt) cnt, min(minscore) minscore, max(maxscore) maxscore from
ordrwys group by hr,qtr
Not only does this create duplicate entries in the query result like
"A,B,C" and "A,C,B" it seems that the order in rwycnt and config are not
always the same so a user can not match the results based on their
order.
The difference between my functions and functions like sum and the
secondMax demonstrated in the documentation is that secondMax does not
care about the order in which it gets its arguments and does not need to
maintain an ordered set in order to return the correct results. A good
example of a built in oracle function that does care about all its
arguments and probably has to maintain a similar data structure to the
one I want is the PERCTILE_DISC function. If you can find the code for
that function (or something like it) and forward a reference to me that
in itself would be very helpful.
Thanks,
K.Dingle
CREATE OR REPLACE type Histogram as object
-- TYPE Hist10 IS TABLE OF pls_integer INDEX BY varchar2(10),
-- retval hist10;
-- retval number,
retval noam.const.hist10,
static function ODCIAggregateInitialize (sctx IN OUT Histogram)
return number,
member function ODCIAggregateIterate (self IN OUT Histogram,
value IN varchar2) return number,
member function ODCIAggregateTerminate (self IN Histogram,
returnValue OUT varchar2,
flags IN number) return number,
member function ODCIAggregateMerge (self IN OUT Histogram,
ctx2 IN Histogram) return number
CREATE OR REPLACE type body Histogram is
static function ODCIAggregateInitialize(sctx IN OUT Histogram) return
number is
begin
sctx := const.Hist10();
return ODCIConst.Success;
end;
member function ODCIAggregateIterate(self IN OUT Histogram, value IN
varchar2)
return number is
begin
if self.retval.exist(value)
then self.retval(value):=self.retval(value)+1;
else self.retval(value):=1;
end if;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate(self IN Histogram,
returnValue OUT varchar2,
flags IN number)
return number is
begin
returnValue := self.retval;
return ODCIConst.Success;
end;
member function ODCIAggregateMerge(self IN OUT Histogram,
ctx2 IN Histogram) return number is
begin
i := ctx2.FIRST; -- get subscript of first element
WHILE i IS NOT NULL LOOP
if self.retval.exist(ctx2(i))
then self.retval(i):=self.retval(i)+ctx2.retval(i);
else self.retval(value):=ctx2.retval(i);
end if;
i := ctx2.NEXT(i); -- get subscript of next element
END LOOP;
return ODCIConst.Success;
end;
end;
CREATE OR REPLACE type stringCat as object
retval varchar2(16383), -- concat of all value to now varchar2, --
highest value seen so far
static function ODCIAggregateInitialize (sctx IN OUT stringCat)
return number,
member function ODCIAggregateIterate (self IN OUT stringCat,
value IN varchar2) return number,
member function ODCIAggregateTerminate (self IN stringCat,
returnValue OUT varchar2,
flags IN number) return number,
member function ODCIAggregateMerge (self IN OUT stringCat,
ctx2 IN stringCat) return number
CREATE OR REPLACE type body stringCat is
static function ODCIAggregateInitialize(sctx IN OUT stringCat) return
number is
begin
sctx := stringCat('');
return ODCIConst.Success;
end;
member function ODCIAggregateIterate(self IN OUT stringCat, value IN
varchar2)
return number is
begin
if self.retval is null
then self.retval:=value;
else self.retval:=self.retval || ',' || value;
end if;
return ODCIConst.Success;
end;
member function ODCIAggregateTerminate(self IN stringCat,
returnValue OUT varchar2,
flags IN number)
return number is
begin
returnValue := self.retval;
return ODCIConst.Success;
end;
member function ODCIAggregateMerge(self IN OUT stringCat,
ctx2 IN stringCat) return number is
begin
self.retval := self.retval || ctx2.retval;
return ODCIConst.Success;
end;
end;
CREATE OR REPLACE FUNCTION StrCat (input varchar2) RETURN varchar2
-- PARALLEL_ENABLE
AGGREGATE USING StringCat;GraphicsConfiguration is an abstract class. You would need to subclass it. From the line of code you posted, it seems like you are going about things the wrong way. What are you trying to accomplish? Shouldn't this question be posted in the Swing or AWT forum?
-
Error in using aggregate function in Outer Query in Siebel Analytics
Hi,
When I am using aggregate function in outer query in Siebel Analytics I am facing error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59111] The SQL statement must include a GROUP BY clause. (HY000)
Bellow is the code.
SELECT test1.username saw_0, test1.desg saw_1,COUNT (test2.querydate) saw_2
FROM (SELECT POSITION.CBL username,
POSITION.CBP desg
FROM "CM"
WHERE (POSITION.BPTCD = 'Marketing')
AND (POSITION.EDate =TIMESTAMP '1899-01-01 00:00:00'
) test1,
(SELECT users.UN username,
measures."Query Count" querycount,
measures."Max Total Time" secs,
topic.db dashboardname,
"Query Time".DATE querydate
FROM "Plan"
WHERE (topic."Dashboard Name" IN ('DS'))) test2
WHERE test2.username = LOWER (test1.username)
AND test2.dashboardname = 'DS'
GROUP BY test1.username, test1.desgShould your query be a valid SQL query?
I can't think that the query you have would be valid in a SQL plus window.
Chris -
EJB 3.0: EJBQL aggregate functions not working properly
Hi!
We are experiencing problems when using aggregate functions within EJBQL queries. In my case, we have to use max() function to retrieve the max start_date from a specific table. In order to do this, we wrote the following code:
String strQuery = "select max(o.dt_fim) from Questionario o";
Query queryTeste = em.createQuery(strQuery);
List x = queryTeste.getResultList();
OBS: dt_fim is an Oracle 10g datetime column, with its corresponding entity attribute in Questionario entity class.
AFAIK, the query above should return only one record (object instance) containing the date value, right? However, it brougth a list of the entity objects, corresponding to all records in the table, as we had just run "select o from Questionario o".
Examining the server log we can see this behavior:
[TopLink Fine]:2006.09.12 01:47:55.526--
ServerSession(7119662)--Connection(7048401)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])
--SELECT ID_QUEST, DT_INICIO, DT_FIM, DS_QUEST, DT_CRIACAO, TP_QUEST, NM_QUEST, COD_SEGMENTO, ID_GRUPO FROM TBBOP_QUEST
Are anyone experiencing this issue?
Is there any workaround?
Any help would be much appreciated, since we need to deploy the application for user testing asap.
Thanks in advance.
Best regards,
Gustavo
PS: We are using JDeveloper 10.1.3.0.4(SU4)
Message was edited by:
Gustavo Lopes SobralThe 10.1.3.0 versions of JDeveloper contain our early preview of EJB 3.0 JPA functionality. One limitation is that the query language is not complete (released before the spec was finalized).
You can use TopLink Essentials (JPA Reference implementation) whihc contains a complete compliant implementation of the final specification.
http://otn.oracle.com/jpa
The 10.1.3.1 JDeveloper preview ships with TopLink Essentials.
Doug -
Pivot table in BI Publisher: Different aggregate functions in data columns
Hi, everyone!
I`ve got some troubles with pivot table in my rtf-template.
Here is my xml:
<ROWSET>
<ROW>
<_BI_SUBRF_MO_._MUN_NAME_>МО Петроградский р-н</_BI_SUBRF_MO_._MUN_NAME_>
<_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>714000003</_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>
<_BI_MONTH_DEBET_._BI_DEBET_SUM_>0.0</_BI_MONTH_DEBET_._BI_DEBET_SUM_>
<_BI_CALENDAR_._YEAR__>2009</_BI_CALENDAR_._YEAR__>
<_BI_CALENDAR_._MONTH__>8</_BI_CALENDAR_._MONTH__>
</ROW>
<ROW>
<_BI_SUBRF_MO_._MUN_NAME_>МО Петроградский р-н</_BI_SUBRF_MO_._MUN_NAME_>
<_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>714000004</_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>
<_BI_MONTH_DEBET_._BI_DEBET_SUM_>165.58</_BI_MONTH_DEBET_._BI_DEBET_SUM_>
<_BI_CALENDAR_._YEAR__>2009</_BI_CALENDAR_._YEAR__>
<_BI_CALENDAR_._MONTH__>7</_BI_CALENDAR_._MONTH__>
</ROW>
<ROW>
<_BI_SUBRF_MO_._MUN_NAME_>МО Петроградский р-н</_BI_SUBRF_MO_._MUN_NAME_>
<_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>714000004</_BI_PERS_ACCOUNT_CARD_._BI_PAC_NMB_>
<_BI_MONTH_DEBET_._BI_DEBET_SUM_>165.58</_BI_MONTH_DEBET_._BI_DEBET_SUM_>
<_BI_CALENDAR_._YEAR__>2009</_BI_CALENDAR_._YEAR__>
<_BI_CALENDAR_._MONTH__>7</_BI_CALENDAR_._MONTH__>
</ROW>
...... and so on..
</ROWSET>
In the pivot table i`d like to see one row for every BISUBRF_MO_._MUN_NAME_ using BICALENDAR_._YEAR__ and BICALENDAR_._MONTH__ as measures and sum of BIMONTH_DEBET_._BI_DEBET_SUM_ and count of unique (or at least just count of) BIPERS_ACCOUNT_CARD_._BI_PAC_NMB_ in cells.
I create a pivot table using wizard, everything ok except one thing: as i understand, in pivot table for data in rows we can use only one kind of aggregate function e.g. only sum or only count.
Is there any way to use different aggregate functions in data cells?
Thank youAs you can see, when we use crosstab tag we can specify only one aggregate function for data cells.
Is there any way to get in XSL-FO (where we can what really happens) instead of:
<T1>
<xsl:value-of select="sum(current-group()/_BI_PERS_ACCOUNT_CARD_._BI_PAC_UNID_)"/>
</T1>
<T2>
<xsl:value-of select="sum(current-group()/_BI_MONTH_DEBET_._BI_DEBET_SUM_)"/>
</T2>
this
<T1>
<xsl:value-of select="sum(current-group()/_BI_PERS_ACCOUNT_CARD_._BI_PAC_UNID_)"/>
</T1>
<T2>
<xsl:value-of select="count(current-group()/_BI_MONTH_DEBET_._BI_DEBET_SUM_)"/>
</T2>
Edited by: user12115038 on 26.10.2009 8:08 -
Issue in pivot while using aggregate functions
when I use this below query in oracle sql developer
------------->select sum(round(8.08/0.54,2)*30) from dual.
i am getting result as 448.8.it is a correct value
but i use this below queries in pivot as same like above query i am getting result of doubled value 914.4.
PIVOT
SUM(round(ROUND(sellout,2)/6,2)) AS LAST_6_MON_SELL_OUT,
SUM(ROUND(inventory,2)) AS INVENTORY_INTINS_1,
Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)*30) As Stockperday
FOR PRODUCT IN (56,78)
actually i am getting value for SUM(round(ROUND(sellout,2)/6,2)) is 0.54,*SUM(ROUND(inventory,2))* is 8.08 i the above query ,but i am getting wrong value for this aggregate function Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)30)* as 914.4.but actual value is 448.8
why this problem.can anybody explain me.why this problemTry ur luck in 'sql plsql thread'
PL/SQL -
Why doesn't PIVOT clause work with COLLECT aggregate function in 11g ?
Hello all !
I am really puzzled as to what is considered an aggregate function in the context of the PIVOT clause in 11g.
I have been toying with quite a few things related to collections lately and this arose as an aside :
CREATE TABLE TEST_COLL
NODE_ID VARCHAR2(15 CHAR) NOT NULL,
NODE_VALUE VARCHAR2(45 CHAR) NOT NULL,
NODE_LEVEL NUMBER(1) NOT NULL
CREATE OR REPLACE TYPE TREE_NODE AS OBJECT
NODE_KEY VARCHAR2( 15 CHAR),
NODE_NAME VARCHAR2(127 CHAR)
CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL;At this stage I am sure we all agree that the query
SELECT NODE_LEVEL,
CAST(COLLECT(TREE_NODE(NODE_ID, NODE_VALUE)) AS TREE_NODES) AS NODES
FROM TEST_COLL
GROUP BY NODE_LEVEL;is perfectly valid as the COLLECT function is an aggregate function according to the [Official Documentation|http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions031.htm#i1271564]
But then, one of the following two queries should work
SELECT CAST(REGION_NODES AS TREE_NODES) AS REGIONS,
CAST(DEPARTMENT_NODES AS TREE_NODES) AS DEPARTMENTS,
CAST(AREA_NODES AS TREE_NODES) AS AREAS,
CAST(CENTRE_NODES AS TREE_NODES) AS CENTRES
FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
FROM TREE_COLL
PIVOT (COLLECT(NODE) FOR NODE_LEVEL IN (1 AS REGION_NODES,
2 AS DEPARTMENT_NODES,
3 AS AREA_NODES,
4 AS CENTRE_NODES
or (better)
SELECT REGION_NODES AS REGIONS,
DEPARTMENT_NODES AS DEPARTMENTS,
AREA_NODES AS AREAS,
CENTRE_NODES AS CENTRES
FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
FROM TREE_COLL
PIVOT (CAST(COLLECT(NODE) AS TREE_NODES) FOR NODE_LEVEL IN (1 AS REGION_NODES,
2 AS DEPARTMENT_NODES,
3 AS AREA_NODES,
4 AS CENTRE_NODES
);yet, both fail with
ORA-56902: expect aggregate function inside pivot operationInvestigating further, I found the same behaviour when using XMLAGG as the aggregate function in the PIVOT clause.
Is this normal ? And if it is, is there any other way to achieve the result I was anticipating ?
My version is
SQL> SELECT BANNER FROM V$VERSION;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - ProductionThanks in advance
Best Regards
PhilipMost likely a bug. But you can bypass it by using any other aggregate making sure group consists of a single row and apply collect to a pivoted value. Yes, the cost is double aggregation. And also there is another cost - you would need to create MAP member function otherwise aggreations like MAX/MIN, etc. will not work:
CREATE OR REPLACE TYPE TREE_NODE AS OBJECT
NODE_KEY VARCHAR2( 15 CHAR),
NODE_NAME VARCHAR2(127 CHAR),
map member function f return varchar2
Type created.
CREATE OR REPLACE TYPE BODY TREE_NODE AS
map member function f return varchar2 is
begin
return NODE_NAME;
end f;
end;
Type body created.
CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL
Type created.
SQL> select *
2 from test_coll
3 /
NODE_ID NODE_VALUE NODE_LEVEL
1 A 1
2 B 2
3 C 3
4 D 4
5 E 1
6 F 2
7 G 3
8 H 4
8 rows selected.
SQL> Now:
SELECT CAST(COLLECT(REGION_NODES) AS TREE_NODES) AS REGIONS,
CAST(COLLECT(DEPARTMENT_NODES) AS TREE_NODES) AS DEPARTMENTS,
CAST(COLLECT(AREA_NODES) AS TREE_NODES) AS AREAS,
CAST(COLLECT(CENTRE_NODES) AS TREE_NODES) AS CENTRES
FROM (
SELECT ROWID RID,
NODE_LEVEL,
TREE_NODE(NODE_ID, NODE_VALUE) AS NODE
FROM TEST_COLL
PIVOT (MAX(NODE) FOR NODE_LEVEL IN (
1 AS REGION_NODES,
2 AS DEPARTMENT_NODES,
3 AS AREA_NODES,
4 AS CENTRE_NODES
REGIONS(NODE_KEY, NODE_NAME) DEPARTMENTS(NODE_KEY, NODE_NAME) AREAS(NODE_KEY, NODE_NAME) CENTRES(NODE_KEY, NODE_NAME)
TREE_NODES(TREE_NODE('1', 'A'), TREE_NODE('5', 'E')) TREE_NODES(TREE_NODE('6', 'F'), TREE_NODE('2', 'B')) TREE_NODES(TREE_NODE('7', 'G'), TREE_NODE('3', 'C')) TREE_NODES(TREE_NODE('8', 'H'), TREE_NODE('4', 'D'))
SQL> SY. -
Aggregate functions cannot be used in group expressions
Hi have report showing sales by Vendor. I need to list all the vendors with Monthly Total>5000 and combine the rest as "OTHER VENDORS"
Vendor is a Group in my report, so I tried to put an expression as a Group on:
=IIF(Sum(Fields!Mth_1_Sales.Value)>5000,Fields!Vendor_No.Value,"OTHER VENDORS")
I've got an error: "aggregate functions cannot be used in group expressions"
How do I get Vendors with Sales < 5000 into "OTHER VENDORS" ?Hi,
You need to group by Month on group expression,
And you can use the same expression in the report column as
=IIF(Sum(Fields!Mth_1_Sales.Value)>5000,Fields!Vendor_No.Value,"OTHER VENDORS")
Many Thanks
..................................................................................................................................................................Please
mark the post as Please mark the post as answered if this post helps to solve the post. -
How can I use User-Defined Aggregate Functions in Timesten 11? such as ODCI
Hi
we are using Timesten 11 version and as per the documentation, it doesn't support User-Defined Aggregate Functions.
So we are looking for alternatives to do it. Could you please provide your expert voice on this.
Thanks a lot.
As the following:
create or replace type strcat_type as object (
cat_string varchar2(32767),
static function ODCIAggregateInitialize(cs_ctx In Out strcat_type) return number,
member function ODCIAggregateIterate(self In Out strcat_type,value in varchar2) return number,
member function ODCIAggregateMerge(self In Out strcat_type,ctx2 In Out strcat_type) return number,
member function ODCIAggregateTerminate(self In Out strcat_type,returnValue Out varchar2,flags in number) return
number
How can I use User-Defined Aggregate Functions in Timesten 11? such as ODCIAggregateInitialize ?Dear user6258915,
You absolutely right, TimesTen doesnt support object types (http://docs.oracle.com/cd/E13085_01/doc/timesten.1121/e13076/plsqldiffs.htm) and User-Defined Aggregate Functions.
Is it crucial for your application? Could you rewrite this functionality by using standart SQL or PL/SQL?
Best regards,
Gennady -
Can't have aggregate function in WHERE clause clause
Dear all,
I've created object in BO XI 3.1 Designer with following criterias:
http://img4.imageshack.us/img4/833/20111201124314.th.jpg
It is a simple number - 1,2,3,4,5.
Now I need to use this object as a criteria for WHERE function in another object.
http://img607.imageshack.us/img607/1543/20111201124717.th.jpg
I receive an error "Can't have aggregate function in WHERE clause <clause>"
How can I overcome this?
P.S. I'm sorry in advance if such topic already exist - I didn't found one.
Edited by: Ashot Antonyan on Dec 1, 2011 9:50 AM
Edited by: Ashot Antonyan on Dec 1, 2011 9:51 AMHi,
You will have to use Sub query to achieve this. Give more details on what is available and what you need then i could help you out with the complete solution.
Thanks,
Ravichandra K
Maybe you are looking for
-
The children had new IPhones 5s bought for them by my ex-husband. He set them up and logged them into his Icloud account which they were unaware of. Some months later they have messages saying their Icloud storage is full which alerted them to the fa
-
A New Year, a New Challenge! Become the FIRST SSAS Guru of 2015!
Happy New Year! "Guru 2014" is so 'last year'! The real glory is to be the first Guru of 2015! :D The birth of a new year, and a new hero? Or the stamp of authority from long established Guru leaders? The challenge is on, all eyes are watching, anyon
-
Problem with Business Objects 4.0 SP2 Windows install
Hello Experts, I have followed the steps outlined by Mr. Gingle's blog "Caboodle - Part 3 - The BOBJ4 Install" Caboodle - Part 3 - The BOBJ4 Install to do a vanilla BusinessObjects 4.o SP2 Windows install. The install goes fine but I do not se
-
How to sell Lightroom plug-in on the Adobe
I have created a couple of plug-ins that I would like to publish on the Adobe website Lightroom 4 / In depth : Plug-ins see : https://www.adobe.com/products/photoshop-lightroom/plugins-presets.html Question: how can I have my plug-ins add to this web
-
Compiling for Windows and Java
Hi All This is a deff newbie question. Basically i have a program that will compile in Windows, but if I try and compile it in Linux (CentOS) then I get 48 errors all related to graphics of constructors. It was my understanding that Java was meant to