Missing expression Error using pivot function
Hi,
When i am running the query:
The query needs to display name and total:
{select *}
{ from (select name,nvl(sal,0) tot from tablea }
{ GROUP BY name,nvl(sal,0) }
{ pivot(SUM(tot) for name in (select ltrim(sys_connect_by_path(''''||name||'''', ','), ',') str}
{from ( select row_number() over(order by name) rn}
{ , name}
{ from tablea}
{where connect_by_isleaf=1}
{start with rn=1}
{connect by rn=prior rn+1);}
When running the above query its giving error:
ORA-00936: missing expression at line select ltrim(sys_connect_by_path
Any help will be needful for me
If you use pivot, you have to hardcode all your values in the FOR IN clause.
SQL> select *
2 from (select ename,nvl(sal,0) tot from emp
3 GROUP BY ename,nvl(sal,0)
4 )
5 pivot(SUM(tot) for ename in ( 'SCOTT' ,'KING') )
6 ;
'SCOTT' 'KING'
3000 5000You can't substitute the literal list of values (in my example ('SCOTT','KING') with a subquery producing similar result.
Only with pivot xml you can put there a subquery, in that case, the result however doesn't have to be in form of comma separated values (like you try to achieve with sys_connect_by_path)
SQL> select *
2 from (select ename,nvl(sal,0) tot from emp
3 GROUP BY ename,nvl(sal,0)
4 )
5 pivot xml (SUM(tot) for ename in ( select ename from emp where ename like 'S%' ) )
6 ;
ENAME_XML
<PivotSet><item><column name = "ENAME">SCOTT</column><column name = "SUM(TOT)">3000</column></item><
item><column name = "ENAME">SMITH</column><column name = "SUM(TOT)">800</column></item></PivotSet>Best regards
Maxim
Similar Messages
-
ORA-00936 Missing expression - error in composite statement
I'm using the following statement to call a function which uses a number retrieved from a table i.e.
SELECT GETNEXTBUSINESSDATE(TO_DATE('28/08/2003','dd/mm/yyyy'), TO_NUMBER(SELECT VALUE1 FROM PARAMETERS WHERE PARCODE = 'CCR1' AND ATTRIBUTE1 = 'CCRNRQST1')) FROM DUAL;
The function adds the value store in the value1 field to a date to get the next buisness date. The above statement is giving me an ORA-00936 Missing expression error message.
Can anybody help ?We can't pass a query as a parameter.
You'll have to write a function that accepts PARCODE and ATTRIBUTE1 as parameters, or figure some other way of getting the value.
As I typed that, it occurred to me that this might work:
SELECT GETNEXTBUSINESSDATE(TO_DATE('28/08/2003','dd/mm/yyyy')
, x.val1)
FROM ( SELECT TO_NUMBER(VALUE1) as val1
FROM PARAMETERS
WHERE PARCODE = 'CCR1'
AND ATTRIBUTE1 = 'CCRNRQST1') x;I'm not guaranteeing anything as I've never tried running a function from an in-line view.
Cheers, APC -
ORA-00936: Missing Expression when using a claculation as a condition item
Hi
I created a calculation below to create a subtotal on each row of a group of selected items.
SUM(Invoice Amount)OVER(PARTITION BY Supplier Num ORDER BY Payment Currency Code)
This worked fine - but then I wanted to create a condition based on this calculation and when I used the calculation as a condition item and reran the report I received the 'ORA-00936: Missing Expression' error. So not too sure why it is fine as a calculation but not as part of a condition.
We use Discoverer version 4.1
Am I missing something or is this a bug?
Any help would be very appreciated
Thanks
MarcusThanks for your reply, Rod
We are using the 9.2.0.5 version of the database
I am not a SQL expert, by any means, but below is the line that refers to the condition in the sql inspector
WHERE ( ( E_152 )/2 > 50)
presuambly that means E_152 is the calculation, I think this may be refering to this at the beginning of the report:
SELECT DISTINCT E316344 as E316344,E316372 as E316372,E316411 as E316411,E316425 as E316425,E316496 as E316496,E316497 as E316497,E316498 as E316498,E316510 as E316510,E316511 as E316511,E316512 as E316512,E316515 as E316515,E316517 as E316517,E316519 as E316519,E316520 as E316520,E_24 as E_24,E_21 as E_21,E_18 as E_18,E_16 as E_16,E_13 as E_13,E_11 as E_11,E316501 as E316501 FROM ( SELECT E_152 as E_152,DISTINCT E316344 as E316344,E316372 as E316372,E316411 as E316411,E316425 as E316425,E316496 as E316496,E316497 as E316497,E316498 as E316498,E316510 as E316510,E316511 as E316511,E316512 as E316512,E316515 as E316515,E316517 as E316517,E316519 as E316519,E316520 as E316520,E_24 as E_24,E_21 as E_21,E_18 as E_18,E_16 as E_16,E_13 as E_13,E_11 as E_11,E316501 as E316501 FROM ( SELECT DISTINCT i316344 as E316344,i316372 as E316372,i316411 as E316411,i316425 as E316425,i316496 as E316496,i316497 as E316497,i316498 as E316498,i316510 as E316510,i316511 as E316511,i316512 as E316512,i316515 as E316515,i316517 as E316517,i316519 as E316519,i316520 as E316520,SUM(i316501) OVER(PARTITION BY i316345 ORDER BY i316520 )/2 as E_24,( i316501-( NVL(i316502,0) ) )*( NVL(i316522,1) ) as E_21,i316501-( NVL(i316502,0) ) as E_18,NVL(i316502,0) as E_16,i316501*( NVL(i316522,1) ) as E_13,NVL(i316522,1) as E_11,i316501 as E316501,SUM(i316501) OVER(PARTITION BY i316345 ORDER BY i316520 ) as E_152
Apologies if this info is not that helpful
Would it have anything to do with the fact that the row calculation is based on several rows (i.e. a subtotal) and if a single row is excluded it would change the value of the other rows within that subtotal group. Maybe it causes some sort of circular issue?
Anyway, thanks again for your help - hopefully we can resolve it
Marcus -
ORA-00936:missing expression Error
I have what I would think was a simple SQL for Excel; but for some reason I keep getting the ORA-00936 missing expression error message.
The SELECT AND FROM of the SQL are no problem. It's the Where portion of the SQL statement where it messes up. I have many user input required parameters. But I tested out the same SQL statement in Toad for Oracle and it worked fine.
I'm wondering at this point if it's just too much for Excel.
Here's the code from the "Where" portion of the SQL that worked in Toad for Oracle. I believe I have to change some of the syntax to get it to work in Excel; and I'm wondering if anyone knows the true correct way to do this. Because I'm also wondering if that's where I'm going wrong.
Anyway, here's the code:
WHERE ( (a_compl_summary.product_division = 'CP')
AND ( a_compl_summary.entry_date >= :date1
AND a_compl_summary.entry_date <= :date2
AND ( a_compl_summary.product_family LIKE :pf1
OR a_compl_summary.product_family LIKE :pf2
OR a_compl_summary.product_family LIKE :pf3
OR a_compl_summary.product_family LIKE :pf4
OR a_compl_summary.product_family LIKE :pf5
AND (a_compl_summary.region = :r1)
AND ( a_compl_summary.NAME = :c1
OR a_compl_summary.NAME = :c2
OR a_compl_summary.NAME = :c3
OR a_compl_summary.NAME = :c4
OR a_compl_summary.NAME = :c5
AND (a_compl_summary.complaint = :yorn)
AND ( rp_qa_reported_device_codes.reported_dev_clarification LIKE
:cl1
OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
:cl2
OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
:cl3
OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
:cl4
OR rp_qa_reported_device_codes.reported_dev_clarification LIKE
:cl5
AND (rp_qa_reported_device_codes.reported_dev_clarification NOT LIKE
:dc1
AND (a_compl_summary.incident_number =
rp_qa_patient_codes.incident_number
AND (a_compl_summary.case_number = rp_qa_patient_codes.case_number)
AND (a_compl_summary.part_sequence = rp_qa_patient_codes.part_sequence
AND (a_compl_summary.incident_number =
rp_qa_reported_device_codes.incident_number
AND (a_compl_summary.case_number =
rp_qa_reported_device_codes.case_number
AND (a_compl_summary.part_sequence =
rp_qa_reported_device_codes.part_sequence
AND (rp_qa_reported_device_codes.incident_number =
rp_qa_patient_codes.incident_number
AND (rp_qa_reported_device_codes.case_number =
rp_qa_patient_codes.case_number
AND (rp_qa_reported_device_codes.part_sequence =
rp_qa_patient_codes.part_sequence
)But are the ":parameter1" okay, or do I need to change the syntax for Excel?
Because when I change the[b] :parameter to just a ? it ends up working to a degree. When I have too many parameters Excel ends up bailing on me with a Debug, Send Error Report box popping up. -
Missing Expression error in query...
Hi,
SELECT DECODE(NAME, '~', '', NAME),
DECODE(NAME_2, '~', '', NAME_2),
DECODE(SALES_ORG_ID, '~', '', SALES_ORG_ID),
DECODE(PARTNER_ID, '~', '', PARTNER_ID)
FROM DMN_SALES_PARTNER
WHERE (
(upper(trim(country_name)),(trim(state_id))) IN
SELECT DISTINCT upper(trim(scsm.country_name)),upper(trim (scsm.state_name))
FROM sop_region_country_map srsm, sop_user_map smap,sop_country_state_map scsm
WHERE SSO_ID = '&sso_id' AND
upper(trim(smap.region_id)) = upper(trim(srsm.region_id)) AND
upper(trim(srsm.country_name)) = upper(trim(scsm.country_name)) AND
decode(upper(trim(srsm.state_name)),NULL,'~',upper(trim(srsm.state_name)) ) = upper(trim(scsm.state_name))
AND deviation_from_sap = 'N'
OR
SELECT upper(trim(scsm.country_name)),upper(trim(scsm.state_name))
FROM sop_country_state_map scsm
WHERE (upper(trim(scsm.country_name)),scsm.sap_state_map_id) in (
select upper(trim(scssm.country_name)),scssm.sap_state_map_id
from sop_country_state_sap_mapping scssm )
)I want to return the combination of country_name and state_name from any of the queries in OR clause so as to compare them with the country_name and state_id of main query..I have written the above query for it but its giving me "Missing Expression" error..
Pls help..
Thx
JPJP,
Your second part after the "OR" is just a SQL statement and it is not being compared to an expression. That's probably what the error message is telling you.
Regards,
Rob. -
Pivot function and Missing expression error
select * from (
select T.PAT_MRN_ID, T.ABBREVIATION,CONCEPT_VALUE from TBL_WORKLFOw T
pivot
max(concept_value)
for ABBREVIATION in (select ABBREVIATION from TBL_WORKLFOW )
this query is throwing "missing expression"..error.
Can some one help figuring out the problem.Hi, Parth,
Parth Divekar wrote:
So your suggestion is to have it in a procedure ...form a dynamic sql using values from query and then execute the sql..That's one thing you can do.
You might also look into string aggregation, where you have one gargantuan column containing all the pivoted data from all the abbreviatons, no matter how many there are. That big column can be formatted so that it looks like several distinct columns.
Assuming dynamic SQL is the best answer, I find it easier to do in SQL*Plus, using files or substitution variables, as shown below. That's just my preference; you may like PL/SQL better.
How to Pivot a Table with a Dynamic Number of Columns
This works in any version of Oracle
The "SELECT ... PIVOT" feature introduced in Oracle 11
is much better for producing XML output.
Say you want to make a cross-tab output of
the scott.emp table.
Each row will represent a department.
There will be a separate column for each job.
Each cell will contain the number of employees in
a specific department having a specific job.
The exact same solution must work with any number
of departments and columns.
(Within reason: there's no guarantee this will work if you
want 2000 columns.)
Case 0 "Basic Pivot" shows how you might hard-code three
job types, which is exactly what you DON'T want to do.
Case 1 "Dynamic Pivot" shows how get the right results
dynamically, using SQL*Plus.
(This can be easily adapted to PL/SQL or other tools.)
PROMPT ========== 0. Basic Pivot ==========
SELECT deptno
, COUNT (CASE WHEN job = 'ANALYST' THEN 1 END) AS analyst_cnt
, COUNT (CASE WHEN job = 'CLERK' THEN 1 END) AS clerk_cnt
, COUNT (CASE WHEN job = 'SALESMAN' THEN 1 END) AS salesman_cnt
FROM scott.emp
WHERE job IN ('ANALYST', 'CLERK', 'SALESMAN')
GROUP BY deptno
ORDER BY deptno
PROMPT ========== 1. Dynamic Pivot using Script ==========
-- ***** Start of dynamic_pivot.sql *****
-- Suppress SQL*Plus features that interfere with raw output
SET FEEDBACK OFF
SET PAGESIZE 0
SPOOL p:\sql\cookbook\dynamic_pivot_subscript.sql
SELECT DISTINCT
', COUNT (CASE WHEN job = '''
|| job
|| ''' ' AS txt1
, 'THEN 1 END) AS '
|| job
|| '_CNT' AS txt2
FROM scott.emp
ORDER BY txt1;
SPOOL OFF
-- Restore SQL*Plus features suppressed earlier
SET FEEDBACK ON
SET PAGESIZE 50
SPOOL p:\sql\cookbook\dynamic_pivot.lst
SELECT deptno
@@dynamic_pivot_subscript
FROM scott.emp
GROUP BY deptno
ORDER BY deptno
SPOOL OFF
-- ***** End of dynamic_pivot.sql *****
EXPLANATION:
The basic pivot assumes you know the number of distinct jobs,
and the name of each one. If you do, then writing a pivot query
is simply a matter of writing the correct number of ", COUNT ... AS ..."\
lines, with the name entered in two places on each one. That is easily
done by a preliminary query, which uses SPOOL to write a sub-script
(called dynamic_pivot_subscript.sql in this example).
The main script invokes this sub-script at the proper point.
In practice, .SQL scripts usually contain one or more complete
statements, but there's nothing that says they have to.
This one contains just a fragment from the middle of a SELECT statement.
Before creating the sub-script, turn off SQL*Plus features that are
designed to help humans read the output (such as headings and
feedback messages like "7 rows selected.", since we do not want these
to appear in the sub-script.
Turn these features on again before running the main query.
PROMPT ========== 2. Dynamic Pivot using Substitution Variable ==========
-- ***** Preliminary Query: *****
COLUMN sql_txt_col NEW_VALUE sql_txt
WITH all_jobs AS
SELECT DISTINCT
job
, DENSE_RANK () OVER (ORDER BY job) AS r_num
FROM scott.emp
SELECT SYS_CONNECT_BY_PATH ( job || ''' THEN 1 END) AS '
|| job
|| '_CNT'
|| CHR (10) -- Newline, for legibility only
, ', COUNT (CASE WHEN job = ''' -- Delimiter, goes before each entry
) AS sql_txt_col
FROM all_jobs
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_num = PRIOR r_num + 1
-- ***** Main Query *****
SELECT deptno
&sql_txt -- Ends with newline, so occupy that line
FROM scott.emp
GROUP BY deptno
ORDER BY deptno
EXPLANATION:
Using a substitution variable is very similar to using a script.
The main difference is that the output of the preliminary query has to
go into one row. This is done with SYS_CONNECT_BY_PATH, and getting
that requires that the jobs be numbered with consecutive integers, 1, 2, 3, ...
which we get from DENSE_RANK.
The NEWLINE character was added just to make the output line easier
to read during debugging.
*/ -
Missing Expression Error When Case Statment is used as field
I have tried to write an expression that will calculate how many days ago a request was submitted and return a user defined value if the calculation falls within the criteria in the case statment. The SQL View for the Query I am using is shown below:
SELECT A.F_POSN_REQUEST_ID, A.F_REQ_ECP_STATUS, TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>60 THEN '>60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI')) >30 AND <=60 THEN '30 - 60' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))>=15 AND <=30 THEN '15 - 30' ELSE(CASE WHEN(sysdate - TO_DATE(SUBSTR( TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'),1,16),'YYYY-MM-DD-HH24.MI'))<15 THEN 'Less Than 15' ELSE NULL END)END)END)END))
FROM PS_F_POSN_REQUEST A
WHERE A.F_REQ_ECP_STATUS IN ('I','O','P')
GROUP BY A.F_POSN_REQUEST_ID, A.F_REQ_ECP_STATUS, TO_CHAR(A.REQUEST_DTTM,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_ST_DT,'YYYY-MM-DD-HH24.MI.SS."000000"'), TO_CHAR(A.F_REQ_ECP_PROC_DT,'YYYY-MM-DD-HH24.MI.SS."000000"')When I try to run the query I get Message=ORA-00936: missing expression (50,380)
Any suggestions you could provide to help me clear this error would be greatly appreciated.
Edited by: 992737 on Mar 8, 2013 9:07 AMHi,
Welcome to the forum!
I think you want something like this:
CASE
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 60 THEN '>60'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 30 THEN '30.1-60'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) - 15 THEN '15.1-30'
WHEN a.f_req_st_dt < TRUNC (SYSDATE) THEN '15 or less'
ENDNested CASE expressions aren't needed very much. Each WHEN clause is evaluated only if all the ealier ones have failed. For example, when testing to see if a row is in the 301.-60 range above (that is, the 2nd WHEN clause), there's no need to see if the difference is greater than or equal to 60; it wouldn't be evaluating that clause if the 1st WHEN condition was TRUE.
This assumes that a.f_req_st_dt is a TIMESTAMP or DATE; either datatype can be compared with DATEs, such as SYSDATE-60, so there's no need to conevert them to strings, and then convert them back into DATEs.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Simplify the problem as much as possible. Show only the parts that you don't already know how to do.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002}
Never write, let alone post, unformatted code. Indent the code to show the exent and structure of clauses (SELECT, FROM, etc.), and complex expressions (such as CASE). The forum FAQ explains how to use \ tags when posting formatted text on this site. -
OIM 11g - AD Organization Recon "missing expression" error
Hi,
I've got an environment with a OIM 11.1.1.5.2 installed with MSAD user management connector version 9.1.1.
Provisioning to Active Directory works just fine out of the box, however, we've run into a problem with the Organization Reconciliation Job (not the organization lookup reconciliation).
Every time i run the "AD Organization Recon" schedule task, the job ends succesfully and events are created for each AD org, but these events do not have any value on the "current status" field and no OIM organization is created.
Checking the logs, i can find the following error for each organization discovered for the connector:
[2012-04-04T10:06:19.647-03:00] [WLS_OIM1] [NOTIFICATION] [IAM-5010000] [oracle.iam.reconciliation.dao] [tid: [ACTIVE].ExecuteThread: '4' for
queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 58f980760a5e54af:-129c6f98:1367872b8db:-8000-0000000000000002,0
] [APP: oim#11.1.1.3.0] Generic Information: Insert into recon_org_match(act_key, re_key, rom_rowver) (SELECT act.act_key, RA_XELLERATE_ORG.r
e_key, '0' FROM act, RA_XELLERATE_ORG WHERE RA_XELLERATE_ORG.re_key = 99 and act.act_status != 'Deleted' AND )
[2012-04-04T10:06:19.648-03:00] [WLS_OIM1] [NOTIFICATION] [IAM-5010006] [oracle.iam.reconciliation.impl] [tid: [ACTIVE].ExecuteThread: '4' fo
r queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 58f980760a5e54af:-129c6f98:1367872b8db:-8000-0000000000000002,
0] [APP: oim#11.1.1.3.0] The following exception occurred: {0}[[
oracle.iam.platform.utils.SuperRuntimeException: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
at oracle.iam.reconciliation.dao.ReconActionDao.executeOrgMatch(ReconActionDao.java:1370)
at oracle.iam.reconciliation.impl.OrganizationHandler.executeSingleEventMatch(OrganizationHandler.java:34)
at oracle.iam.reconciliation.impl.EntityTypeHandler.process(EntityTypeHandler.java:38)
at oracle.iam.reconciliation.impl.ActionEngine.processEvent(ActionEngine.java:209)
This is not the first time this happens to us, just a month ago in a different environment, and working with OIM 11.1.1.5, we found the same problem. After reviewing everything we could thought of, we exported the Xellerate Organization.xml file from mds and found this:
<?xml version='1.0' encoding='UTF-8'?>
<reconConfig xmlns="http://www.oracle.com/schema/oim/recon/profile">
<generalconfig mode="CHANGELOG" createEntityUsingSPFlag="true" dateFormat="yyyy/MM/dd hh:mm:ss z" ownerMatchingRuleWhereClause="" entitytype="Organization" version="1.0" trustedSrcFlag="false" accountPostProcessingRequiredFlag="true" sequentialProcessingFlag="false" batchSize="-1" retryInterval="30" maxRetryCount="5" defaultProfileFlag="true" name="Xellerate Organization"/>
<singlevaluedreconeventdata>
<formInfo ostKey="0" sdkKey="2" objKey="3" latestFormVersion="0" activeFormVersion="0" objorderFor="O" objname="Xellerate Organization" sdkformName="ACT"/>
<matchingruleWhereClause>*((ACT.ACT_NAME=RA_XELLERATE_ORG.RECON_ORGANIZATIONSORGB111A46A))*</matchingruleWhereClause>
<reconFields>
<reconAttr>
We found that after adding the same rule on the element "matchingruleWhereClause" to the element "ownerMatchingRuleWhereClause" the reconciliation started working. At the time we thought that maybe we had modified some property on the design console and messed up the profile, or some bug that would be patched on 11.1.1.5.2, but now that we have a brand new patched installation we face the exact same situation.
Is this a common problem in 11.1.1.5? Is manually editing the xellerate organization profile supported? Maybe we are doing something wrong, but we've followed all OIM and AD connector guides, there's nothing there that says that we need to configure rules on the xellerate orgs resource before trying recon. We can reconcile using this workaround, but we do not want to move forward without knowing if something could go wrong down the line.
Thanks.Hi guys,
I'm experiencing the same problem? Does any one have any suggestions?
Thanks in advance... -
Insert missing expression error
I am trying to insert data into sql plus and I keep getting this error. I am new at this and have no idea what I am doing wrong. Could someone please help!
here is the table I am inserting:
Name Null? Type
MANUFACTURER_ID NOT NULL NUMBER
M_NAME VARCHAR2(30)
STREET VARCHAR2(30)
CITY VARCHAR2(30)
STATE VARCHAR2(20)
COUNTRY VARCHAR2(30)
WEBSITE VARCHAR2(50)
EMAIL VARCHAR2(50)
FAX VARCHAR2(15)
I am inserting these values:
SQL> insert into manufacturer values(9185247,rollinsonlightsportaircraft,route2box186, bloomfield_in_47424, In, US, 'www.eurofox-use.com','[email protected]', 8123840518);
insert into manufacturer values(9185247,rollinsonlightsportaircraft,route2box186, bloomfield_in_47424, In, US, 'www.eurofox-use.com','[email protected]', 8123840518)
ERROR at line 1:
ORA-00936: missing expression
I have been working on this forever and I am just not getting it. Please help!Now I am working on a different table and I am getting the error on a number attribute. Any ideas: here is the info.
Name Null? Type
DESIGN_ID NOT NULL NUMBER
MANUFACTURER_ID NUMBER
ENGINE_ID NUMBER
DESIGN_NAME VARCHAR2(20)
MAX_SPEED NUMBER
CRUISE_SPEED NUMBER
LD VARCHAR2(10)
MINSINK NUMBER
ASPECT_RATIO VARCHAR2(10)
RANGE NUMBER
CLIMB_RATE NUMBER
TAKEOFF_D NUMBER
LANDING_D NUMBER
SERVICE_CEIL NUMBER
EMPTY_WEIGHT NUMBER
GROSS_WEIGHT NUMBER
USEFUL_WEIGHT NUMBER
HEIGHT NUMBER
LENGTH NUMBER
WINGSPAN NUMBER
WINGAREA NUMBER
FUEL_CAPACITY NUMBER
WINGFOLD NUMBER
GEAR VARCHAR2(30)
HOUR_BUILD NUMBER
BUILT VARCHAR2(20)
INFO_PACKET VARCHAR2(10)
COST_OF_PLANS NUMBER
KIT_COST NUMBER
QB_COST NUMBER
PLAN_COST NUMBER
LDA VARCHAR2(20)
P_CURRENT NUMBER
CABIN_WIDTH NUMBER
QB_BUILDTIME VARCHAR2(20)
BUILD_COSTLOW NUMBER
BUILD_COSTHIGH NUMBER
SEATS VARCHAR2(20)
SQL> insert into plane values(20260,90300,148,'BushCaddy L162 Max',140,125,'',,'',720,1300,380,500,14000,1250,2650,1400,8,238,36,189,60,,'tailwheel',1200,'12','25',0,354030,0,'',1,47,'300',60000,110000,'2+2');
insert into plane values(20260,90300,148,'BushCaddy L162 Max',140,125,'',,'',720,1300,380,500,14000,1250,2650,1400,8,238,36,189,60,,'tailwheel',1200,'12','25',0,354030,0,'',1,47,'300',60000,110000,'2+2')
ERROR at line 1:
ORA-00936: missing expression
The * is falling under the cruise speed variable or minisink. but they are both number. -
How to use Pivot function for group range in oracle SQL
Hi,
Good Morning !!!
I need to show the data in the below format. There is 2 columns 1 is State and another one is rate.
State <100 100-199 200-299 300-399 400-499 500-599 600-699 700-799 800-899 900-999 >=1000 Total
AK 1 2 0 4 1 4 4 35 35 4 1 25
AL 0 0 2 27 10 17 35 2 2 35 0 103
AR 0 0 1 0 0 2 2 13 13 2 0 6
AZ 0 1 2 14 2 14 13 3 3 13 0 57
CA 0 0 1 6 2 7 3 4 4 3 0 34
Developed the below query but unable to use the range on pivot function . Please help on this.
(select (SELECT SHORT_DESCRIPTION
FROM CODE_VALUES
WHERE CODE_TYPE_CODE = ad.STATE_TYPE_IND_CODE
AND VALUE = ad.STATE_CODE
) STATE,
nr.rate
FROM neutrals n,
contacts c,
addresses ad,
xref_contacts_addresses xca,
neutral_rates nr
where n.contact_id=c.contact_id
and n.address_id = ad.address_id
and xca.address_id=ad.address_id
and xca.contact_id=c.contact_id
and nr.contact_id = n.contact_id
and nr.rate_frequency='HOUR' )user8564931 wrote:
This solutions is useful and Thanks for your reply.
How can i get the Min value and Max value for each row ?
State <100 100-199 200-299 300-399 400-499 500-599 600-699 700-799 800-899 900-999 >=1000 Total Min Max
IL 0 0 1 5 1 5 40 1 1 40 0 53 $10 $2,500
IN 0 0 0 0 0 0 1 49 49 1 0 3 $70 $1,500This?
WITH t AS
(SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 67 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 78 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 34 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 4 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 15 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 6 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 123 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 123 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 120 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 456 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 11 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 24 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 34 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 87 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 234 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 789 VALUE FROM DUAL
UNION ALL
SELECT 'MH' state, 54321 VALUE FROM DUAL),
-- End of test data
t1 AS
( SELECT state,
NVL (COUNT (DECODE (VALUE, 0, 0)), 0) "<100",
NVL (COUNT (DECODE (VALUE, 1, 1)), 0) "100-199",
NVL (COUNT (DECODE (VALUE, 2, 2)), 0) "200-299",
NVL (COUNT (DECODE (VALUE, 3, 3)), 0) "300-399",
NVL (COUNT (DECODE (VALUE, 4, 4)), 0) "400-499",
NVL (COUNT (DECODE (VALUE, 5, 5)), 0) "500-599",
NVL (COUNT (DECODE (VALUE, 6, 6)), 0) "600-699",
NVL (COUNT (DECODE (VALUE, 7, 7)), 0) "700-799",
NVL (COUNT (DECODE (VALUE, 8, 8)), 0) "800-899",
NVL (COUNT (DECODE (VALUE, 9, 9)), 0) "900-999",
NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ">=1000"
FROM (SELECT state,
CASE
WHEN VALUE < 100 THEN 0
WHEN VALUE BETWEEN 100 AND 199 THEN 1
WHEN VALUE BETWEEN 200 AND 299 THEN 2
WHEN VALUE BETWEEN 300 AND 399 THEN 3
WHEN VALUE BETWEEN 400 AND 499 THEN 4
WHEN VALUE BETWEEN 500 AND 599 THEN 5
WHEN VALUE BETWEEN 600 AND 699 THEN 6
WHEN VALUE BETWEEN 700 AND 799 THEN 7
WHEN VALUE BETWEEN 800 AND 899 THEN 8
WHEN VALUE BETWEEN 900 AND 999 THEN 9
WHEN VALUE >= 1000 THEN 10
END
VALUE
FROM t)
GROUP BY state)
SELECT STATE,
"<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000",
"<100"
+ "100-199"
+ "200-299"
+ "300-399"
+ "400-499"
+ "500-599"
+ "600-699"
+ "700-799"
+ "800-899"
+ "900-999"
+ ">=1000"
total,
least("<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000") min_val,
greatest("<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000") max_val
FROM t1
/ -
Error using Rank function in Answers
Hi All,
Am trying to generate a report in Answers which lists Top Accounts with Revenue.
I Ranked the Revenue field and it is returning me correct values. ( Rank(account.revenue) )
But, when I try to filter on this field and restrict the rows which shows only top 10 Accounts, it is returning the following error:
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1792, message: ORA-01792: maximum number of columns in a table or view is 1000 at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
Can any one help me on this.
Thanks in Advance,
Imtiaz.Hi Joe,
This is the Physical query generated when I use Rank function and the report is fine.
select distinct D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9,
D1.c10 as c10,
D1.c11 as c11,
D1.c12 as c12,
D1.c13 as c13,
D1.c14 as c14,
D1.c15 as c15
from
(select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9,
D1.c10 as c10,
D1.c11 as c11,
D1.c12 as c12,
D1.c13 as c13,
D1.c14 as c14,
D1.c15 as c15
from
(select Case when D1.c1 is not null then Rank() OVER ( ORDER BY D1.c1 DESC NULLS LAST ) end as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c1 as c4,
D1.c4 as c5,
D1.c5 as c6,
D1.c6 as c7,
D1.c7 as c8,
D1.c8 as c9,
D1.c9 as c10,
D1.c10 as c11,
D1.c11 as c12,
D1.c12 as c13,
D1.c13 as c14,
D1.c14 as c15,
ROW_NUMBER() OVER (PARTITION BY D1.c1, D1.c2, D1.c3, D1.c4, D1.c5, D1.c6, D1.c7, D1.c8, D1.c9, D1.c10, D1.c11, D1.c12, D1.c13, D1.c14 ORDER BY D1.c1 ASC, D1.c2 ASC, D1.c3 ASC, D1.c4 ASC, D1.c5 ASC, D1.c6 ASC, D1.c7 ASC, D1.c8 ASC, D1.c9 ASC, D1.c10 ASC, D1.c11 ASC, D1.c12 ASC, D1.c13 ASC, D1.c14 ASC) as c16
from
(select distinct T690.SUM_REVN_AMT as c1,
T690.NAME as c2,
T2216.NAME as c3,
T690.X_PETROFAC_REVN as c4,
T690.SUM_WIN_PROB as c5,
T690.X_PERCENT_GET as c6,
T690.SUM_WIN_PROB * T690.X_PERCENT_GET / nullif( 100, 0) as c7,
T690.X_EC_PRIORITY as c8,
T19028.LOGIN as c9,
T690.X_COUNTRY as c10,
T690.X_REGION as c11,
T18311.NAME as c12,
T18641.NAME as c13,
T18238.NAME as c14
from
SIEBEL.S_BU T18238 left outer join (
SIEBEL.S_USER T19028 left outer join (
SIEBEL.S_OPTY T690 left outer join SIEBEL.S_STG T2216 On T690.CURR_STG_ID = T2216.ROW_ID) left outer join SIEBEL.S_ORG_EXT T1189 On T690.PR_DEPT_OU_ID = T1189.ROW_ID) left outer join SIEBEL.S_ORG_EXT T18311 /* Competitor */ On T690.PR_CMPT_OU_ID = T18311.ROW_ID) left outer join SIEBEL.S_ORG_EXT T18641 /* Partner */ On T690.PR_PRTNR_ID = T18641.ROW_ID) left outer join SIEBEL.S_POSTN T19114 On T690.PR_POSTN_ID = T19114.PAR_ROW_ID) left outer join SIEBEL.S_OPTY_BU T18280 On T690.ROW_ID = T18280.OPTY_ID) left outer join SIEBEL.S_OPTY_X T19415 On T690.ROW_ID = T19415.PAR_ROW_ID) On T19028.PAR_ROW_ID = T19114.PR_EMP_ID) On T18238.ROW_ID = T18280.BU_ID
) D1
) D1
where ( D1.c16 = 1 )
) D1
order by c1 desc
But When I apply Filter on this Rank column then it gives me the error. THis is the Physical query for that
select distinct Case when D1.c1 is not null then Rank() OVER ( ORDER BY D1.c1 DESC NULLS LAST ) end as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c1 as c4,
D1.c4 as c5,
D1.c5 as c6,
D1.c6 as c7,
D1.c7 as c8,
D1.c8 as c9,
D1.c9 as c10,
D1.c10 as c11,
D1.c11 as c12,
D1.c12 as c13,
D1.c13 as c14,
D1.c14 as c15
from
(select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9,
D1.c10 as c10,
D1.c11 as c11,
D1.c12 as c12,
D1.c13 as c13,
D1.c14 as c14
from
(select T690.SUM_REVN_AMT as c1,
T690.NAME as c2,
T2216.NAME as c3,
T690.X_PETROFAC_REVN as c4,
T690.SUM_WIN_PROB as c5,
T690.X_PERCENT_GET as c6,
T690.SUM_WIN_PROB * T690.X_PERCENT_GET / nullif( 100, 0) as c7,
T690.X_EC_PRIORITY as c8,
T19028.LOGIN as c9,
T690.X_COUNTRY as c10,
T690.X_REGION as c11,
T18311.NAME as c12,
T18641.NAME as c13,
T18238.NAME as c14,
Case when T690.SUM_REVN_AMT is not null then Rank() OVER ( ORDER BY T690.SUM_REVN_AMT DESC NULLS LAST ) end as c15
from
SIEBEL.S_BU T18238 left outer join (
SIEBEL.S_USER T19028 left outer join (
SIEBEL.S_OPTY T690 left outer join SIEBEL.S_STG T2216 On T690.CURR_STG_ID = T2216.ROW_ID) left outer join SIEBEL.S_ORG_EXT T1189 On T690.PR_DEPT_OU_ID = T1189.ROW_ID) left outer join SIEBEL.S_ORG_EXT T18311 /* Competitor */ On T690.PR_CMPT_OU_ID = T18311.ROW_ID) left outer join SIEBEL.S_ORG_EXT T18641 /* Partner */ On T690.PR_PRTNR_ID = T18641.ROW_ID) left outer join SIEBEL.S_POSTN T19114 On T690.PR_POSTN_ID = T19114.PAR_ROW_ID) left outer join SIEBEL.S_OPTY_BU T18280 On T690.ROW_ID = T18280.OPTY_ID) left outer join SIEBEL.S_OPTY_X T19415 On T690.ROW_ID = T19415.PAR_ROW_ID) On T19028.PAR_ROW_ID = T19114.PR_EMP_ID) On T18238.ROW_ID = T18280.BU_ID
) D1
where ( D1.c15 <= 10 )
) D1
order by c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15
Thanks,
Imtiaz -
IDOC- JDBC --- ORA-00936: missing expression - Error
Hi all,
I am working on a IDOC-> JDBC scenario.
it works fine in development but in quality i amgetting the following message.
Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'T_SAP_COST' (structure 'Statement2'): java.sql.SQLException: ORA-00936: missing expression
there is no issue with mapping and i compared and everything is exactly the same as development.
Has someone come accross a similar issue.
Regards,
Tarun BahalThis is not an error with respect to XI. There is some problem with the SQL query generated after the mapping. Generally ORA____ kind of errors are comman in JDBC Senario and even Oracle maintains something like our SAP Note for each ORA errors. I am not sure about the URL for searching this error. You can check in this URL too, [ORA-00936 |http://ora-00936.ora-code.com/] http://ora-00936.ora-code.com/
Since you are saying that it works fine in developement, you can check with the data. Whether it is generating the SQL Statement properly or not. Also confirm whether you have sufficient data in the quality systems to generate the SQL Statement properly.
Edited by: Prasad Ulagappan on Oct 16, 2008 11:34 AM -
Error using LISTAGG function to aggregate the strings.
HI
I am using LISTAGG function to aggregate the strings but throws a error ORA - 19011
The output of the aggregated function exeeds the varchar limit.
I dont know how to change it to a LOB.
Can you please help me.
This is the code.
I have used both the functions.
RTRIM(XMLAGG(XMLELEMENT(e,FDCT.USER_NAME || ' ')).extract('//text()'), ' ')
or
LISTAGG(FDCT.USER_NAME, ',') WITHIN GROUP (ORDER BY FDCT.USER_NAME)
Edited by: 787819 on Jun 22, 2011 1:46 PMIf a function returns a VARCHAR2, then it will error (or sometimes truncate depending on function) when reaching the limit of the datatype.
Perhaps an alternative would be to write your own user-defined aggregate function that works with a CLOB.
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10765/aggr_functions.htm#ADDCI2120
A comma-separated string over 32767 in length sounds of dubious value to me anyway... -
JDBC receiver - "ORA-00936:missing expression" error at sync.select command
Hi again,
questions, questions....
This is my select on the JDBC rec.connection:
I think this is a select with an AND (two criteria).
How does it look for an OR ?
At the moment we have another error:
Error when executing statement for table/stored proc. 'IRIS.T_ST_MAINDRIVER' (structure 'STATEMENT'): java.sql.SQLException: ORA-00936: missing expression
Hello experts,
what is this? I don´t think that a select calls a stored procedure which is the only result for threads when searching in this forum!
regards
DirkHi,
Are you trying to execute a Stored Procedure?
You can't get the result from an Oracle SP with JDBC. The problem is about the cursor return from SP, that couldn't bre understood by JDBC adapter.
You can, make a .NET wrapper to it. Make a .NET web service that gets the parameters from XI and runs the SP with them, get the oracle cursor return, transform it into a XML message and return it to the XI SOAP adapter. I've tryied and it works fine - and as I could see is the only way to perform calls to Oracle SPs with cursor return in XI.
hope this helps!
roberti
Message was edited by:
Waldemar Roberti -
With out using pivot function need a Query
Hi
I am having table which has 7 columns
data in table:
ID,Region,area, year-month, sales_target, actual_sales,
1, abc, xyz, 200907, 1000, 500
2, abc, pqr, 200908, 2000, 1500
3, mnr, xyz, 200907, 3000, 2000
I need the data in year and month with out using pivot funtion
intial
region, area, jul, aug, sep, oct .......jun
abc, xyz, 1000,0, 0, 0... 0
actual
region, area, jul, aug, sep, oct .......jun
abc, xyz, 500, 0, 0, 0... 0ThanksHere it is
with d as ( select 1 ID, 'abc' Region, 'xyz' area, 200907 yearmonth, 1000 sales_target, 500 actual_sales from dual
union all select 2, 'abc', 'pqr', 200908, 2000, 1500 from dual
union all select 3, 'mnr', 'xyz', 200907, 3000, 2000 from dual
select region, area,
max(case extract(month from to_date(yearmonth,'yyyymm')) when 7 then sales_target
else 0 end ) TGT_JUL
max(case extract(month from to_date(yearmonth,'yyyymm')) WHEN 8 then sales_target
else 0 end ) TGT_AUG
max(case extract(month from to_date(yearmonth,'yyyymm')) WHEN 9 then sales_target
else 0 end ) TGT_SEP
from d
group by region, area
REG ARE TGT_JUL TGT_AUG TGT_SEP
abc pqr 0 2000 0
mnr xyz 3000 0 0
abc xyz 1000 0 0You can copy and replicate the results for another one - actual_sales.
Maybe you are looking for
-
How do I use my MacBook Pro to do video chat with my Gmail account
I have a gmail video/audio chat account and would like to use my Macbook Pro as my communication device. I cann't seem to get the video portion going. Anyidea?
-
Can we create a Simulation tutorial steps from a Video in HTML5
Hi Everyone, I want to create a tutorial something like a simulation by using the video. And the big thing is that it has to be in html5 format. I have one video in MP4 format from which I have to create the tutorial.The video is just a screen record
-
Password Protect Attachment file thru Mail from BO
I am generating WebI report and this report (in the format of excel/pdf) will be send to the list of users through mail. When the user open the attachment, it should prompt for password and open the same once password match.
-
Hi, I have created a site using muse that is hosted on Business Catalyst (webmarketing+). I have created and formatted the news module using the tutorialon Adobe TV and its working perfectly but I'm just wondering how to add images / pdf downloads to
-
Nach Update über Cloud: Absturz PS CC 2014 nach etwa 10 Sekunden
Hallo Gemeinde, habe gerade mein neues Update über die Cloud bezogen. Leider stürzt PS nach ca. 10 Sekunden ab, mit der Meldung: Adobe PS CC 2014 funktioniert nicht mehr. Grafikkartentreiber habe ich schon aktualisiert. Hier die Systeminfo: Kann jema