PIVOT query throwing error
I have a request pivot within a region of APEX (pl sql function return sql query) report
declare v_term_pivot varchar2(500); PIVIN LONG; cursor xtoy is SELECT distinct d.JOB FROM emp d; v_query LONG; begin OPEN xtoy; LOOP FETCH xtoy into v_term_pivot; EXIT when xtoy%NOTFOUND; PIVIN:=PIVIN||''''||v_term_pivot||''' "'||substr(v_term_pivot,1,30)||'", '; END LOOP; v_query:='SELECT * FROM (SELECT x.ENAME, x.JOB, x.SAL FROM emp x) PIVOT ( SUM(x.SAL) FOR x.JOB IN ('||substr(PIVIN, 0, length(PIVIN)-1)||') ) order by 1;'; --dbms_output.put_line(v_query); RETURN v_query; end;
Get an error:
Failed to parse the SQL query:
ORA-01748: only here allowed simple column names
Can someone advice how can this be corrected?
I reworked the code to use the scott. EMP table.
I got the SQL Select function resulting and he ran in SQL Developer.
Syntax 1
You must remove aliases for tables of the PIVOT() section.
line 16 and 17 should be
SUM (SAL)
FOR USE IN (...)
Syntax 2
Line 11: you add comma and space (2 characters)
Line 17: you remove only 1 tank
Syntax 3 (problem semi)
Although the APEX works with it, I would abandon the semicolon (;) to the end.
To name the columns, you must create a function that returns the name of the report column.
Again, this must match the columns listed in the SELECT part
reminder of my warning:
Using a "SELECT *" and lack of "ORDER BY" in your cursor will cause you problems. (maybe not now, but it will.)
MK
Tags: Database
Similar Questions
-
Getting counties and divide by the sum in a single Pivot query
Hello
I have a pivot query that gives counties of all codes. I have also separated the number with the total in the same query.
Now, the output should have the counts / divided into sum multiplied by 100. Basically, the percentage.e.g col1 col2 col3 error_1 05-Jun-2012 parts error_1 05_june_2012 parts error_1 04_june_2012 consumables error_2 04_june_2012 consumables error_3 03_june_2012 parts . . .
output will be something like
Any suggestions please?error June-2012 May-2012 Feb-2012 .... headers error_1 60% 0 % 0% error_2 20% 0 0% error_3 20% 0% 0%
Thank you
Sunwith t1 as (select 'error_1' col1,trunc(sysdate) - 1 col2 from dual union all select 'error_1',trunc(sysdate) - 1 from dual union all select 'error_1',trunc(sysdate) + 30 from dual union all select 'error_2',trunc(sysdate) + 31 from dual union all select 'error_3',trunc(sysdate) - 2 from dual union all select 'error_3',trunc(sysdate) + 30 from dual union all select 'error_1',trunc(sysdate) - 3 from dual union all select 'error_2',trunc(sysdate) - 2 from dual union all select 'error_3',trunc(sysdate) + 30 from dual union all select 'error_4',trunc(sysdate) - 6 from dual ) select col1, count(case to_char(col2,'mon') when 'jul' then 1 end) one, 100 * ratio_to_report(count(case to_char(col2,'mon') when 'jul' then 1 end)) over () x, count(case to_char(col2,'mon') when 'jun' then 1 end) two, 100 * ratio_to_report(count(case to_char(col2,'mon') when 'jun' then 1 end)) over () y from t1 group by col1 order by col1
Concerning
Etbin
Edited by: Etbin on 8.6.2012 14:15
used month next to keep English and slovene "LUN" same ;) -
Original title: two updates - for "SQL Server 2005 Service Pack 3 'and 'Power Poin 2007", throwing errors during installation
For several months, one day each on ' Windows Vista Bussiness "and"MS Office Professional 2007' install.
Relevant updates are:-
1 security Update for SQL Server 2005 Service Pack 3 (KB2494113)
2 update for Microsoft Office PowerPoint 2007 (KB2535818)
The lifted message when the update is "patch installer has stopped working".
Finally, the "errors:" are: -.
Code FF Windows Update has encountered an unknown error
Code 80070663 Windows Update has encountered an unknown error
I tried nmerous solutions suggested on the forums but nothing helped.
Please suggest what you please!
Hello
Have what troubleshooting steps you tried?
Answer to the above question could help us by providing the best troubleshooting steps.
However, visit the link below to download and install the update of security for Microsoft Office PowerPoint 2007 (KB2535818) update.
http://www.Microsoft.com/download/en/details.aspx?ID=24723 -
Hi all
When I tried to use the Device.device.OS to get the string from the bone. It is compiled smoothly. But it throws error when the application started on my desk.
Error #1079: Native methods are not allowed in the loaded code.
It does not error in the emulator, but he did not get the chain of the OS.
Someone knows how to use the device class? Is it still not currently supported?
Thank you very much!
Error #1079: Native methods are not allowed in the loaded code.
This error is thrown on the desktop because your qnx - air.swc is probably in the process of fusion as code instead of being tied to your project as external. The reason who need to be external is that it contains classes that exist in the execution of AIR in the Simulator and not in the AIR runtime on your desktop. The device classes use the custom air extensions we wrote to get the properties of the device.
If you want just the operating system, you can also use the Capabilities.os, which is a standard API Flash Player and does not require the use of custom extensions.
My guess on why it does not work on the device thus is that the qnx - air.swc is not defined externally. Return to externally set and run it in the Simulator.
Hope that helps
Julian
-
Hi all
I wrote a pivot query but it is not giving me the expected output.
with test as ( select 'outgoing' type_of_call, 'local' sub_type_call, '1sec' pulse, 0.3 call_charge from dual union all select 'outgoing' type_of_call, 'STD' sub_type_call, '2sec' pulse, 1.5 call_charge from dual union all select 'outgoing' type_of_call, 'ISD' sub_type_call, '1sec' pulse, 4 call_charge from dual union all select 'SMS' type_of_call, 'local' sub_type_call, '1' pulse, 0.5 call_charge from dual union all select 'SMS' type_of_call, 'STD' sub_type_call, '1' pulse, 1 call_charge from dual union all select 'SMS' type_of_call, 'ISD' sub_type_call, '1' pulse, 3 call_charge from dual ) select * from test pivot(count(type_of_call) for (sub_type_call) in ('local','STD','ISD') ); O/P should look like Type_of_call pulse_local charge_local Pulse_STD charge_STD pulse_ISD charge_isd outgoing 1sec 0.3 2sec 1.5 1sec 4 SMS 1 0.5 1 1 1 3
Is there something that I am missing in the query?
Thank you
SID
SQL> with test as ( select 'outgoing' type_of_call, 'local' sub_ty, '1sec' pulse, 0.3 call_charge from dual union all select 'outgoing' type_of_call, 'STD' sub_ty, '2sec' pulse, 1.5 call_charge from dual union all select 'outgoing' type_of_call, 'ISD' sub_ty, '1sec' pulse, 4 call_charge from dual union all select 'SMS' type_of_call, 'local' sub_ty, '1' pulse, 0.5 call_charge from dual union all select 'SMS' type_of_call, 'STD' sub_ty, '1' pulse, 1 call_charge from dual union all select 'SMS' type_of_call, 'ISD' sub_ty, '1' pulse, 3 call_charge from dual ) select * from test pivot(max(CALL_CHARGE) as CALL_CHARGE, max(pulse) as pulse for (sub_ty) in ('local' as local,'STD' as std,'ISD' as isd) ) order by type_of_call desc 2 3 4 5 6 7 8 9 10 11 12 13 / TYPE_OF_ LOCAL_CALL_CHARGE LOCA STD_CALL_CHARGE STD_ ISD_CALL_CHARGE ISD_ -------- ----------------- ---- --------------- ---- --------------- ---- outgoing .3 1sec 1.5 2sec 4 1sec SMS .5 1 1 1 3 1
-
need help on creating pivot query
SELECT * FROM TEST1
----------------
VALUE OF PERSON COMPUTERNAME
COMP1 ABC 3
COMP2 ABC 5
COMP1 CAD 3
COMP3 CAD 5
COMP2 TES 1
COMP1 TES 5
COMP3 ABC 2
myQuery
----------------------------
Select the link null, label, value1 COUNT (VALUE)
from 'test1 '.
CONTROL group PER PERSON
Results
---------
Link label value1
- ABC 3
- CAD 2
- TES 2
My requirement
---------------
can we have something like that out using the concept of pivot? If so can you share an example query pls.
Link label value1
-ABC ORDI1, COMP2, COMP3
-CAD COMP1, COMP2
-YOUR ORDI1, COMP3
Hello
Subhash C-Oracle wrote:
need help on creating pivot query
SELECT * FROM TEST1
----------------
VALUE OF PERSON COMPUTERNAME
COMP1 ABC 3
COMP2 ABC 5
COMP1 CAD 3
COMP3 CAD 5
COMP2 TES 1
COMP1 TES 5
COMP3 ABC 2
myQuery
----------------------------
Select the link null, label, value1 COUNT (VALUE)
from 'test1 '.
CONTROL group PER PERSON
Results
---------
Link label value1
- ABC 3
- CAD 2
- TES 2
My requirement
---------------
can we have something like that out using the concept of pivot? If so can you share an example query pls.
Link label value1
-ABC ORDI1, COMP2, COMP3
-CAD COMP1, COMP2
-YOUR ORDI1, COMP3
This sounds like a job for LISTAGG:
SELECT NULL AS link
label
LISTAGG (comp_name, ',')
THE Group (ORDER BY ComputerName) AS value1
OF test1
GROUP BY label
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
Are you sure that the results you posted are what you want from data provided?
Is of the order of the elements in a significant list? In other words, when you say you want to get the results:
COMP1, COMP2
you'd be just as happy with
ORDI1, COMP2
? If the order is important, explains what this order.
-
Why multiple selection in parameter throwing error BI publisher 11g?
Hi all, I have under SQL statement with parameters.
Select 'TABLE_A '. "" s_number "as"s_number. "
'TABLE_A '. "" SM "like"sm. "
'TABLE_A '. "" Loc "as"loc"
'TABLE_A '. "" Co "as"co. "
'TABLE_A '. "" s "as"dry. "
'TABLE_A '. "" m_days "as"m_days. "
'TABLE_A '. "" b_time "as"b_time. "
'TABLE_A '. "" e_time "as"e_time. "
'TABLE_A '. "' build ' as"build. "
'TABLE_A '. "" RM "as"rm"
'TABLE_A '. "" aid_credits "as"aid_credits. "
"TABLE_D. "" Co "as"co_1. "
"TABLE_D. "" co_des "as"co_des. "
"TABLE_D. "" pre_co_des "as"pre_co_des. "
"TABLE_D. "" cont_cou_des "as"cont_cou_des. "
"TABLE_D. "' end_sm ' as 'end_sm '.
"St." » « « « dbo ». » TABLE_A' 'TABLE_A '.
"Left outer join"st. " """dbo"."" TABLE_D""TABLE_D.
on ('TABLE_A'. "Co"= "TABLE_D". ("" Co ")
where ('TABLE_A'. ("" in(:PSM) SM "or: PSM is null)
and ('TABLE_A'. ("' in(:PLOC) Loc" or: PLOP is null)
and ('TABLE_A'. ("" in(:PCO) Co "or: BCP is null) and"TABLE_D. "" end_sm "="
order by 'TABLE_A '. "' s_number ' ASC
I defined in the parameter section
multiple selection is enabled
can select all is selected
NULL value last selected for all parameters: PSM, PLOP, BCP
now my question is that if I select more than one value in the settings it throws error «an error has occurred on xml data recovery»
oracle.xdo.XDOException: java.sql.SQLException: type [Hyperion] [SQLServer JDBC Driver] [SQL Server] non Boolean expression specified in a context where a condition is expected, near ', '.
Please help me what is?
Kind regards
Sam
For this reason, the error is: PSM is null,: PLOP is null and: BCP is null.
Because it is possible to assign multiple values to a variable to link plain. You must manage this in different ways.
If she is Oracle DB - decode(:PCO,null,columnxxx,'dummy')
-
PowerCLI throwing error when I try to count the totla linux VM
Hi allWhen I try to run the command on PowerCLI to count total linux/windows VM, it's throwing error, please if any Kown how to solve the problem, please share it.
Here is the Error Msg:
PS C:\Program Files\VMware\Infrastructure\vSphere PowerCLI > (Get-VMguest * |) Where-Object {$_.} ({OSFullName-like "* Linux * '}). County | Out-file C:\Users\xbblfl9\Desktop\CNJLinuxcount.txt
Get-VMGuest: 26/12/2013-12:21:02 Get-VMGuest the underlying connection was closed: an unexpected error occurred on a send.
On line: 1 char: 13
+ (Get-VMguest < < < < * |) Where-Object {$_.} ({OSFullName-like "* Linux * '}). County |
Out-file C:\Users\xbblfl9\Desktop\CNJLinuxcount.txt
+ CategoryInfo: NotSpecified: (:)) [Get-VMGuest], ViError)
+ FullyQualifiedErrorId: Client20_QueryServiceImpl_RetrievePropertiesEx_ViError, VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVmGuestGet-VMGuest: 26/12/2013-12:21:02 Get-VMGuest value is not found for the required VM parameter
On line: 1 char: 13
+ (Get-VMguest < < < < * |) Where-Object {$_.} ({OSFullName-like "* Linux * '}). County |
Out-file C:\Users\xbblfl9\Desktop\CNJLinuxcount.txt
+ CategoryInfo: NotSpecified: (:)) [Get-VMGuest], VimException)
+ FullyQualifiedErrorId: Core_BaseCmdlet_UnknownError, VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.GetVmGuestPS C:\Program Files\VMware\Infrastructure\vSphere PowerCLI >
Thank you
Murali J
Hello
It does not work, same error, I get when I run the above command.
I can able to get windows/Linux VM Total count by using below command.
Get - vm | where {$_ .name-match "^ w"} | measure-object | Out-file C:\Users\Desktop\CNJWindowscount.tx
-
I'm new to PIVOT queries. I was making reference to the discussion that follows, but ran into a problem.
When I added the XML to format data, I started to have NULL values rather than what I was looking for.
WITH (AS PIVOT_DATA)
SELECT * FROM)
SELECT THE REGION, FCST_PERIOD, PRIME_PART, FINAL_FORECAST
OF XYZ WHERE FCST_PERIOD > = last_day (trunc (sysdate)) + 1 and FCST_PERIOD < = last_day (add_months(sysdate,12)) AND PRIME_PART IN ('BLAH')
)
PIVOT XML (SUM (FINAL_FORECAST) FOR FCST_PERIOD IN (SELECT DISTINCT FCST_PERIOD OF XYZ))
)
SELECT PRIME_PART, REGION,
EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[1]/COLUMN[2]') FCST_PERIOD1,
EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[2]/COLUMN[2]') FCST_PERIOD2,
EXTRACTVALUE(FCST_PERIOD_XML,'/PIVOTSET/ITEM[3]/COLUMN[2]') FCST_PERIOD3
OF PIVOT_DATA;
RESULTS IN:
PRIME_PART REGION FCST_PERIOD1 FCST_PERIOD2 FCST_PERIOD3 BLA MIDWEST (NULL) (NULL) (NULL) BLA WEST-NV (NULL) (NULL) (NULL) BLA SOUTH-EAST (NULL) (NULL) (NULL) BLA WEST-CA (NULL) (NULL) (NULL) BLA SOUTHWEST (NULL) (NULL) (NULL) BLA EAST (NULL) (NULL) (NULL) The second part of my question is how would I do a group when you use a pivot query. When I finished, I've has several parts and would like to group by REGION.
Thank you!
Names of elements and attributes in XML are case-sensitive.
Try with:
EXTRACTVALUE (FCST_PERIOD_XML, ' / PivotSet/item [1] /column [2]') FCST_PERIOD1
There is also a good chance that EXTRACTVALUE is frowned upon in your version. Instead, use XMLQuery or XMLTable.
That being said, using XML PIVOT just to grind it later into a number known columns is pretty useless.
The same can be achieved much more efficiently with regular PIVOT operator (and if necessary analytical function).
Post some examples of data in the table of your database and your final result expected to get useful assistance.
-
Questions HFR - "5200: query execution error: invalid item ID".
Hi all
We use the Hyperion HFM 11.1.1.3 application. We have recently upgraded to the Oralce Database 11.2.0.2 and reconfigured the HFM application with this new version of the database. When I tried to run the Financial reporting via the HFR studio, I get the error message - ' 5200: query execution error: invalid item ID ". Please could you help me solve this problem.
Thank you
Michel K
It was because of the default angle that is invalid for the user which was inconsistent with the special report.
Change the preferences to the preview from the user Point of view and rerun the report.
File > preference > Financial Reporting > preview select 'ON' box under the Point of view.
Re-run the report, then select the desired POV.
This will prompt the user to change their POV every time that he or she opens a report. They can select the correct POV and the report runs successfully.
You can turn off later. Let me know if it solved that problem.
-
Throwing error of backing bean on click of a button?
Hello world
I have two 2 user lovs lovs must select at least one value from the lov and click on the search button.
By clicking on search button im getting lov values if at least we're not selected I need to throw an error message.
How can I throw error message?
Thank you.You always go to the next page. You must return a null value when the condition fails.
public String Find(){ if(............) { //Show the message return null; } return "Find"; // to navigate to next page }
Published by: Mohammad Jabr on 27 November 2012 14:34
-
I have a query in Oracle 11:
Resultselect to_char(da,'DY-DD') days from ( select rownum -1 + to_date('2012-10-15','yyyy-mm-dd') da, l from (select level l from dual connect by level <= to_date('2012-10-21','yyyy-mm-dd') - to_date('2012-10-15','yyyy-mm-dd')+1) order by 1)
What I need which is present in a row instead of a column:"DAYS" MON-15 TUE-16 WED-17 THU-18 FRI-19 SAT-20 SUN-21
This should be done with pivot requests? Any suggestion please!MON-15 TUE-16 WED-17 THU-18 FRI-19 SAT-20 SUN-21
Thanks in advance.Hello
user564819 wrote:
I need in 7 different columns.
Oracle version is 11.2.0.1.0. Could you give an example of how to do this with pivot query?Here's one way:
WITH all_days AS ( SELECT LEVEL AS n , TO_CHAR ( TO_DATE ('2012-10-15','yyyy-mm-dd') + LEVEL - 1 , 'DY-DD' ) AS dy_dd FROM dual CONNECT BY LEVEL <= TO_DATE ('2012-10-21','yyyy-mm-dd') + 1 - TO_DATE ('2012-10-15','yyyy-mm-dd') ) SELECT * FROM all_days PIVOT ( MIN (dy_dd) FOR n IN ( 1 AS col_1 , 2 AS col_2 , 3 AS col_3 , 4 AS col_4 , 5 AS col_5 , 6 AS col_6 , 7 AS col_7 , 8 AS col_8 , 9 AS col_9 , 10 AS col_10 ) ) ;
This always displays exactly 10 columns.
If the subquery produces less than 10 dates, then the last columns will be NULL.
If the subquery produces more than 10 dates, will be not shown the 11th (and later versions).There is nothing special about the number 10; You can have any number of columns you want. The number of columns and their names is fixed when you write the query, regardless of what is in the subquery. If you want a dynamic number of columns, or names derived from data, see {message identifier: = 3527823}
-
Hi the BI Experts,
I have a question in the report. The request is to give the data, but the report shows the same.
When no values are given, report throws ERROR instead of give the white page. Client expects blank page or page modeling with tables or positions etc but not the error message.
Please suggest a solution for this.
Let me know if anyone needs any other information about it.
Thanks in advance.Make sure your Inbox sent the updated without data found logical model.
-
My Flex components constantly throw error: #1009
In a user interface, we've created, we use many elements drawn in flash and exported using the flash components. Almost any time there is a user interaction this components, or if the application loses focus, it throws error 1009. This problem is so prolific, that we can not find the cause. Here are a few of the error stack traces:
TypeError: Error #1009: cannot access a property or method of a null object reference.
to::UIMovieClip/removeFocusEventListeners() [E:\dev\trunk\frameworks\projects\flash-integration\src\mx\flash\UIMovieClip.as:2466] mx.flash
to mx.flash::UIMovieClip/focusOutHandler() [E:\dev\trunk\frameworks\projects\flash-integratio n\src\mx\flash\UIMovieClip.as:2509]
to flash. display::Stage / set focus()
to::UIComponent/setFocus() fl.core
to::FocusManager/setFocus() fl.managers
to::FocusManager/mouseDownHandler() fl.managers
The above happened when I clicked on a flex component exported from flash this is a clip that contains only a text field.
TypeError: Error #1009: cannot access a property or method of a null object reference.
to::UIMovieClip/removeFocusEventListeners() [E:\dev\trunk\frameworks\projects\flash-integration\src\mx\flash\UIMovieClip.as:2466] mx.flash
to mx.flash::UIMovieClip/focusOutHandler() [E:\dev\trunk\frameworks\projects\flash-integratio n\src\mx\flash\UIMovieClip.as:2509]
to flash. display::Stage / set focus()
to::UIComponent/setFocus() fl.core
to::FocusManager/setFocus() fl.managers
to::FocusManager/mouseDownHandler() fl.managers
The above happened when I clicked on a flash component flex exported within a scroll within another component flash flex exported flash component.
Maybe part of the problem try to mix the flash and flex frameworks too. Any help would be appreciated.
Dan
This looks like a bug. Workaround should be to change the focus to something else before removing a component from the stage.
-
ALTER database open resetlogs throw error
Hi all
My db version is 10.2.0.4
Trying to open the database
ALTER database open resetlogs throws error like
ORA-04098: trigger ' APPS. LOGON_TRGR' is invalid and does not re-validation
suggestion?
Thank you
Baskar.lUnresolved questions 45 / 48?
Maybe you are looking for
-
How can I get the console error stop appearing?
My error console keeps popping up when I open Firefox or when occurs a pop-up but its getting really boring because he has never done this before. Please tell me how to stop appearing.
-
The new Google instant search works in private browsing mode. Difficulty?
The new Google search instant feature works only in private in my Firefox 3.6 navigation mode how can get Firefox to allow normal and non-private mode?
-
Dell Dimension 2700 c reference
Hello. I have a Dell Dimension 2700 c desktop computer that won't start. When I Plug and press the power button / light in the power button lights constantly green as usual, but the computer won't start. I can hear the fan running, and more there is
-
Hello Cisco support community teams. I intend to implement GETVPN for my Client. I have several questions about GETVPN failover behavior. I have test the configuration on GNS3 with C3725 router and also tested on real C2800Series router, and the resu
-
restart the installation of RAC
Hi guys,.I met an installation problem when I try to install RAC on vmware with adatpter on a laptop microsoft loopback.After properly installing the grid infrastructure, stop down all nodes (machine VM), I intend to continue the next day.and now I b