ORA-01882: timezone region not found ORA-02063: line precediendo a DBLink - oracle

An error occurred accessing info in DataBase, the database is Oracle. I access the database from a Weblogic 12.
The last time I had the same error with timezone. I fixed using the following (like argument in Weblogic 11):
-Duser.timezone=GMT
This time I get this error:
java.sql.SQLDataException: ORA-01882: timezone region not found ORA-02063: line precediendo a DBLink
Here is the SQL:
SELECT A.DEPT, A.EMP_NAME, A.EMP_LOC, A.LAST_NAME, A.ADDRESS_1, A.ADDRESS_2, A.ADDRESS_3, A.ADDRESS_4, A.CONTROL_NUM, A.EMP_SSID, A.PEN_DATE, B.EMP_LEVEL_ACCESS, C.CONF_NUM, replace(A.EX_SALARY, ' ', '') as EX_SALARY, replace(A.EX_SAL_CODE, ' ', '') as EX_SAL_CODE, replace(A.BIRTHDATE, ' ', '') as BIRTHDATE FROM EMP_W2_INFO_TBL A, EMP_LEVEL_ACCESS_VW B, FILING_CONF_TBL C WHERE A.EMP_NUM = 'XXXXX' AND A.TAX_YEAR = '2016' AND A.EMP_NUM = B.EMP_ID AND A.TAX_YEAR = C.TAX_YEAR (+);
I validate DBLink is not corrupted checking the connectiong.

Related

How can I hardcode date into Oracle query in SSIS

