Query Builder - sort order causing ORA-00979 error
Hello,
I'm having an issue with the "sort order" clause in the query builder tool when using a function on the same column.
I've build a simple query in the gui and the following statement is displayed in the SQL Window
select "DEMO_ORDER_ITEMS"."ORDER_ID" as "ORDER_ID",
sum(DEMO_ORDER_ITEMS.QUANTITY) as "QUANTITY"
from "DEMO_ORDER_ITEMS" "DEMO_ORDER_ITEMS"
group by DEMO_ORDER_ITEMS.ORDER_ID
and if I add a sort order of "1" on the quantity field, the following query is changed to
select "DEMO_ORDER_ITEMS"."ORDER_ID" as "ORDER_ID",
sum(DEMO_ORDER_ITEMS.QUANTITY) as "QUANTITY"
from "DEMO_ORDER_ITEMS" "DEMO_ORDER_ITEMS"
group by DEMO_ORDER_ITEMS.ORDER_ID
order by DEMO_ORDER_ITEMS.QUANTITY DESC
When running this query I get an error
failed to parse SQL query:
ORA-00979: not a GROUP BY expression
It is quite obvious what is wrong with the query but I don't know how to get the query builder tool to generate the correct statement. The order by clause should be order by sum(DEMO_ORDER_ITEMS.QUANTITY) DESC.
I've tried to do some searching and haven't found much documentation on this issue. Any assistance is appreciated.
Thanks,
Tony
While this statement is generally certainly true and should also be remembered, it is not really helpful for the specific case.
I think the behaviour described is a bug. However this might be one a little difficult to solve. The user unfortunatly can't influence much of the query builder results directly.
Either put 1 into the order by clause or use the column alias name without table alias name ("QUANTITY" only).
My personal solution would be NOT TO use any sort criteia in the query builder. This makes sense in so far as the generated SQL is often basis for some report. If that is an interactive report you won't add a sort order anyway. This is a layout thing and layout will be handled by the end user itself. he can choose whatever sorting he wants.
Edited by: Sven W. on Jul 22, 2009 11:43 AM
Similar Messages
-
Does RULE hint cause ORA-01555 errors ?
DB Version:9.2.0.5.0
OS:SunOS 5.9
Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errors
SELECT /*+ RULE */ COUNT(*)
FROM ( SELECT /*+ RULE */ DISTINCT CAR_HDR.CAR_NBR AS A1, CAR_HDR.PLT_ID AS A29,
CAR_HDR.PKT_CTRL_NBR AS A2, CAR_HDR.TOTAL_QTY AS A21, CAR_HDR.STAT_CODE AS A6,
CAR_HDR.CURR_LOCN_ID AS A12,
CAR_HDR.CAR_NBR AS A145,
CAR_HDR.WN_NBR AS A4, CAR_HDR.PCALL_NBR AS A7, CAR_HDR.CHAIN_CNT AS A119,
CAR_HDR.SHPMT_NBR AS A35, LPN_HDR.WHSE AS A105, CAR_HDR.MISC_CAR AS A146, '' AS A138,
CAR_HDR.CHUTE_ID AS A132, CAR_HDR.MOD_DATE_TIME AS A82, LPN_HDR.LOCN_CLASS AS A106,
LPN_HDR.AREA AS A107, LPN_HDR.ZONE AS A108, LPN_HDR.AISLE AS A109, LPN_HDR.BAY AS A110,
LPN_HDR.LVL AS A111, LPN_HDR.POSN AS A112
FROM INV_MASTER , CAR_DTL , LPN_HDR , CAR_HDR
WHERE CAR_HDR.CAR_NBR=CAR_DTL.CAR_NBR(+)
AND CAR_HDR.CURR_LOCN_ID=LPN_HDR.LOCN_ID(+)
AND CAR_HDR.WHSE=LPN_HDR.WHSE(+)
AND CAR_DTL.SKU_ID=INV_MASTER.SKU_ID(+)
AND CAR_HDR.CT_SEQ = 'ALB10'
AND INV_MASTER.INV_CODE = 98
AND INV_MASTER.TRACK_CODE = 'P10' )
user636669 wrote:
DB Version:9.2.0.5.0
OS:SunOS 5.9
Our DBA is saying that the RULE hint in the below SQL might be causing ORA-01555 error. Is it true? Does RULE hint cause ORA-01555 errorsThe full statement is causing the ORA-01555 error. Each line of the statement is important therefore each line is reponsible for the error. I personally think the DISTINCT keyword has a bigger influence than the RULE hint.
I suggest to check what you want to do with that count result. maybe there are better ways to get the same result. Maybe you can even ignore the distinct keyword or remove some outer joins. Using the CBO might result in the same plan as using the RBO, so you you will never know if that removing the hint will help or if if you'll get the same problem later again. -
Query Builder - Where Clause - Could not format error using date comparison
We've come across a bug in the Query Builder, under the Create Where Clause tab, if you select a column of Date type plus one of the comparison operators =, !=, <, >, <=, >=, BETWEEN or NOT BETWEEN it displays an error in the Logging Page:
Level: Severe
Source: o.d.r.queryBuilder.SQLGenerator
Message: Could not format :2010-09-02 16:20:31.0
Then under the Show SQL tab it doesn't display the date(s) you selected, e.g.
WHERE LAST_UPDATE BETWEEN AND
Also the View Results tab does not display any results.
You can still press Apply to add the SQL as is to the editor window and from there you have to manually code in the date parameters.
We're using the latest version of SQL Developer 2.1.1.64.45 Windows 32bit version with JDKHi Gordon,
When I add the following lines:
declare @refdt1 date
set @refdt =
/*select 1 from jdt1 t0 where t0.RefDate*/ '[%1]'
declare @refdt2 date
set @refdt =
/*select 1 from jdt2 t0 where t0.RefDate*/ '[%2]'
WHERE T0.RefDate >= @refdt1 and T0.RefDate <= @refdt2
... the error message is now:
Must declare the scalar variable @refdt1
Note: Before adding these lines, the query works perfectly, and returns totals from the whole database (with dynamically generated column headings!)
Thanks
Leon Lai
AMENDED QUERY:
declare @refdt1 date
set @refdt1 =
/*select 1 from jdt1 t0 where t0.RefDate*/ '[%1]'
declare @refdt2 date
set @refdt2 =
/*select 1 from jdt1 t0 where t0.RefDate*/ '[%2]'
--------- I inserted the 6 lines above ---------------------
DECLARE @listCol VARCHAR(2000)
DECLARE @query VARCHAR(4000)
SELECT @listCol =
STUFF
( SELECT DISTINCT '],[' + CAST(month(T0.RefDate) AS varchar)
FROM JDT1 T0
FOR XML PATH('')
), 1, 2, ' ') + ']'
SET @query =
'SELECT * FROM
(SELECT Account, month (T0.RefDate) Month , Debit
FROM JDT1 T0
------------------- I add the WHERE clause below --------------------
WHERE T0.RefDate >= @refdt1 and T0.RefDate <= @refdt2
GROUP BY Account, RefDate, Debit
) S
PIVOT
Sum(Debit)
FOR Month IN ('+@listCol+')
) AS pvt'
EXECUTE (@query)
Edited by: LEONLAI on Oct 21, 2011 2:36 PM -
Unable to deploy a mapping causing ORA, PLS error
I have a simple mapping, sourec is a table and target is flat file. I have a transformation expression and my expression is as follows :
ORA-06550: line 799, column 7:
PLS-00103: Encountered the symbol "|" when expecting one of the following:
INGRP1.COMPANY_ID ||','||
INGRP1.ADSI_AGENT_ID ||','||
INGRP1.DISTRIBUTION_CHANNEL ||','||
INGRP1.PRODUCT_CODE ||','||
INGRP1.CONTRACT_ID ||','||
INGRP1.EVENT_ID ||','||
INGRP1.COMM_EVENT_CODE ||','||
TO_CHAR(INGRP1.PRICE_DATE,'MM/DD/RRRR') ||','||
TO_CHAR(INGRP1.CYCLE_DATE,'MM/DD/RRRR') ||','||
TO_CHAR(INGRP1.COMM_AMOUNT,'999,999,999.99')||','||
TO_CHAR(INGRP1.COMM_RATE,'99.9999')||','||
SUBSTR(INGRP1.EVENT_DESC,1,10) ||','||
TO_CHAR(INGRP1.STATEMENT_DATE ,'MM/DD/RRRR')||','||
DECODE(INGRP1.NSCC_IND,'Y','Yes','N','No')
When I deploy this mapping, I am getting foloowing error:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
If I take out the DECODE function from the Expression builder and then deploy , it works OK. Coudl anyone sugegst me what is the problem here.
Thanks
SuhailSuhail,
Just thought about something else that is not ideal, but should work: use the decode as a standalone operation in one attribute, and in the next expression, concatenate the result of two previous expression attributes. This should work also (but I know it is not ideal).
Thanks,
Mark. -
Urgent help please. Inner Join caused ora-00933 error
I ran this one , works fine:
SELECT DISTINCT EXP.EXP_ID,
EXP.DATU_EXP_WIRE_CENTER_CLLI,
EXP.DATU_EXP_IP,
EXP.DATU_EXP_CLLI,
EXP.DATU_EXP_PORT,
EXP.DATU_EXP_NAME,
EXP.DATU_EXP_CITY,
EXP.DATU_EXP_STATE,
EXP.DATU_EXP_SW_VERSION,
DECODE(LAST_ALARM.LAST_ALARM_DATE, NULL, TO_CHAR(SYSDATE,'YYYY/MM/DD HH24:MI:SS'),
TO_CHAR(LAST_ALARM.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS STATUS_DATE,
DECODE(LAST_ALARM.ALARM_NAME, NULL, 'Disconnected', LAST_ALARM.ALARM_NAME) AS DATU_STATUS,
DECODE(LAST_ALARM.ALARM_CLASS, NULL, 'OTHER', LAST_ALARM.ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE(LAST_RESOURCE.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_RESOURCE.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS RESOURCE_STATUS_DATE,
DECODE(LAST_RESOURCE.RESOURCE_CODE_NAME, NULL, '', LAST_RESOURCE.RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE(LAST_RESOURCE.RESOURCE_CODE_CLASS, NULL, '', LAST_RESOURCE.RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE(LAST_OPER.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_OPER.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS OPER_STATUS_DATE,
DECODE(LAST_OPER.OPER_CODE_NAME, NULL, '', LAST_OPER.OPER_CODE_NAME) AS OPER_STATUS,
DECODE(LAST_OPER.OPER_CODE_CLASS, NULL, '', LAST_OPER.OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP.BEGIN_MAINT_WINDOW, RTU.RTU_NAME
FROM TT_DATU_EXP_UNIT_INFO EXP
left outer join
( SELECT distinct alarmed_datus.EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS, alarmed_datus.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID ) alarmed_datus
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus.EXP_ID AND b.ALARM_TIME = alarmed_datus.LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE
) LAST_ALARM on EXP.EXP_ID = LAST_ALARM.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE
) LAST_RESOURCE on EXP.EXP_ID = LAST_RESOURCE.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(OPER_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE) LAST_OPER on EXP.EXP_ID = LAST_OPER.EXP_ID
inner join TT_DATU_LRN_MAP LRNS on EXP.EXP_ID = LRNS.EXP_ID AND TRIM(LRNS.LRN) LIKE p_LRN
inner join TT_RTU_TYPES RTU ON EXP.RTU_TYPE_ID = RTU.RTU_TYPE_ID
WHERE NOT EXISTS (SELECT SATELLITE_EXP_ID FROM TT_HOST_SATELLITE WHERE EXP.EXP_ID = SATELLITE_EXP_ID)
AND EXP.IS_PRIMARY_ADDRESS LIKE p_isPrimary;
ELSE
OPEN v_cursor FOR
SELECT EXP.EXP_ID,
EXP.DATU_EXP_WIRE_CENTER_CLLI,
EXP.DATU_EXP_IP,
EXP.DATU_EXP_CLLI,
EXP.DATU_EXP_PORT,
EXP.DATU_EXP_NAME,
EXP.DATU_EXP_CITY,
EXP.DATU_EXP_STATE,
EXP.DATU_EXP_SW_VERSION,
DECODE(LAST_ALARM.LAST_ALARM_DATE, NULL, TO_CHAR(SYSDATE,'YYYY/MM/DD HH24:MI:SS'), TO_CHAR(LAST_ALARM.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS STATUS_DATE,
DECODE(LAST_ALARM.ALARM_NAME, NULL, 'Disconnected', LAST_ALARM.ALARM_NAME) AS DATU_STATUS,
DECODE(LAST_ALARM.ALARM_CLASS, NULL, 'OTHER', LAST_ALARM.ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE(LAST_RESOURCE.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_RESOURCE.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS RESOURCE_STATUS_DATE,
DECODE(LAST_RESOURCE.RESOURCE_CODE_NAME, NULL, '', LAST_RESOURCE.RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE(LAST_RESOURCE.RESOURCE_CODE_CLASS, NULL, '', LAST_RESOURCE.RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE(LAST_OPER.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_OPER.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS OPER_STATUS_DATE,
DECODE(LAST_OPER.OPER_CODE_NAME, NULL, '', LAST_OPER.OPER_CODE_NAME) AS OPER_STATUS,
DECODE(LAST_OPER.OPER_CODE_CLASS, NULL, '', LAST_OPER.OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP.BEGIN_MAINT_WINDOW, RTU.RTU_NAME
FROM TT_DATU_EXP_UNIT_INFO EXP
left outer join (
SELECT distinct alarmed_datus.EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS, alarmed_datus.LAST_ALARM_DATE
FROM (SELECT EXP_ID, MAX(ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID ) alarmed_datus
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus.EXP_ID AND b.ALARM_TIME = alarmed_datus.LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE )
LAST_ALARM on EXP.EXP_ID = LAST_ALARM.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.EXP_ID = LAST_RESOURCE.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(OPER_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.EXP_ID = LAST_OPER.EXP_ID ORDER BY EXP.DATU_EXP_CLLI
inner join TT_RTU_TYPES RTU ON EXP.RTU_TYPE_ID = RTU.RTU_TYPE_ID
WHERE NOT EXISTS (SELECT SATELLITE_EXP_ID FROM TT_HOST_SATELLITE WHERE EXP.EXP_ID = SATELLITE_EXP_ID) AND EXP.IS_PRIMARY_ADDRESS like
p_isPrimary;
However this one:
SELECT EXP.EXP_ID,
EXP.DATU_EXP_WIRE_CENTER_CLLI,
EXP.DATU_EXP_IP,
EXP.DATU_EXP_CLLI,
EXP.DATU_EXP_PORT,
EXP.DATU_EXP_NAME,
EXP.DATU_EXP_CITY,
EXP.DATU_EXP_STATE,
EXP.DATU_EXP_SW_VERSION,
DECODE(LAST_ALARM.LAST_ALARM_DATE, NULL, TO_CHAR(SYSDATE,'YYYY/MM/DD HH24:MI:SS'),
TO_CHAR(LAST_ALARM.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS STATUS_DATE,
DECODE(LAST_ALARM.ALARM_NAME, NULL, 'Disconnected', LAST_ALARM.ALARM_NAME) AS DATU_STATUS,
DECODE(LAST_ALARM.ALARM_CLASS, NULL, 'OTHER', LAST_ALARM.ALARM_CLASS) AS IS_ERROR_STATUS,
DECODE(LAST_RESOURCE.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_RESOURCE.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS RESOURCE_STATUS_DATE,
DECODE(LAST_RESOURCE.RESOURCE_CODE_NAME, NULL, '', LAST_RESOURCE.RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
DECODE(LAST_RESOURCE.RESOURCE_CODE_CLASS, NULL, '', LAST_RESOURCE.RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
DECODE(LAST_OPER.LAST_ALARM_DATE, NULL, '', TO_CHAR(LAST_OPER.LAST_ALARM_DATE,'YYYY/MM/DD HH24:MI:SS')) AS OPER_STATUS_DATE,
DECODE(LAST_OPER.OPER_CODE_NAME, NULL, '', LAST_OPER.OPER_CODE_NAME) AS OPER_STATUS,
DECODE(LAST_OPER.OPER_CODE_CLASS, NULL, '', LAST_OPER.OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,
EXP.BEGIN_MAINT_WINDOW, RTU.RTU_NAME
FROM TT_DATU_EXP_UNIT_INFO EXP
left outer join
SELECT distinct alarmed_datus.EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS, alarmed_datus.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID) alarmed_datus
inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus.EXP_ID AND b.ALARM_TIME = alarmed_datus.LAST_ALARM_DATE
inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE ) LAST_ALARM on EXP.EXP_ID = LAST_ALARM.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.EXP_ID = LAST_RESOURCE.EXP_ID
left outer join
( SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
FROM ( SELECT EXP_ID, MAX(OPER_CODE_TIME) AS LAST_ALARM_DATE
FROM TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID ) a
inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.EXP_ID = LAST_OPER.EXP_ID ORDER BY EXP.DATU_EXP_CLLI
inner join TT_RTU_TYPES RTU ON EXP.RTU_TYPE_ID = RTU.RTU_TYPE_ID
WHERE EXP.IS_PRIMARY_ADDRESS like p_isPrimary;
this one not work kept giving me errors:
[ ORA-00933: SQL command not properly ended
Any guru can help? I need to have this resolved end of today.
Thanks in advance.Hi,
Never write, let alone post, unformatted code.
Indent the code so that it's easy to set the scope of sub-queries, and the majoc clauses (SELECT, FROM, WHERE, ORDER BY, ...) in each.
When posting any formatted text on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
If you do that to the code you posted, you'll see that it ends like this:... inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID
AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.EXP_ID = LAST_OPER.EXP_ID
ORDER BY EXP.DATU_EXP_CLLI
inner join TT_RTU_TYPES RTU ON EXP.RTU_TYPE_ID = RTU.RTU_TYPE_ID
WHERE EXP.IS_PRIMARY_ADDRESS like p_isPrimary
You can't put an ORDER BY clause in the middle of the FROM clause.
The ORDER BY clause always goes after the WHERE clause, like this:... inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID
AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
) LAST_OPER on EXP.EXP_ID = LAST_OPER.EXP_ID
inner join TT_RTU_TYPES RTU ON EXP.RTU_TYPE_ID = RTU.RTU_TYPE_ID
WHERE EXP.IS_PRIMARY_ADDRESS like p_isPrimary
ORDER BY EXP.DATU_EXP_CLLI -
Creating a view using With causes ORA-00600 Error
Hello Ladies and Gents,
I've been trying to deploy a recursive query as a view in Oracle XE and Standard Edition, neither to much success.
The query is located in this question here: http://stackoverflow.com/questions/17358109/how-to-retrieve-all-recursive-children-of-parent-row-in-oracle-sq
with recursion_view(base, parent_id, child_id, qty) as (
-- first step, get rows to start with
select
parent_id base,
parent_id,
child_id,
qty
from
md_boms
union all
-- subsequent steps
select
-- retain base value from previous level
previous_level.base,
-- get information from current level
current_level.parent_id,
current_level.child_id,
-- accumulate sum
(previous_level.qty + current_level.qty) as qty
from
recursion_view previous_level,
md_boms current_level
where
current_level.parent_id = previous_level.child_id
select
base, parent_id, child_id, qty
from
recursion_view
order by
base, parent_id, child_id
The query itself works and returns results. However, when I try to create a view with that query, I receive errors.
I've posted two screenshots: http://www.williverstravels.com/JDev/Forums/StackOverflow/17358109/ViewError.jpg and http://www.williverstravels.com/JDev/Forums/StackOverflow/17358109/InternalError.jpg The first one with the ! and * is when I am using JDeveloper 11g, using the Database Navigator, right-click on View and select "New View". I receive the error when I click OK. I can indeed create the view through a sql script, but when I attempt to view the data, I receive the ORA_00600 error.
I've tried this on both my local machine for XE (version 11.2.0.2.0) and on 11g Standard Edition (11.2.0.2.v6) via Amazon Web Services. The result is the same.
Does anyone know how to get around this?Not 5 minutes after I post this, I decide not to use JDev's graphical editor, and simply write
SELECT * FROM BOMS_VIEW;
And it works like a charm. I just can't use data tab to view the records in the editor. Wish I had known that 5 hours ago. -
Query to find SQL_ID of statement which causes ORA-1555
Could you please sent a query to find which SQL_ID/sql stament causes ORA-1555 error.
HariLook in an AWR report spanning the time frame when it occurred. Number of executions may be blank but the elapsed time will be high.
You can also find part of the statement and then trace it back.
http://asktom.oracle.com/pls/asktom/f?p=100:11:1480055079538858::::P11_QUESTION_ID:40115659055475 -
Parsing Error when using query builder
I have a query with a subquery in the WHERE statement witn multiple fields listed in the select statement.
For example, the subquery starts with "AND (center, jobid) IN SELECT center, jobid FROM ........
The query runs fine and gives me the correct data
However when I click on the Query builder option, I receive the following error
"Text is not a valid, single SELECT statement.
Parsing error:
Failed to parse SQL query.
Invalid Select Statement.
Unexpected token "from" at line13, pos 1.
Query Builder Disabled
I believe this to be a problem with the query builder, Am I correct?Query Builder is a visual environment targeted at novice/intermediate users. Some advanced and/or hard to visualize language features are not supported. The improved error messaging coming in 3.1 would indicate this is 'unsupported' rather than 'not a valid, single SELECT statement.' For example, (using scott/tiger):
Text contains unsupported syntax.
Parsing error:
Failed to parse SQL query.
Invalid SELECT statement.
Unexpected token "," at line 4, pos 16.
Query Builder disabled.
select distinct d.dname
from dept d, emp e
where d.deptno = e.deptno
and (e.deptno, e.job) in
(select x.deptno, x.job
from emp x
where x.deptno > 10
and x.job NOT IN ('MANAGER', 'PRESIDENT')
I don't know what your real query is, but refactoring to use join on derived table or table expression (or, as Gary said, separate IN clauses) rather than '(a, b) IN' will allow Query Builder to display it.
derived table: select distinct d.dname
from dept d, emp e,
(select x.deptno, x.job
from emp x
where x.deptno > 10
and x.job NOT IN ('MANAGER', 'PRESIDENT')
) filter
where d.deptno = e.deptno
and e.deptno = filter.deptno
and e.job = filter.job
table expression: with filter as (select x.deptno, x.job
from emp x
where x.deptno > 10
and x.job NOT IN ('MANAGER', 'PRESIDENT')
select distinct d.dname
from dept d, emp e, filter
where d.deptno = e.deptno
and e.deptno = filter.deptno
and e.job = filter.jobBrian Jeffries
SQL Developer Team -
I am trying to create a new test report in BI Publisher.
When I was testing the connection in Admin/JDBC panel. It says Connection established Successfully. But When I try to open a query Builder , It throws me the following error.
"Could not load schema information. Please make sure that this connection is active."
Any thoughts ?
p.s I am behind proxy. (Changed oc4j.cmd already).
Thanks in Advance.Dear All:
Well, I hope the solution below could solve your problem.
1. Goto the Admin tab from your Oracle BI Publisher Enterprise.
2. Goto the JDBC Connection, there you'll find some of your JDBC predefined connections.
3. Click on the Data Source where you find these error.
4. Replace the jdbc:oracle:thin:@HOST:PORT:SID with HOST, PORT, and SID (e.g. jdbc:oracle:thin:@localhost:1521:ORCL).
5. Enter username and password from the schema (e.g. u:HR p:HR for HR Schema).
6. Test the connection, make sure that it is successfully connected. Otherwise you should check the connection detail.
7. Done. Back to your query builder.
Regards,
Adrian -
Sort order of results in UOW Conformed Query ??
We would like to know what is the expected behavior when a query with ascending ordering or descending ordering is run with UOW conformed.
We know for sure that SQL generated and submit to the database with ORDER BY CLAUSES (which get the data in the database and sorted properly)
However, with a confirm query, the database result will in turn, combine selected objects in the UNIT OF WORK.
Will the combined collection of object be sorted in the prescribed ordering ?
For example:
If in UOW we have some uncommitted CAT object CAT-9, and CAT- 5
In Database we return CAT-1, CAT-3, CAT-7 sorted in ascending order
Will toplink return after the UOW conformed query, a collection in the following order ?
CAT-1, CAT-3, CAT-5, CAT-7, CAT-9 ???
Please advice.
Thank you in advance.No, any new objects that conform to the query will be added to the end of the result set, so may not match the query's sort order.
If you need the conformed results to maintain ordering you can either,
- Sort the results in-memory after executing the query through Collections.sort(List).
- Use a TreeSet as the query resultCollectionClass to sort the query results. -
ORA - 600 error while granting privs
Whenever I fire the below query it returns me a ORA-600 error.
Query
select grantee UserName, granted_role Role from dba_role_privs
where grantee in (select grantee from dba_role_privs
where granted_role = 'DBA')
and grantee in (select username from dba_users
where (username not like '%SYS%' and username not in('BWUSER','ORADMIN')))
order by grantee, granted_role;
ERROR
and grantee in (select username from dba_users
ERROR at line 4:
ORA-00600: internal error code, arguments: [qernsRowP], [1], [], [], [], [],
Please help in optimisizng the query
JafarI am using sqlplus to connect to oracle.
Oh! Query works fine for me after slight adjustment but i dont how?
I made a sligth adjustment
Old query
select grantee UserName, granted_role Role from dba_role_privs
where grantee in (select grantee from dba_role_privs
where granted_role = 'DBA')
and grantee in (select username from dba_users
where (username not like '%SYS%' and username not in('BWUSER','ORADMIN')))
order by grantee, granted_role;
New Query
select grantee UserName, granted_role Role from dba_role_privs
where grantee in (select grantee from dba_role_privs
where granted_role = 'DBA'
and grantee in (select username from dba_users
where (username not like '%SYS%' and username not in('BWUSER','ORADMIN')))
order by grantee, granted_role;
Please look at the bold words, and anyone tell me what was the major difference between the two query for succesful execution.
Thanks'
Jafar -
Query builder bug in outer joins ?
I understood that if you were joining two tables A and B, the following was a
LEFT OUTER JOIN
SELECT A.COL, B.COL
FROM A, B
WHERE A.ID = B.ID (+)
ie: a LEFT outer join has the (+) on the Right-hand table.
However, query builder puts the (+) on the Left-hand table.
Same for a RIGHT outer join - I think the (+) should be on the Left-hand table, but query builder puts it on the Right-hand table.
Cheers,
Andrew
(running Version 2.1.0.00.39)Hi Andrew,
I just played a little with the query builder and created a join between two of my tables:
PROJECTS and ACTIVITIES, linked via KCC.
When I create a left outer join in query builder, I get the following result:
select "PROJECTS"."KCC" as "KCC"
from "ACTIVITIES" "ACTIVITIES",
"PROJECTS" "PROJECTS"
where "PROJECTS"."KCC"(+) ="ACTIVITIES"."KCC"
Which is correct: Left refers to the first table in the from clause (ACTIVITIES) and places the (+) on the other table!
Left and right refers to the order of tables in the from clause, not in the where clause. Query builder sorts the tables in FROM alphabetically, maybe this is differing from the graphical order in query builder.
Regards
Alex -
ORA-03115 error when calling a Stored Procedure
Hi All,
I'm in the process of porting a Pro/C app from NT to Linux. I've installed 8.1.5 on our Linux box and patched it up to 8.1.5.02.
It all kind of works ok, except that I'm sometimes getting ORA-03115 errors when the app calls a stored procedure. The call in question looks like this:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR resprows[50][3998];
int numret = 0;
int numrows= 50;
int done= 0;
unsigned long resp_id = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL AT DB_NAME EXECUTE
BEGIN pkg_something.getdata(
:resp_id, /* IN */
:numrows, /* IN */
:done, /* OUT */
:resprows, /* OUT */
:numret /* OUT */
END;
END-EXEC;
The stored procedure basically uses the resp_id value to select rows from a table;
in each row there is a VARCHAR2(4000) column which it copies into the hostarray resprows.
There may be anything from 1 to numrows returned from the SP.
Initially, the resprows rows were defined to be size [4000]. Unfortunately, this caused ORA-02005 errors - I then changed the size to [3998], which seemed to fix the 02005's (although I'm unclear as to the reasons why).
Now I'm getting the 03115 errors when calling the SP. The oracle manual is not very helpful on what this error means.
This all works chipper on NT.
Any ideas?
Thanks in advance,
Nigel.
PS: The database the app is talking to is still hosted on NT.
nullHiston FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM -
Cannot use Query Builder in TableAdapter Configuration Wizard
I am using Visual Studio 2013 and MySQL NET adapter 6.8.3. I have created a WinForms app in VB. I am trying to create a dataset with a table from the MySQL database (named "propworx"). I do the following:
1. I create a new DataSet.
2. I edit the DataSet with the DataSet Designer.
3. I right-click on ANY TableAdapter, and I click "Configure".
4. I click on "Query Builder".
I get the following error message:
The query builder has failed.
Authentication to host '' for user '' using method 'mysql_native_password' failed with message: Access denied for user
''@'Fabs-Work' (using password: NO)
(In the above, "Fabs-Work" is my computer name.)
Looking at the error message, I immediately see that the host and user information appears to be missing. But it is in my app.config file:
<connectionStrings>
<add name="PropWorx.My.MySettings.PropWorxConnectionString" connectionString="server=localhost;user id=propworx;password=********;persistsecurityinfo=True;database=propworx" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
(I have blanked out the password in the above post, but I have indeed double checked it and it is correct).
The database is hosted locally. I have created a database user in MySQL called "propworx" and have given it full rights.
Any ideas why Visual Studio Dataset Designer is not reading the info from my settings file?
Fabricio Rodriguez - Pretoria, South AfricaHi Fabs,
According to your description, this issue is related to MYSQL. I am afraid this is out of our support. I would suggest that you could ask this issue in their official forum. Here is the link,
http://forums.mysql.com/
Thanks for your understanding.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
GROUP BY with parameter - cause error -ORA-00979: not a GROUP BY expression
I generate a query via PreparedStatement. For example:
SELECT when, value FROM test GROUP BY ?;
PrepState.toString(1, "when");
That causing error: ORA-00979: not a GROUP BY expression
My application using query like:
SELECT to_char(data,1), SUM(vlue) as sum FROM test GROUP BY to_char(data, 2);
PrepState.toString(1, "YYYY-MM");
PrepState.toString(2, "YYYY-MM");Ah. Reproduced in the first chunk of PL/SQL below.
The second chunk is a workaround.
Basically, SQL is parsed by the syntax engine and optimizer to get an execution plan. Then you can have a sequence of "bind, execute, fetch, fetch, fetch..., bind, execute..."
Since you can have multiple binds for a single SQL parse, then the fact that the first set of binds all happen to have the same value doesn't mean the next set will.
The optimizer needs to be 100% sure that the value in the select must always be the same as the value in the group by, so you can't have two separate (and therefore potentially different) bind variable mappings. [Given the right circumstances, the optimizer might do all sorts of tricks, such as using materialized views and function-based indexes.]
Misleadingly, it actually fails on the 'EXECUTE' step of DBMS_SQL rather than the PARSE.
declare
v_sql varchar2(1000) :=
'select to_char(created,:b1), count(*) '||
' from user_objects u '||
' group by to_char(created,:b2) '||
' order by to_char(created,:b3)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
dbms_sql.bind_variable( v_cur, ':b2', v_fmt );
dbms_sql.bind_variable( v_cur, ':b3', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
declare
v_sql varchar2(1000) :=
'select to_char(created,f.fmt), count(*) '||
' from user_objects u, (select :b1 fmt from dual) f '||
' group by to_char(created,f.fmt) '||
' order by to_char(created,f.fmt)';
v_fmt varchar2(10) := 'YYYY';
v_cur number;
v_ret_str varchar2(10);
v_ret_num number;
v_ret number;
begin
v_cur := dbms_sql.open_cursor;
dbms_sql.parse(v_cur, v_sql, dbms_sql.native );
dbms_sql.define_column_char (v_cur, 1, v_ret_str, 10);
dbms_sql.define_column (v_cur, 2, v_ret_num);
dbms_sql.bind_variable( v_cur, ':b1', v_fmt );
v_ret := dbms_sql.execute( v_cur );
WHILE ( dbms_sql.fetch_rows(v_cur) > 0 ) LOOP
dbms_sql.column_value_char (v_cur, 1, v_ret_str );
dbms_sql.column_value (v_cur, 2, v_ret_num );
dbms_output.put_line('>'||v_ret_str||':'||v_ret_num);
END LOOP;
end;
/
Maybe you are looking for
-
Performance issue with Business Objects Java JRC API in CRXI R2 version
A report is developed using java JRC API in CR XI release 2. When I generate the report in the designer, it took less than 5 seconds to display the results in crystal report viewer inside the designer. But in the QA environment, when I generate the s
-
Group Policy Infrastructure Failed : The target name is incorrect
Hi, I am currently facing issues regarding Group Policy, users are unable to change the password. When i run gpupdate /force on servers, the user policy and computer policy are successful but when i run the same on any client i receive error as per b
-
Macbook Pro to Projector issue. Please help.
Hey now. I have been watching tv via a projector using my macbooks for years now. Today all of a sudden it doesn't work anymore. I don't know if it has to do with an apple update I downloaded. Curiously, I can see my computer's wallpaper through the
-
Did CUP risk analysis change with SP7?
Dear GRC experts, I am pretty sure when we tested CUP 5.3 SP4 when doing risk analysis it would only show new risks caused by new roles selected in request (like Risks from Simulation Only YES in RAR). Exisitng risks for that user would not be shown.
-
Power2Go goes thru all the motions to burn a CD and/or DVD and indicates process completed. Disc is BLANK upon ejection Log reads : Error Code : 0xe0080007 more info in error log if needed