Error ORA-00600 in select table in Oracle dblink - oracle

I created an Oracle Dblink to access SQLServer tables.
I can see the tables/views I have access.
But when I execute a select, it returns ORA-00600.
My dblink create command:
CREATE DATABASE LINK SQLREQUERIM CONNECT TO my_user IDENTIFIED BY "myPassword" USING 'MSSQLREQUERIM';
My tnsnames.ora file
MSSQLREQUERIM =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=myOracleHost)(PORT=1521))
(CONNECT_DATA=(SID=MSSQLREQUERIM))
(HS=OK)
)
My listener.ora file
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC=
(SID_NAME=MSSQLREQUERIM)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(PROGRAM=dg4odbc)
)
)
My odbc.ini
[ODBC Data Sources]
MSSQLREQUERIM = MSSQL Server
[MSSQLREQUERIM]
Driver=/usr/lib64/libtdsodbc.so.0
Description = MSSQL Server
Trace = No
Server = mySQLServerHost
Database = REQUERIM
Port = 60472
TDS_Version = 7.2
My iniMYSQLREQUERIM.ora file
HS_FDS_CONNECT_INFO = MSSQLREQUERIM
HS_FDS_TRACE_LEVEL = DEBUG
HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so
set ODBCINI=/etc/odbc.ini

The error was due to some table columns having types (text) that are incompatible with Oracle. Suppressing these columns the search worked.

Related

Azure Synapse Analysis: Error while accessing the external table

Failed to execute query. Error: File 'https://track2gen2storage.blob.core.windows.net/\sourcedata\sample.csv' cannot be opened because it does not exist or it is used by another process.
we performed these steps:-
create database SalesdataDemo
use salesdataDemo
-----create master key
CREATE MASTER KEY ENCRYPTION BY PASSWORD = <Password>;
SELECT *
FROM sys.symmetric_keys AS SK
WHERE SK.name = '##MS_DatabaseMasterKey##';
CREATE DATABASE SCOPED CREDENTIAL ADL_User
WITH
IDENTITY = '<client_id>#<OAuth_2.0_Token_EndPoint>',Secret = <Key>
CREATE DATABASE SCOPED CREDENTIAL adls_credential
WITH IDENTITY ='SHARED ACCESS SIGNATURE',
SECRET = <azure_storage_account_key>
CREATE EXTERNAL DATA SOURCE adlsdatasource
WITH
( LOCATION = 'https://track2gen2storage.blob.core.windows.net',
CREDENTIAL = adls_credential
) ;
CREATE EXTERNAL FILE FORMAT adls_csv
WITH (
FORMAT_TYPE = DELIMITEDTEXT,
FORMAT_OPTIONS ( FIELD_TERMINATOR = ',', STRING_DELIMITER = '"', FIRST_ROW = 2 )
);
CREATE EXTERNAL TABLE sampledata ( <ColumnName><Datatype>)
WITH (
LOCATION = '/sourcedata/sample.csv',
DATA_SOURCE = adlsdatasource,
FILE_FORMAT = adls_csv
)
select * from sampledata
I think the problem is your external table location is starting with /. Try changing it to:
CREATE EXTERNAL TABLE sampledata ( <ColumnName><Datatype>)
WITH (
LOCATION = 'sourcedata/sample.csv',
DATA_SOURCE = adlsdatasource,
FILE_FORMAT = adls_csv
)
Here is the document you can also take a look for reference:
https://learn.microsoft.com/en-us/azure/synapse-analytics/sql/create-use-external-tables
One more question, why do you need database scoped credential named ADL_User?

Query failing on Oracle 12c and 18c when changing NLS_SORT to BINARY_CI

