Skip to Main Content

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Sam.

Asked: August 08, 2016 - 12:09 pm UTC

Last updated: August 09, 2016 - 4:17 pm UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi!, I am trying to query a mysql database from oracle. I have configured everything and everything is working fine but when i query any table of mysql database from oracle, i dont get the columns having number data type.
In hs file i have follwing configurations

# This is a sample agent init file that contains the HS parameters that are
# needed for the Database Gateway for ODBC

#
# HS init parameters
#
HS_FDS_CONNECT_INFO = redemail
HS_FDS_TRACE_LEVEL = 255
HS_FDS_TRACE_FILE_NAME = /export/home/oracle/app/hsodbcsql.trc
HS_FDS_SHAREABLE_NAME = /export/home/oracle/app/unixodbc-2.2.14/lib/libodbc.so
HS_FDS_SUPPORT_STATISTICS = FALSE
HS_FDS_FETCH_ROWS = 100
HS_LONG_PIECE_TRANSFER_SIZE = 1048576
HS_LANGUAGE=AL32UTF8
HS_NLS_NCHAR=UCS2
HS_FDS_REMOTE_DB_CHARSET=AL32UTF8
HS_KEEP_REMOTE_COLUMN_SIZE=LOCAL
HS_FDS_SQLLEN_INTERPRETATION=32


#
# Environment variables required for the non-Oracle system
#
#set <envvar>=<value>

The structure of my table in mysql is :

create table emp (id int,
name varchar(255),
address longtest);

Now when i query from oracle sql plus,

desc emp@mysql;


it displays
name null type
name nvarchar2(255)
address long


and i also want to create emp table in e in oracle which has same structure

so i executed

create table emp1 as select * from emp@mysql;

ERROR at line 1:
ORA-00997: illegal use of LONG datatype






and Chris said...

If a source data type maps to an unsupported type in Oracle, then its information is not returned to Oracle!

http://docs.oracle.com/cd/E11882_01/gateways.112/e12070.pdf

See page A-2 for the conversions. I would have thought int in MySQL would have a valid mapping. But I'm not familiar enough to be sure. Check with support.

The problem with your CTAS is Longtext is mapping to long! This data type is deprecated and subject to a number of restrictions, including:

SELECT lists of CREATE TABLE ... AS SELECT statements
SELECT lists in subqueries in INSERT statements


https://docs.oracle.com/cd/B28359_01/server.111/b28286/sql_elements001.htm#SQLRF00201

So you'll need to create the table manually. And build a process to convert the data.

Is this answer out of date? If it is, please let us know via a Comment