I am trying to get the current Hour in local timezone in esql for a requirement by the command:
set throttle_time = EXTRACT(HOUR FROM LOCAL_TIMEZONE);
But it gives me an exception which is given as below:
ExceptionList
RecoverableException
File:CHARACTER:F:\build\slot1\S000_P\src\DataFlowEngine\MessageServices\ImbDataFlowNode.cpp
Line:INTEGER:1153
Function:CHARACTER:ImbDataFlowNode::createExceptionList
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:SiebelTOSPOSRequestHandler#FCMComposite_1_7
Label:CHARACTER:SiebelTOSPOSRequestHandler.Compute1
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Node throwing exception
RecoverableException
File:CHARACTER:F:\build\slot1\S000_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp
Line:INTEGER:666
Function:CHARACTER:SqlStatementGroup::execute
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2488
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:.SiebelTOSPOSRequestHandler_counternode.Main
Insert
Type:INTEGER:5
Text:CHARACTER:6.3
Insert
Type:INTEGER:5
Text:CHARACTER:SET throttle_time = CAST(EXTRACT(HOUR FROM LOCAL_TIMEZONE) AS CHARACTER);
RecoverableException
File:CHARACTER:F:\build\slot1\S000_P\src\DataFlowEngine\ImbRdl\ImbRdlDateTimeFunctions.cpp
Line:INTEGER:503
Function:CHARACTER:ExtractFnCall::extractHour
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2477
Text:CHARACTER:Cannot extract %3 field from value %4
Insert
Type:INTEGER:5
Text:CHARACTER:.SiebelTOSPOSRequestHandler_counternode.Main
Insert
Type:INTEGER:5
Text:CHARACTER:6.28
Insert
Type:INTEGER:5
Text:CHARACTER:HOUR
Insert
Type:INTEGER:5
Text:CHARACTER:INTERVAL '360' MINUTE
Please if anybody could help me, I would be thankful.
Regards
You say you want "the current Hour in local timezone".
LOCAL_TIMEZONE does not return anything containing what you want. Carefully read this article for an explanation. Also, as a simple experiment, run "SET Environment.temp = LOCAL_TIMEZONE;" then look at what the resulting value and data type of Environment.temp is.
Instead, use CURRENT_TIMESTAMP.
Related
I was wondering if it was possible to update more than 1 row with a procedure, im not sure why this one isnt working. Its working only if theres only 1 row in my table. But if there's more than 1 row i get the usual error message :
ORA-01422: exact fetch returns more than requested number of rows
I'm honestly not sure why this isnt working. Is it possible a procedure cannot update more than 1 row at once ?
create or replace procedure TP3_SP_ARCHIVER_ENCAN
is
V_CURRENT_DATE date;
V_DATE_ENCAN date;
begin
select sysdate, DATE_FIN_ENC into V_CURRENT_DATE, V_DATE_ENCAN
from
TP2_ENCAN;
update TP2_ENCAN
set EST_ARCHIVEE_ENC = 1,
STATUT_ENC = 'Archivé'
where V_CURRENT_DATE - V_DATE_ENCAN > 60;
end TP3_SP_ARCHIVER_ENCAN;
/
I'm excepting to archive every ENCAN that has been closed for a duration of 60+ days. everytime i run this procedure i just want to update those.
Full error message :
Error report -
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "C##JALAC144.TP3_SP_ARCHIVER_ENCAN", line 8
ORA-06512: at line 1
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
This line is your problem:
select sysdate, DATE_FIN_ENC into V_CURRENT_DATE, V_DATE_ENCAN from TP2_ENCAN;
You are selecting DATE_FIN_ENC into a scalar variable that can hold exactly one value. You can select "1" into "x". You can't select "1" and "2" into "x" at the same time. So you get the error you're getting.
If I understand your problem correctly, you probably want this, with no initial select:
update TP2_ENCAN
set EST_ARCHIVEE_ENC = 1,
STATUT_ENC = 'Archivé'
where SYSDATE - DATE_FIN_ENC > 60;
Via your code you just want to update record base on current date. Therefore, you do not need to use parameter. Using the update script is enough.
Create or replace procedure TP3_SP_ARCHIVER_ENCAN is:
begin
update TP2_ENCAN
set EST_ARCHIVEE_ENC = 1,
STATUT_ENC = 'Archivé'
where sysdate - DATE_FIN_ENC > 60;
end
TP3_SP_ARCHIVER_ENCAN;
I'm trying to create MView in orcale bat it raise error. I don't know why or how to fix this.
it is my code
CREATE MATERIALIZED VIEW MAKT REFRESH FAST ON DEMAND
WITH ROWID
START WITH TO_DATE('03-11-2018 01:00:00', 'DD-MM-YYYY HH24:MI:SS') NEXT TRUNC(SYSDATE+12/24,'HH')
AS
SELECT "MAKT"."MANDT" "MANDT",
"MAKT"."MATNR" "MATNR",
"MAKT"."SPRAS" "SPRAS",
"MAKT"."MAKTX" "MAKTX"
FROM "MAKT"#"PE2.ABC.COM.VN" "MAKT"
WHERE "MAKT"."MANDT" = '300';
It gives error
ora-22060 :argument is an invalid or uninitialized number ora-06512
:ora-06512 at sys.dbms_snapshot line 1613 ora-06512 : at line 1
please help me.
I have the following query that I am using in Oracle 11g
IF EXISTS (SELECT * FROM EMPLOYEE_MASTER WHERE EMPID='ABCD32643')
THEN
update EMPLOYEE_MASTER set EMPID='A62352',EMPNAME='JOHN DOE',EMPTYPE='1' where EMPID='ABCD32643' ;
ELSE
insert into EMPLOYEE_MASTER(EMPID,EMPNAME,EMPTYPE) values('A62352','JOHN DOE','1') ;
END IF;
On running the statement I get the following output:
Error starting at line : 4 in command -
ELSE
Error report -
Unknown Command
1 row inserted.
Error starting at line : 6 in command -
END IF
Error report -
Unknown Command
The values get inserted with error when I run it directly. But when I try to execute this query through my application I get an oracle exception because of the error generated :
ORA-00900: invalid SQL statement
And hence the values are not inserted.
I am relatively new to Oracle. Please advise on what's wrong with the above query so that I could run this query error free.
If MERGE doesn't work for you, try the following:
begin
update EMPLOYEE_MASTER set EMPID='A62352',EMPNAME='JOHN DOE',EMPTYPE='1'
where EMPID='ABCD32643' ;
if SQL%ROWCOUNT=0 then
insert into EMPLOYEE_MASTER(EMPID,EMPNAME,EMPTYPE)
values('A62352','JOHN DOE','1') ;
end if;
end;
Here you you the update on spec, then check whether or not you found a matching row, and insert in case you didn't.
"what's wrong with the above query "
What's wrong with the query is that it is not a query (SQL). It should be a program snippet (PL/SQL) but it isn't written as PL/SQL block, framed by BEGIN and END; keywords.
But turning it into an anonymous PL/SQL block won't help. Oracle PL/SQL does not support IF EXISTS (select ... syntax.
Fortunately Oracle SQL does support MERGE statement which does the same thing as your code, with less typing.
merge into EMPLOYEE_MASTER em
using ( select 'A62352' as empid,
'JOHN DOE' as empname,
'1' as emptype
from dual ) q
on (q.empid = em.empid)
when not matched then
insert (EMPID,EMPNAME,EMPTYPE)
values (q.empid, q.empname, q.emptype)
when matched then
update
set em.empname = q.empname, em.emptype = q.emptype
/
Except that you're trying to update empid as well. That's not supported in MERGE. Why would you want to change the primary key?
"Does this query need me to add values to all columns in the table? "
The INSERT can have all the columns in the table. The UPDATE cannot change the columns used in the ON clause (usually the primary key) because that's a limitation of the way MERGE works. I think it's the same key preservation mechanism we see when updating views. Find out more.
enter code hereI am facing an issue when reading the oracle logs through time interval.
Issue:
In oracle , while data is getting inserted through some external application, If I am using log miner to read the oracle logs, It gives me duplicate records.
For example, suppose if there is a time interval t1,t2,t3.
Data is inserted from t1 to t3.
Meanwhile If I am using log miner to read the data from t1 to t2 and then t2 to t3. Then there are some records which are coming in both the intervals.
One observation :Records which are showing duplicates are at the end of first interval and at the beginning for second interval.
Queries which I am using:
begin dbms_logmnr.start_logmnr(STARTTIME => t1,ENDTIME =>t2,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + DBMS_LOGMNR.COMMITTED_DATA_ONLY);end;
select sql_redo from V$LOGMNR_CONTENTS WHERE OPERATION IN('INSERT','UPDATE','DELETE') and table_name = xyz
begin dbms_logmnr.start_logmnr(STARTTIME => t2,ENDTIME =>t3,OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG + DBMS_LOGMNR.CONTINUOUS_MINE + DBMS_LOGMNR.COMMITTED_DATA_ONLY);end;
select sql_redo from V$LOGMNR_CONTENTS WHERE OPERATION IN('INSERT','UPDATE','DELETE') and table_name = xyz
Date format which I am using to start miner: DD-MON-YYYY HH24:MI:SS
Note:Data is being committed as soon as it is getting inserted.
Accoring to oracle documentation , in logminr, start time will be used as greater then or equal to , and end time will be used as less then or equal to. So logmnr is designed in this way.
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.