I have the following query which correctly returns records when I execute it via code or Oracle SQL Developer.
SELECT TABLE_T.COL_P,
1234 AS COL_C,
TABLE_T.COL_D,
SUM(SOME_COLUMN) Value
FROM TABLE_T
INNER JOIN TABLE_E E ON TABLE_T.COL_P = E.COL_P
AND TABLE_T.COL_C = E.COL_C
AND TABLE_T.COL_CC = E.COL_CC
AND TABLE_T.COL_CL = E.COL_CL
INNER JOIN TABLE_C C1 ON C1.COL_P = E.COL_P
AND C1.COL_C = E.COL_C
INNER JOIN TABLE_C C2 ON C2.COL_P = C1.COL_P
AND C2.COL_CX = C1.COL_CX
AND C2.COL_CY = C1.COL_CY
AND C2.COL_CZ = C1.COL_CZ
WHERE TABLE_T.COL_P = 'Some Text'
AND C2.COL_C = 1234
AND TABLE_T.COL_CL IN
(SELECT COL_CL
FROM TABLE_CL
WHERE COL_P = 'Some Text'
AND ((COL_CLTYPE = 'VALUE_A')
OR (COL_CLTYPE = 'VALUE_B')
OR (COL_CLTYPE = 'VALUE_C')
OR (COL_CLTYPE = 'VALUE_D')) )
GROUP BY TABLE_T.COL_P,
TABLE_T.COL_D
However, it fails to return records once I execute the following session commands:
ALTER SESSION SET NLS_COMP = LINGUISTIC;
ALTER SESSION SET NLS_SORT = BINARY_CI;
This problem only occurs when I'm running against an Oracle 12c or 18c database.
It works find with/without the session commands when running against an Oracle 12C R2 or 11g database.
I've already checked the Explain Plan for 12c/18c and 12cR2 and its creating the same plan.
I found out that by adding an ORDER BY clause to the query (ORDER BY TABLE_T.COL_D, it resolves the problem.
Any ideas on what might be causing this problem?
I know the ORDER BY solution works, but I'd like to know what the underlying cause is and if there's a better solution to it.

Error ORA-12154 in Oracle Data Integrator

I get the error when I run a mapping.
I've created a "New Data Server"
I can successfully test the connection by clicking on "Test Connection" button.
But the mapping cannot be run successfully. The full error message is below:
ODI-1228: Task Merge rows-IKM Oracle Merge-Load USERS fails on the target connection DB-TARGET.
Caused By: java.sql.SQLException: ORA-12154: TNS:невозможно разрешить заданный идентификатор соединения
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:495)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:447)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1055)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:624)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:253)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:613)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:214)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:38)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:891)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1194)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1835)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1790)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:301)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:205)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:142)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:28)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:52)
at oracle.odi.runtime.agent.execution.SessionTask.processTask(SessionTask.java:206)
at oracle.odi.runtime.agent.execution.SessionTask.doExecuteTask(SessionTask.java:117)
at oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:886)
at oracle.odi.runtime.agent.execution.SessionExecutor$SerialTrain.runTasks(SessionExecutor.java:2225)
at oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:610)
at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$1.doAction(TaskExecutorAgentRequestProcessor.java:718)
at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$1.doAction(TaskExecutorAgentRequestProcessor.java:611)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203)
at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$1400(StartSessRequestProcessor.java:74)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:702)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180)
at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:108)
at java.lang.Thread.run(Thread.java:748)
Caused by: Error : 12154, Position : 154, Sql =
MERGE
INTO TARGET.USERS USERS
USING
(
SELECT
USE.NAME AS NAME ,
USE.PASSWD AS PASSWD ,
USE.USER_ROLE AS USER_ROLE
FROM
**SOURCE.USERS#"MySource" USE**
) MERGE_SUBQUERY
ON
(
USERS.NAME = MERGE_SUBQUERY.NAME
)
WHEN NOT MATCHED THEN
INSERT
(
NAME ,
PASSWD ,
USER_ROLE
)
VALUES
(
MERGE_SUBQUERY.NAME ,
MERGE_SUBQUERY.PASSWD ,
MERGE_SUBQUERY.USER_ROLE
)
WHEN MATCHED THEN
UPDATE SET
PASSWD = MERGE_SUBQUERY.PASSWD ,
USER_ROLE = MERGE_SUBQUERY.USER_ROLE , OriginalSql =
MERGE
INTO TARGET.USERS USERS
USING
(
SELECT
USE.NAME AS NAME ,
USE.PASSWD AS PASSWD ,
USE.USER_ROLE AS USER_ROLE
FROM
SOURCE.USERS#"MySource" USE
) MERGE_SUBQUERY
ON
(
USERS.NAME = MERGE_SUBQUERY.NAME
)
WHEN NOT MATCHED THEN
INSERT
(
NAME ,
PASSWD ,
USER_ROLE
)
VALUES
(
MERGE_SUBQUERY.NAME ,
MERGE_SUBQUERY.PASSWD ,
MERGE_SUBQUERY.USER_ROLE
)
WHEN MATCHED THEN
UPDATE SET
PASSWD = MERGE_SUBQUERY.PASSWD ,
USER_ROLE = MERGE_SUBQUERY.USER_ROLE , Error Msg = ORA-12154: TNS:невозможно разрешить заданный идентификатор соединения
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:499)
... 30 more
Don't be confused with russian description of the error ORA-12154.
It means TNS:could not resolve the connect identifier specified.
tnsnames.ora file exists. I can also connect using SQL Developer
After some investigation it seems to me that the line
SOURCE.USERS#"MySource" USE
is the culprit
But before this script was executed ODI executed another script and executed it successfully. Below are its contents:
create database link "MySource" connect to SOURCE identified by <#=odiRef.getInfo("SRC_PASS") #> using '***'
I ran both queries in SQL Developer and replaced <#=odiRef.getInfo("SRC_PASS") #> with the real value.
I could reproduce the error.
I ran the query below to be sure that the dblink had been created:
select * from all_db_links;
Then I ran against a discussion where someone suggested to create dblinks in this way:
create database link "MySource" connect to SOURCE identified by *** using
'(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle.****.***.**)
)
)';
It worked. I could use this link in the subsequent queries. But I noticed that a shorter way was to create a dblink by using SID only:
create database link "MySource" connect to SOURCE identified by *** using oracle;
So I switched to ODI and changed the connection strings used in all the data servers from jdbc:oracle:thin:#<host>:<port>/<service name> to the format jdbc:oracle:thin:#<host>:<port>:<sid>
This resolved the isssue. I could run the mapping successfully.
Not sure why a dblink that is created based on service name cannot be used.
Oracle doesn't forbid it according to the docu
CREATE DATABASE LINK:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5005.htm