I am very new to Oracle database and I am trying to hardcode the date (2020-06-30 0:00:00) into the query below, however I get the following errors
[valsys_TIMESERIES_VALUE [37]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80040E14 Description: "ORA-12801: error signaled in parallel query server P006
ORA-01821: date format not recognized
ORA-02063: preceding 2 lines from VALSYS".
An OLE DB record is available. Source: "OraOLEDB" Hresult: 0x80004005 Description: "ORA-12801: error signaled in parallel query server P006
ORA-01821: date format not recognized
ORA-02063: preceding 2 lines from VALSYS".
"SELECT TS_ID,DATE_UTC,VALUE,CASE WHEN VALUE = 0 THEN '0' ELSE TO_CHAR(VALUE) END VALUE_CONV ,SUBSTITUTE_VALUE
,CASE WHEN SUBSTITUTE_VALUE = 0 THEN '0' ELSE TO_CHAR(SUBSTITUTE_VALUE) END SUBSTITUTE_VALUE_CONV ,MANUAL_VALUE, CASE WHEN MANUAL_VALUE = 0 THEN '0' ELSE TO_CHAR(MANUAL_VALUE) END MANUAL_VALUE_CONV,FEASIBLE
,VERIFIED,APPROVED,VALID_FROM,VALID_UNTIL,LAST_EXPORT,DAY_CET,COMPUTED,MARKER,TASK_UNIT_ID FROM \""+ #[$Project::Oracle_Valsys_Schemaname] + "\".\"VALSYS_TIMESERIES_VALUE\"
WHERE VALID_FROM > to_timestamp('"+ #[User::PreLET] + "', '2020-06-30 0:00:00') "
The second parameter of to_timestamp is a format mask, e.g. 'yyyy-mm-dd hh24:mi:ss'
This is a sample usage
select
to_timestamp('2020-06-30 00:00:00', 'yyyy-mm-dd hh24:mi:ss') tst
from dual;
TST
-----------------------------
30.06.2020 00:00:00,000000000

Try to convert Time to Sec in Oracle SQL

I am trying to convert Time to Sec but whatever I try I get error message.
The following query is what I done so far
SELECT
SUM(TIME_TO_SEC(mi.Time)),
uti.Date_
FROM
users ui
LEFT JOIN project_users pui
ON(ui.UserID = pui.UserID)
LEFT JOIN user_timesheets uti
ON(ui.UserID = uti.user_id)
LEFT JOIN moments mi
ON(uti.UserTimesheetsID = mi.UserTimesheetsID)
WHERE
uti.user_id = 1 AND mi.Time != ''
AND
EXTRACT(MONTH FROM uti.Date_) = '2020-01-21'
AND
EXTRACT(YEAR FROM uti.Date_) = '2020-01-21'
AND
mi.AtestStatus = 1
GROUP BY
uti.Date_
HAVING SUM(SELECT(TIME_TO_SEC(mi.Time))) > 28800;
I get error
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 74 Column: 36
I am not sure what to use here to convert, but so far I try to use TO_CHAR and CAST
The reference link is here
REFERENCE
You refer TIME_TO_SEC function from MySQL documentation though question is marked with oracle tag. Use extract(second ...) or google oracle extract epoch equivalent, depending on what you want.
Also the expressions EXTRACT(MONTH FROM uti.Date_) = '2020-01-21' and EXTRACT(YEAR... look suspicious, returned values definitely are not of form 'YYYY-MM-DD'.

Getting error "Error parsing insert statement for table ROOT.LOAD_SQL" while using ltrim in sql loader

I trying to load the datas from data file to the database table load_sql using sql loader. I have data like below in the data file.
empid,ename
1,Raja,**Kanchi
2,Poo,**Kanchi
3,Bhasker,**Kanchi
4,Siva,**Kanchi
I have to load to load it in the load_sql table like below format:
1,Raja,Kanchi
2,Poo,Kanchi
3,Bhasker,Kanchi
4,Siva,Kanchi
I have written a control file with help of char manipulation function for inserting records in third column but im getting error:
options(skip = 1,Errors = 100, direct = True)
load data
infile 'D:\SQLLDR\control.ctl'
truncate into table load_sql
when city = 'Kanchi'
fields terminated by ','
optionally enclosed by '"'
(
empid,
ename,
X filler,
city "ltrim(:city,*)"
)
I'm getting the error like
'SQL*Loader-951: Error calling once/load initialization
ORA-02373: Error parsing insert statement for table ROOT.LOAD_SQL.
ORA-00936: missing expression'
You have some syntax errors in your control file. Try this:
options(skip = 1,Errors = 100, direct = True)
load data
infile 'D:\SQLLDR\control.ctl' <-- This doesn't look like a data file name?
truncate into table load_sql
when (city = '**Kanchi')
fields terminated by ','
optionally enclosed by '"'
(
empid,
ename,
city "ltrim(:city, '*')"
)
ltrim(:city,*)
^
|
this is invalid
Should have been
ltrim(:city, '*')
or, possibly,
replace(:city, '*', '')

How to find out the right syntax in MariaDB Error Based SQL Injection?

I am trying to inject SQL statements into a Box.
I have the following injection point:
example.com/?o=1&page=app
when I inject 1' then I receive the following error message:
DEBUG INFO: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '5' or dest like '1'') LIMIT 10' at line 1
I was trying to inject the following:
1' ORDER BY 1 --
I still get error message and I don't know how to close the statement:
DEBUG INFO: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY 1 --') and ( dest like '5' or dest like '1' ORDER BY 1 --') LIMIT 10' at line 1
What I am doing wrong?
Thanks for the answers!
Given that when you tried 1' the query included '1'' it seems that the original query is something like this:
... '5' or dest like '$o') LIMIT 10
e.g.
SELECT * FROM table WHERE (category = '5' or dest like '$o') LIMIT 10
To get this to be a valid query you'd need to close the parentheses.
So e.g. %') --, giving:
SELECT * FROM table WHERE (category = '5' or dest like '%') --') LIMIT 10
or %' OR '' = ', giving:
SELECT * FROM table WHERE (category = '5' or dest like '%' OR '' = '') LIMIT 10

Oracle - Selecting from remote database taken from PL/SQL parameter

I am creating a procedure to merge two tables across different database instances. The DB_FROM and the DB_TO are given as parameters to the procedure. Everything else is hardcoded.
PROCEDURE MERGE_TABLE_1(DB_FROM, DB_TO) AS
BEGIN
MERGE INTO TABLE_1#DB_TO DSTN
USING (SELECT * FROM TABLE_1#DB_FROM) SRC
ON (DSTN.ID = SRC.ID)
WHEN MATCHED THEN
WHEN NOT MATCHED THEN
END MERGE_TABLE_1
I get the below error when I attempt to compile
Error(1): ORA-04052: error occurred when looking up remote object
TABLE_1#DB_TO ORA-00604: error occurred at recursive SQL level 1
ORA-02019: connection description for remote database not found
Nope, it will not work that way. You cannot use variables as table names, column names or db link names in static SQL. You can achieve what you want using dynamic sql:
EXECUTE IMMEDIATE
'MERGE INTO TABLE_1#' || DB_TO || ' DSTN
USING (SELECT * FROM TABLE_1#' || DB_FROM || ') SRC
ON (DSTN.ID = SRC.ID)
WHEN MATCHED THEN
WHEN NOT MATCHED THEN ...';

Resources