Using ORDER BY in UNION clause in cursor
Hi Everybody,
I have one situation and i need your help guys. I have to use ORDER BY in UNION of two queries and return value in cursor.
OPEN cursor FOR
SELECT ID, DESC,SID, ITID, SID_DESC
FROM (SELECT A.ID,
A.DESC,
B.SID,
NULL AS ITID,
B.SID_DESC
FROM TABLEA A, TABLEB B
WHERE A.ID = B.ID
order by A.SORTORDER asc,B.SORTORDER)
UNION
SELECT ID, DESC, ,SID,ITID, ITID_DESCRIPTION,
FROM (SELECT A.ID,
A.DESC,
NULL AS SID,
C.ITID,
C.ITID_DESC,
FROM TABLEA A,
TABLEC C
WHERE A.ID = C.ID
order by A.SORTORDER asc,C.SORTORDER)
I SORT ORDER is column in all three tables. TABLEA has unique number for each record as sort order. TABLEB has sortorder as 1 for each id. If id is two times then its 1 and 2 for each id. TABLEC has sort order as TABLEB, 1 for each id and if id is two times then it is 1 and 2 and id id is three times, it is 1, 2, 3.
I am not getting correct sorting as i cant use order by like this in UNION. Please let me know how i can handle this.
Thank you in advance to everybody.
I will really appreciate your comments and responses.
Hi,
You can use ORDER BY in a sub-query, but there's usually no point in doing so, because the super-query won't necessarily preserve that order. You need to make the columns that you want to ORDER BY available to the main query, so that they can be used there.
Try this:
SELECT ID, DESC,SID, ITID, SID_DESC
FROM (
SELECT A1.ID,
A1.DESC,
B.SID,
NULL AS ITID,
B.SID_DESC,
A1.SORTORDER AS sortorder_1
B.SORTORDER AS sortorder_2
FROM TABLEA A1,
TABLEB B
WHERE A1.ID = B.ID
UNION
SELECT A2.ID,
A2.DESC,
NULL AS SID,
C.ITID,
C.ITID_DESC,
A2.SORTORDER AS sortorder_1
B.SORTORDER AS sortorder_2
FROM TABLEA A2,
TABLEC C
WHERE A2.ID = C.ID
order by SORTORDER_1 ASC -- ASC is the default, but it doesn't hurt to say it
SORTORDER_2This assumes that tableb.sortorder and tablec.sortorder have the same, or at least similar, data types. If not, explicitly convert sortorder_1 in one branch of the UNION to the type of sortorder_2 in the other branch.
Using the same alias to mean different things in the same query is just asking for trouble. I changed the table alias a (which was used in different places to mean two different things) to A1 and A2, each of which means only one thing.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Similar Messages
-
hi Following is my query and am unable to accomplish my order by statement in Union All . please help me in this.
<code>
SELECT b.audit_trail_id,
TO_CHAR (b.last_update_date, 'DD-Mon-YYYY') "Revision Date",
(u.last_name || ', ' || u.first_name || ' ' || u.mi) "By",
b.col_name "Field",
b.new_value "New Value",b.previous_value "Old Value",
a.lot_id,
b.comment_text "Comments"
FROM clem_audit_trail b,lot a, users u
WHERE a.lot_id = b.lot_id(+)
AND u.user_id(+) = b.last_update_user_id
AND a.lot_id in (select lot_id from request_lot where request_id = 51914)
AND col_name IN
('Interim Release Date',
'Final Disposition Date',
'On Time Disposition',
'Intended Use',
'REJECTS_YN',
'# of QARs',
'# of Quality Events',
'# of LIRs',
'# of Change Controls',
'# of Batch Records',
'# of GMP Batch Records',
'EXPLANATION',
'QA Notes',
'GDMS_LINK')
AND UPPER (table_name) IN('LOT') order by b.last_update_date
UNION ALL
SELECT b.audit_trail_id,
TO_CHAR (b.last_update_date, 'DD-Mon-YYYY') "Revision Date",
(u.last_name || ', ' || u.first_name || ' ' || u.mi) "By",
b.col_name "Field",
b.new_value "New Value",b.previous_value "Old Value",
r.request_id,
b.comment_text "Comments"
FROM clem b,request r, users u
WHERE r.request_id = b.request_id(+)
AND u.user_id(+) = b.last_update_user_id
AND r.request_id = 51914
AND UPPER (table_name) IN ('REQUEST') AND
b.col_name IN ('Partial Release',
'All QP Docs in GDMS',
'Number of Batch Records',
'Request',
'QP Issues',
'Snag Comments',
'Responsible Group',
'Reason Late',
'Study Impact',
'Other Details',
'Request Status',
'QP Link to GDMS'
) order by b.last_update_date
</code>
If i execute individually it works fine, if i use union all it throughs error for me.
Any suggestion...Hi,
In a set operation (such as UNION) table aliases (such as b.) only have meaning within the branch in which they are defined. The ORDER BY clause is not part of any 1 branch, so a table alias can't be used there.
In most cases, you can use a column name (or alias) from the first branch, like this:
SELECT b.audit_trail_id,
TO_CHAR (b.last_update_date, 'DD-Mon-YYYY') "Revision Date",
order by "Revision Date"
;and you can always order by column number, like this:
SELECT b.audit_trail_id,
TO_CHAR (b.last_update_date, 'DD-Mon-YYYY') "Revision Date",
order by 2
;In this case, however, there's an extra problem. You're transforming the DATE to a string in the SELECT clause. The string is all that's available in the ORDER BY clause, and the string '19-NOV-2012' comes after the string '01-JAN-2015', because the character '1' comes after '0'. Perhaps the simplest solution is to have your front end, and not the query, format the dates. In SQL*Plus, you can do this:
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
SELECT b.audit_trail_id,
b.last_update_date AS "Revision Date",
order by 2
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
Order by clause in cursor problem
Hello,
I'm unable to compile package body when i'm using order by clause in cursor subquery in stored procedure.
Sample code:
CREATE PACKAGE Announces AS
TYPE tRefCur IS REF CURSOR;
PROCEDURE TopAnnounces(
iiCount IN NUMBER,
osAnnounces OUT tRefCur,
oiRetVal OUT NUMBER
END Announces;
CREATE PACKAGE BODY Announces AS
PROCEDURE TopAnnounces(
iiCount IN NUMBER,
osAnnounces OUT NUMBER,
oiRetVal OUT NUMBER
AS
BEGIN
OPEN osAnnounces FOR
SELECT Id, Name, AnnCount FROM
SELECT Id, Name, COUNT(CategoryId) AS AnnCount FROM tblAnnounces
GROUP BY Id, Name
-- bellow is the line, where the code crash
ORDER BY AnnCount DESC
WHERE ROWNUM < iiCount + 1;
oiRetVal := 0;
EXCEPTION
WHEN OTHERS THEN
oiRetVal := -255;
END TopAnnounces;
END Announces;
If I compile the code above I will get this error:
PLS-00103: Encoutered the symbol "ORDER" when expecting on of the following:
After I remark the problematic line, the compilation is successful (but not the result :).
Is there something I'm doing wrong?
Thanks for advice
Vojtech Novacek
nullSorry you can not use order by clause into one temporal table created by subquery.
Put the order by clause offside of subquery.
Atte.
CC.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Vojtech Novacek:
Hello,
I'm unable to compile package body when i'm using order by clause in cursor subquery in stored procedure.
Sample code:
CREATE PACKAGE Announces AS
TYPE tRefCur IS REF CURSOR;
PROCEDURE TopAnnounces(
iiCount IN NUMBER,
osAnnounces OUT tRefCur,
oiRetVal OUT NUMBER
END Announces;
CREATE PACKAGE BODY Announces AS
PROCEDURE TopAnnounces(
iiCount IN NUMBER,
osAnnounces OUT NUMBER,
oiRetVal OUT NUMBER
AS
BEGIN
OPEN osAnnounces FOR
SELECT Id, Name, AnnCount FROM
SELECT Id, Name, COUNT(CategoryId) AS AnnCount FROM tblAnnounces
GROUP BY Id, Name
-- bellow is the line, where the code crash
ORDER BY AnnCount DESC
WHERE ROWNUM < iiCount + 1;
oiRetVal := 0;
EXCEPTION
WHEN OTHERS THEN
oiRetVal := -255;
END TopAnnounces;
END Announces;
If I compile the code above I will get this error:
PLS-00103: Encoutered the symbol "ORDER" when expecting on of the following:
After I remark the problematic line, the compilation is successful (but not the result :).
Is there something I'm doing wrong?
Thanks for advice
Vojtech Novacek<HR></BLOCKQUOTE>
null -
Using order by with the UNION ALL operator
Hi,
I have 2 queries and i'm using UNION ALL to join both of them.
And i want to sort the final result based on a column.
When i try to do that, its not allowing me to use the ORDER BY clause.
Any suggestions??
Example
select * from xxx where job='Manager'
order by ename
union all
select * from yyy where job='Engineer'
order by ename
Thanks in advance
--KumarSQL> select * from test_emp where deptno = 10 order by ename
2 union all
3 select * from test_emp where deptno = 20 order by ename;
union all
ERROR at line 2:
ORA-00933: SQL command not properly ended
SQL> select * from test_emp where deptno = 10 --order by ename
2 union all
3 select * from test_emp where deptno = 20 order by ename;
select * from test_emp where deptno = 20 order by ename
ERROR at line 3:
ORA-00904: "ENAME": invalid identifier
SQL> select * from test_emp where deptno = 10 --order by ename
2 union all
3 select * from test_emp where deptno = 20 --order by ename;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-81 3141 1 10
7782 CLARK MANAGER 7839 09-JUN-81 2700 10
7839 KING PRESIDENT 17-NOV-81 5512 10
7934 MILLER CLERK 7782 23-JAN-82 1433 10
7369 SMITH CLERK 7902 10-OCT-06 882 123 20
7566 JONES MANAGER 7839 10-OCT-06 3279 123 20
7788 SCOTT ANALYST 7566 11-OCT-06 3307 123 20
7876 ADAMS CLERK 7788 10-OCT-06 1212 123 20
7902 FORD ANALYST 7566 10-OCT-06 3307 123 20
9 rows selected.
SQL> select * from
2 (select * from test_emp where deptno = 10 union all
3 select * from test_emp where deptno = 20)
4 order by ename;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 10-OCT-06 1212 123 20
7698 BLAKE MANAGER 7839 01-MAY-81 3141 1 10
7782 CLARK MANAGER 7839 09-JUN-81 2700 10
7902 FORD ANALYST 7566 10-OCT-06 3307 123 20
7566 JONES MANAGER 7839 10-OCT-06 3279 123 20
7839 KING PRESIDENT 17-NOV-81 5512 10
7934 MILLER CLERK 7782 23-JAN-82 1433 10
7788 SCOTT ANALYST 7566 11-OCT-06 3307 123 20
7369 SMITH CLERK 7902 10-OCT-06 882 123 20
9 rows selected.
SQL> -
How to use order by within Group by clause
Hi All,
I need a help as to how should i use the Order by clause so that the data should be in order with respect to one column, and at the same time whole data is grouped by some other column...like
Select RaceNo,Venue,FP,BP from Race group by RaceNo
Here I want to order by FP in ascending order for each group. When i am using it , whole order is changing.
Can anybody suggest me how to use order by clause that would apply to each group of data.
Thanks .order by clause should be used at the last in any query.......but in group by clause u can't use use that becoz u group according to column then no ordering is needed there......if u want to filter something then u can use having clause and later if u need to arrange then u can use order by clause.........
i hope this eg.l gives u some clarification....
e.g
select deptno,count(empno)
from dept
group by deptno
having count(empno) > 10
order by deptno -
Without using order by and connect by clause
hi all,
can i write a tree query without using start with clause and connect by clause
and
can i order the employee names in a select query without using order by clause
can those things are possible in select statement...dipuna wrote:
hi all,
can i write a tree query without using start with clause and connect by clause
and
can i order the employee names in a select query without using order by clause
can those things are possible in select statement...A very odd question.
Those clauses are the means to do what you are asking. Why would you be looking for some other method? -
Is it possible to use LONG columns in WHERE clause or ORDER BY?
Is it possible to use LONG columns in WHERE clause or ORDER BY?
Hi,
LONG data type is deprecated, maybe could you change your column type to LOB ?
Nonetheless below is a workaround which may fit your needs if forced to use LONG.
It uses a function which returns you a CLOB. It allows you to use the converted "LONG" column in a WHERE clause.
Then if you want to order by you have to convert the CLOB to a VARCHAR using DBMS_LOB.SUBSTR.
SQL> CREATE TABLE my_table (id NUMBER, description LONG);
Table created.
SQL> INSERT INTO my_table VALUES (1, 'FIRST LONG');
1 row created.
SQL> INSERT INTO my_table VALUES (2, 'ANOTHER LONG');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> CREATE TYPE my_type_row AS OBJECT (id INTEGER, description CLOB);
2 /
Type created.
SQL> CREATE TYPE my_type_table AS TABLE OF my_type_row;
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION get_my_long
2 RETURN my_type_table
3 PIPELINED
4 AS
5 v_tab my_type_table := my_type_table ();
6 BEGIN
7 FOR cur IN (SELECT id, description FROM my_table)
8 LOOP
9 PIPE ROW (my_type_row (cur.id, cur.description));
10 END LOOP;
11 RETURN;
12 END;
13 /
Function created.
SQL> SELECT
2 id,
3 description
4 FROM
5 TABLE (get_my_long ())
6 WHERE
7 description LIKE '%LONG'
8 ORDER BY
9 DBMS_LOB.SUBSTR(description);
ID DESCRIPTION
2 ANOTHER LONG
1 FIRST LONG
SQL> SELECT
2 id,
3 description
4 FROM
5 TABLE (get_my_long ())
6 WHERE
7 description LIKE 'FI%';
ID DESCRIPTION
1 FIRST LONG
SQL>Kind regards,
Ludovic -
How to use "Order by" clause dynamically on LOV values in 10g r2 forms
Hi ,
I have following requirement,please guide me.
1 Create a List Of Values with 2 fields, Code and Description
2. Do not use order by clause in record Group Query
3. Attach this LOV to a field in Form
4. When user invokes the LOV user will see two fields in LOV with header as Code and Description
5. Now when user clicks on Column Header “Code” then LOV should be sorted on Code
6. And if User clicks on Column Header “Description” then LOV should be sorted on Description
Thanks in Advance.Kindly post this problem in this forum ->
[Forms Forum|http://forums.oracle.com/forums/forum.jspa?forumID=82]
And, close this thread by marked it as answered. ;)
Regards.
Satyaki De. -
With out using order by clause
display the details of the employees with sal in descending order, without using order by clause
Don't forget that it's just for fun :)Well it's not entirely for fun :-)
There are real life users who might have real production problems and the rely and input/feedback from this forum.
I do not :)You spread untested answers/knowledge that might be wrong.
I can't imagine where you can see cartesian. It's
equijoin by primary key.I suggest you test it.
JFUI hierarchy is built after joining. And this
hierarchy is bamboo-tree. So result must be sorted
acording hierarchy.I know what hierarchical ordering is :-)
And here's a little test i did on your behalf, on the EMP table :-)
select e1.*
from e e1,
( select e2.id, count(*) as rn from e e2, e e3
where e3.sal >= e2.sal
and e3.id >= e2.id
group by e2.id
) e4
where e1.id = e4.id
start with e4.rn = 1
connect by e4.rn = prior e4.rn + 1
SQL*Plus: Release 10.1.0.4.2 - Production on Wed Jul 25 16:02:19 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: scott/tiger
Connected to:
Oracle Database 10g Release 10.2.0.1.0 - Production
SCOTT@ORCL> set lines 1000
SCOTT@ORCL>
SCOTT@ORCL>
SCOTT@ORCL> select emp1.*
2 from emp emp1,
3 ( select emp2.empno, count(*) as rn from emp emp2, emp emp3
4 where emp3.sal >= emp2.sal
5 and emp3.empno >= emp2.empno
6 group by emp2.empno
7 ) emp4
8 where emp1.empno = emp4.empno
9 start with emp4.rn = 1
10 connect by emp4.rn = prior emp4.rn + 1;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-DEC-80 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7902 FORD ANALYST 7566 3000 20
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7934 MILLER CLERK 7782 1301 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
42 rows selected.
SCOTT@ORCL>Regards,
Tony -
How can i use Order by inside a sub query in Oracle
Hi!,
Please help me, it's an urgent... how can i use Order by clause
SELECT SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.dDate
, (SELECT nvl(S.Qty,0) FROM Stock S , DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.dDate <= DD.dDate and rownum=1
ORDER BY DD1.dDate DESC*) as StockQty
, (SELECT nvl(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.dDate > DD.dDate
AND DD2.dDATE=DD.dDate
) as TotalQtySold
FROM SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0;
kindly help
Thank you.Actually I'm converting Procedures from SQL Server to Oracle.
Actual Stored Procedure in SQL Server is as follows.
SELECT --top 10000
SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.Date
, (SELECT TOP 1 ISNULL(S.Qty,0) FROM dbo.Stock S , dbo.DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.Date <= DD.Date
ORDER BY DD1.Date DESC) as StockQty
, (SELECT ISNULL(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.Date > DD.Date
AND DD2.DATE=DD.Date
) as TotalQtySold
--INTO TEMP_Salesfact
FROM dbo.SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0 -
Use of Where and having clause
Hi all,
I always have a doubt about use of HAVING and WHERE clause,
suppose I have table T1 with only one column C1
CREATE TABLE T1
(C1 VARCHAR2(1) );
which having data by following INSERT scripts
INSERT INTO T1 VALUES('A');
INSERT INTO T1 VALUES('B');
INSERT INTO T1 VALUES('C');
INSERT INTO T1 VALUES('A');
INSERT INTO T1 VALUES('B');
INSERT INTO T1 VALUES('A');
Now I want result as follows
C1 ==== COUNT(C1)
==============
B ===== 2
A ===== 3
So out of query 1 and 2 which approach is right ?
1) SELECT C1,COUNT(C1) FROM T1
WHERE C1<>'C'
GROUP BY C1
ORDER BY C1 DESC;
2) SELECT C1,COUNT(C1) FROM T1
GROUP BY C1
HAVING C1<>'C'
ORDER BY C1 DESC;
Edited by: user13306874 on Jun 21, 2010 2:36 AMIn SQL, it's always best to filter data at the earliest moment possible.
In your example the WHERE clause would be that moment:
SQL> explain plan for
2 select c1,count(c1)
3 from t1
4 where c1 != 'C'
5 group by c1
6* order by c1 desc;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3946799371
| Id | Operation | Name | Rows | Bytes |
| 0 | SELECT STATEMENT | | 5 | 10 |
| 1 | SORT GROUP BY | | 5 | 10 |
|* 2 | TABLE ACCESS FULL| T1 | 5 | 10 |
Predicate Information (identified by operation id):
2 - filter("C1"!='C')
18 rows selected.
SQL>As you can see the filter is applied during the scan of T1.
Whereas in the HAVING case:
SQL> explain plan for
2 select c1,count(c1)
3 from t1
4 group by c1
5 having c1 != 'C'
6* order by c1 desc;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3146800528
| Id | Operation | Name | Rows | Bytes |
| 0 | SELECT STATEMENT | | 6 | 12 |
|* 1 | FILTER | | | |
| 2 | SORT GROUP BY | | 6 | 12 |
| 3 | TABLE ACCESS FULL| T1 | 6 | 12 |
Predicate Information (identified by operation id):
1 - filter("C1"!='C')
18 rows selected.
SQL>The scan is done after all groups have been computed: one of which was computed in vain, since it will be filtered away due to the HAVING clause.
In general I would use as a guideline: if you are not using aggregate functions in your HAVING clause predicate, then move that predicate to the WHERE portion of your query.
Edited by: Toon Koppelaars on Jun 21, 2010 11:54 AM -
Using ORDER BY in Oralce 7.3.x
Hi,
I need to create a view using ORDER BY cluase in Oralce 7.3.x.
(I guess ORDER BY Clause is not supported in Oracle 7.3).
Please Let me know any workaround for this.
Thanks in advance.
-GopiHave you tried a simple select statement using ORDER BY? ORDER BY is definitely supported in 7.3.
I haven't written a VIEW using ORDER BY, but what I remember most about VIEWS is that you have to use COLUMN ALIASES when referencing them in other statements. Maybe you need to assign column aliases and then peform the order by.... I don't know this for sure though.
PS views are slow enough as it is. Why not just select the data through the view, and then when you run queries off of the view, then perform the ORDER BY? -
Re: adding Union clause to existing seeded VO
Hi all,
we have a requirement to add union clause to existing VO which is standard one.. please help me if it is possible...
regards,
Raghava.Hi,
Following is the error stack for the code i wrote above....
we have a standard EO based VO and we need to add union clause to the VO query.. is there any approach to achieve this except extending VO?
The VO query is...
SELECT pca.COST_ALLOCATION_ID,
pca.EFFECTIVE_START_DATE,
pca.EFFECTIVE_END_DATE,
pca.BUSINESS_GROUP_ID,
pca.COST_ALLOCATION_KEYFLEX_ID,
pca.ASSIGNMENT_ID,
pca.PROPORTION as proportion,
pca.REQUEST_ID,
pca.PROGRAM_APPLICATION_ID,
pca.PROGRAM_ID,
pca.PROGRAM_UPDATE_DATE,
pca.LAST_UPDATE_DATE,
pca.LAST_UPDATED_BY,
pca.LAST_UPDATE_LOGIN,
pca.CREATED_BY,
pca.CREATION_DATE,
pca.OBJECT_VERSION_NUMBER,
pca.ROWID
FROM PAY_COST_ALLOCATIONS_F pca
WHERE to_date(:1,'YYYY-MM-DD') between effective_start_date and effective_end_date and :2 = assignment_id
The Union Clause needed is
and 1 = 2
union
(select cost_allocation_flex_id,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from test_table)
I tried it thru CO as below...
OAApplicationModule oa =(OAApplicationModule) oapagecontext.getApplicationModule(oawebbean);
OAViewObject vo = (OAViewObject)oa.findViewObject("CostingEntryDetailVO");
String whereclause ="COST_ALLOCATION_KEYFLEX_ID=6217) " +
" AND 1=2 " +
" union (( select cost_allocation_flex_id,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from test_table )";
if (vo!=null)
vo.setWhereClause(whereclause);
vo.executeQuery();
The error stack is:
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT pca.COST_ALLOCATION_ID,
pca.EFFECTIVE_START_DATE,
pca.EFFECTIVE_END_DATE,
pca.BUSINESS_GROUP_ID,
pca.COST_ALLOCATION_KEYFLEX_ID,
pca.ASSIGNMENT_ID,
pca.PROPORTION as proportion,
pca.REQUEST_ID,
pca.PROGRAM_APPLICATION_ID,
pca.PROGRAM_ID,
pca.PROGRAM_UPDATE_DATE,
pca.LAST_UPDATE_DATE,
pca.LAST_UPDATED_BY,
pca.LAST_UPDATE_LOGIN,
pca.CREATED_BY,
pca.CREATION_DATE,
pca.OBJECT_VERSION_NUMBER,
pca.ROWID
FROM PAY_COST_ALLOCATIONS_F pca
WHERE to_date(:1,'YYYY-MM-DD') between effective_start_date and effective_end_date and :2 = assignment_id) QRSLT WHERE (nullCOST_ALLOCATION_KEYFLEX_ID=6217 AND 1=2 union (( select cost_allocation_flex_id,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null from test_table )) ORDER BY effective_start_date
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:896)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:612)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1166)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2513)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1894)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:538)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:426)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)
## Detail 0 ##
java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1189)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:860)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:669)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3723)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4559)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:743)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:892)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:806)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:800)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3643)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(OAViewObjectImpl.java:439)
at genus.oracle.apps.pay.selfservice.assignmentcosting.webui.xxxAssignmentCostingEntryCO.processRequest(xxxAssignmentCostingEntryCO.java:80)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:596)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1166)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2513)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1894)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:538)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:426)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619)
java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1189)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:860)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:669)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3723)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4559)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:743)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:892)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:806)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:800)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3643)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(OAViewObjectImpl.java:439)
at genus.oracle.apps.pay.selfservice.assignmentcosting.webui.xxxAssignmentCostingEntryCO.processRequest(xxxAssignmentCostingEntryCO.java:80)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:596)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1166)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:964)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:931)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:655)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:251)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2513)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1894)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:538)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:426)
at OA.jspService(_OA.java:212)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:51)
at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:284)
at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:395)
at OA.jspService(_OA.java:221)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:379)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:313)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:199)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:619) -
Union clause cut off decimal places?
Dear all,
I am trying to create a query with "union" clause (to join 3 parts of records).
If I run them separately, I got the figures in Qty field (of Bill of Material) with 3 decimal places.
However, I only got 2 decimal places, when I combined the 3 sub-queries.
Any idea please?
Many thanks
Yang
Edited by: Y on Jul 10, 2009 4:16 PMDear all,
I just tried to create a view in the database for the "union" query, and I can see it is a 6 decimal numeric field from the SQL sever management studio, as all data are displayed fine.
Unfortunately, I queried this view in SAP query manager, and it is still showing only 2 decimals ...
I am very keen to know if there is a solution.
However, for now, I have let the view join the ITT1 table again in SAP to use the qantities figures.
It seems that SAP only shows 2 digit for numeric fields, unless it is getting data from a generic data table?
Cheers
Yang -
Help:Using Order by for a date column fetching wrong results
Hi all,
In my table I am having a date column which is having values
13/06/2007 09:24:00
31/05/2007 10:30:00
I am selecting this column with some other columns using order by at the end by giving the date column.
But I am getting rows in reverse order like above. I am using to_char(start_time,'dd/mm/yyyy hh:24mi:ss') in the select.
If I give to_date(start_time) in the order by the values are fetching correclty.But I was not allowed to use to_char in the select statement.
Kindly suggest me where it went wrong.
Thanks in advance.Hi , Thanks for the update. Actually that column was an Oracle DATE type. Earlier I gave simply that column name alone in the order by clause. That is getting falied only if the 2 entries falls in different months. Otherwise that is perfect.
So I gave to_date in the order by. But now I am facing a problem in the selecing that column.
Maybe you are looking for
-
How do I get music already on my laptop into my itunes account library? I have just done the icloud match thinking this would pick them all up, but it hasn't, all it has done is match the 40 songs I already have in my itunes library. I wanted to get
-
I think i know the answer but i've seen some searches that suggest it is possible and i can see PPro as a target in ExtendScript Can i script PPro CS6? Is there a scripting guide like there is for After Effects? If not, are there any known plans to a
-
I have three servers in a Citrix Farm, one of the servers BSOD's once or twice a week with the error PAGE_FAULT_IN_NONPAGED_AREA (50). When I analyze the dump file it always shows the faulting drive is lcencm.sys. This is Sophos Lan Crypt, which we
-
KM Document Iview not Displaying
Hi Experts, I have created KM Document iview and when i preview, its working but when i assign it to Role and check it with Users or Admin am getting error page cannot be displayed. Please let me know what i have missed, I have checked Entry Point fo
-
I am unable to update my new credit card on my payment details???
Hi there, I got a notification my credit card epxired and therefore this has stopped my CC payment. I am getting an error message when I try to upload my new card? It wont work. Any advice?