Application unable to access table created in oracle database

Fetching data through a python application from a table throws me this error:
cx_Oracle.DatabaseError: ORA-00942: table or view does not exist. I have verified the schema and table name.
cur = cursor.execute('SELECT * FROM SYS.STUDENT_RECORDS')
However, the application fetches data from the system table.
cur = cursor.execute("SELECT * FROM TAB_STATS$ WHERE ROWNUM <= 10")
Here is the connection string:
dsn_tns = cx_Oracle.makedsn(ip, port, SID)
connection = cx_Oracle.connect(user='username', password='****',dsn=dsn_tns)
I am assuming it has got to do something with the user permission, but not quite getting it right. I don't have much experience with Oracle DB. Any help would be highly appreciated.
#kaushik #krokodilko, your guidance helped me arrive at the following solution:
Created new user and granted privileges.
Changed connection string to use service name instead of SID.(don't know why SID didn't work though)
dsn_tns = cx_Oracle.makedsn(ip, port, service_name=service_name)
cur = cursor.execute("SELECT * FROM user1.STUDENT_PROFILES WHERE ROWNUM <= 10")

Why a select query is running slower in Oracle than sql server

I am reading data from Oracle database by using ODP.Net with the follwing code
OracleConnection con = new OracleConnection(connectionString);
OracleCommand cmd = new OracleCommand( SELECT ID,RECORD(XMLType) FROM tbl_Name, con);
con.Open();
OracleDataReader _dataReader = cmd.ExecuteReader();
while (_dataReader.Read())
{
string rowId = _dataReader[0].ToString();
string xmlString = _dataReader[1].ToString();
adding this data into Queue for further processing
}
It working fine but in a minute it's reading only 10000 record. If I use SqlServer database it's reading 500000 record in minute having table with same schema.
Please help me if I am missing something to read data faster using ODP.NET
Thank you.
**
ANSWER:
**
I have tried with GetClobVal() and GetString Val() functions, now it is working fine.
select t.RECID, t.XMLRECORD.GetClobVal() from tableName t"
select x.RECID,x.XMLRECORD.getStringVal() from tableName x"
If we use these queries with oracle command it will run fast, but not as fast as sql server query.

Resources