I have a table called host which I can perform function aggregations like avg:
select avg(cpu_cores) from host
Gives me:
AVG(cpu_cores)
4.93
However if I try the same with checksum it errors out as invalid identifier:
select checksum(cpu_cores) from host
ORA-00904: "CHEKCSUM INVALID IDENTIFIER"
CAUSE:
ACTION:
ERROR AT LINE 1 COLUMN 8
why is that ?
Related
Hi I am trying to run this query but getting this error
Query 1
select OWNER,table_name,
to_number(extractvalue(xmltype(dbms_xmlgen.getxml('select count(*) c from '||owner||'.'||table_name)),'/ROWSET/ROW/C')) as count
from all_tables
Runs fine
Query 2 - Included additional columns (sample_size, last_analyzed)
select OWNER,table_name,
to_number(extractvalue(xmltype(dbms_xmlgen.getxml('select count(*) c from '||owner||'.'||table_name)),'/ROWSET/ROW/C')) as count,
sample_size, last_analyzed
from all_tables
Error - ?
ORA-19202: Error occurred in XML processing
ORA-00933: SQL command not properly ended
ORA-06512: at "SYS.DBMS_XMLGEN", line 176
ORA-06512: at line 1
19202. 00000 - "Error occurred in XML processing%s"
*Cause: An error occurred when processing the XML function
*Action: Check the given error message and fix the appropriate problem
Query 2 - Issue what could be the issue ? - Explanation and resolution
By using HR schema, i have created backup table (EMPLOYEES_BKP) using EMPLOYEES table. when i am using MERGE statement, i am getting the below error..
MERGE INTO EMPLOYEES_BKP BKP
USING EMPLOYEES EMP
ON (BKP.EMPLOYEE_ID=EMP.EMPLOYEE_ID)
WHEN MATCHED THEN
UPDATE SET BKP.SALARY=EMP.SALARY
WHEN NOT MATCHED BY TARGET THEN
INSERT (BKP.EMPLOYEE_ID, BKP.FIRST_NAME,BKP.LAST_NAME, BKP.EMAIL, BKP.PHONE_NUMBER, BKP.HIRE_DATE, BKP.JOB_ID, BKP.SALARY, BKP.COMMISSION_PCT, BKP.MANAGER_ID, BKP.DEPARTMENT_ID)
VALUES (EMP.EMPLOYEE_ID, EMP.FIRST_NAME,EMP.LAST_NAME, EMP.EMAIL, EMP.PHONE_NUMBER, EMP.HIRE_DATE, EMP.JOB_ID, EMP.SALARY, EMP.COMMISSION_PCT, EMP.MANAGER_ID, EMP.DEPARTMENT_ID)
WHEN NOT MATCHED BY SOURCE
DELETE;
Error at Command Line : 15 Column : 18
Error report -
SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
I am trying to delete few rows from the table -cost_mdl_ver_equip but I am getting the following error:
delete from tbcam.cost_mdl_ver_equip where mdl_ver_id = 303165
Error:
Error starting at line : 10 in command -
delete from tbcam.cost_mdl_ver_equip where mdl_ver_id = 303165
Error report -
ORA-01407: cannot update ("TBCAM"."COST_MDL_VER_EQUIP"."MDL_VER_ID") to NULL
Here is the constraints for the table:
what fix do I need to do?
I am getting error in the second script. Please explain why i am getting error in the second script.
select count(*) from LCL_SHR_IncidentIntegrationInt where
externalsystem = 'IPSOFT'
and (to_char(sysdate,'YYYYMMDDHH24MISS')-to_char(fn_adjusted_date(CREATE_DATE),'YYYYMMDDHH24MISS')) > 180;
O/P : 122797
select count(*) from LCL_SHR_IncidentIntegrationInt where
externalsystem = 'IPSOFT'
and (to_char(sysdate,'DD-MM-YYYY HH24:MI:SS')-to_char(fn_adjusted_date(CREATE_DATE),'DD-MM-YYYY HH24:MI:SS')) > 180;
O/P : ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause: The specified number was invalid.
*Action: Specify a valid number.
The first query works because Oracle is able to implicitly cast the characters as number and compare with 180. The other one doesn't because the : and - cannot be implicitly cast to number.
You should use date and time functions for such cases like timestampdiff or datediff. More functions here - https://docs.oracle.com/cd/E17952_01/refman-5.1-en/date-and-time-functions.html
I have the following SQL statement in Oracle that is giving me some headache. I am trying to return an empty geometry if the value held in the Oracle table is null however it simply fails with the following error:
The Error
*
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NullPointerException ORA-06512: at "MDSYS.SDO_UTIL", line
2421 ORA-06512: at "MDSYS.SDO_UTIL", line 2443 ORA-06512: at
"MDSYS.SDO_GEOMETRY", line 36
*
The Code
select CLUSTER_ID,
NUM_POINTS,
FEATURE_PK,
A.CELL_CENTROID.SDO_POINT.X,
A.CELL_CENTROID.SDO_POINT.Y,
A.CLUSTER_CENTROID.SDO_POINT.X,
A.CLUSTER_CENTROID.SDO_POINT.Y,
TO_CHAR (A.CLUSTER_EXTENT.GET_WKT ()),
TO_CHAR (A.CELL_GEOM.GET_WKT ()),
A.CLUSTER_EXTENT.SDO_SRID,
TPHS_PHASE_ID
from (SELECT CLUSTER_ID,
NUM_POINTS,
FEATURE_PK,
SDO_CS.transform (CLUSTER_CENTROID, 4326) cluster_centroid,
SDO_CS.TRANSFORM(NVL(CLUSTER_EXTENT, MDSYS.SDO_GEOMETRY(2001,4326 ,MDSYS.SDO_POINT_TYPE(NULL,NULL,NULL),NULL,NULL)),4326) CLUSTER_EXTENT ,
SDO_CS.transform (CELL_CENTROID, 4326) cell_centroid, CELL_GEOM FROM
V_CLUSTER_1000M) a
LEFT JOIN RWOL_TMA_ROADWORKS
ON a.FEATURE_PK = RWOL_TMA_ROADWORKS.TPHS_PHASE_ID
where sdo_filter( A.CELL_GEOM, SDO_CS.transform(mdsys.sdo_geometry(2003,4326, NULL, mdsys.sdo_elem_info_array(1,1003,3),mdsys.sdo_ordinate_array(-25.43623984375,44.257784519021, 21.62918984375, 60.752403080295)),81989)) = 'TRUE'
Anybody got any idea what is going wrong here? I am no Oracle dev so any help is appreciated as well as an explanation.
The problem here was caused by the line
TO_CHAR (A.CLUSTER_EXTENT.GET_WKT ()),
This line is attempting to get a well known text item from the returned column and because we do not supply a valid one it is failing. Strange error really.