INSERT to Oracle table from SQL Server database link - sql-server

I have created a database link to SQL Server 2012 database in Oracle 11gR2 using the Oracle Gateway for SQL Server. The connection is working fine and I am able to run queries and stored procedure from SQL Server.
The problem arises when I try to retrieve an XML column from SQL Server. Oracle documents clearly states that if database is in UTF character set (AL32UTF8), XML is supported, but in LONG datatype format.
I am able to query the XML column by
SET LONG 5000;
select "XMLColumn" FROM "xmltable"#sqlserver;
but while trying to insert this into an oracle table with Long datatype it gives the following error.
SQL Error: ORA-00997: illegal use of LONG datatype
Is there any workaround for this problem.
I even tried to convert the incoming XML to CLOB as suggested by Sanders, which perfectly makes sense. But somehow that too throws back the same error. In below query Name is obviously the XML column from SQL Server.
CREATE TABLE TEMPCLOB
AS
SELECT TO_LOB("Name") AS "Name" FROM "xmldata"#sqlserver;

LONG is deprecated datatype in Oracle. You can spend time to this problem, but I'd advice you to convert it immediately into CLOB or XMLTYPE and have no problem at all.

Related

Having trouble evaluating Oracle rowidtochar() field to SQL Server nvarchar(18) field during SSIS load

Looking for some much needed guidance. My ultimate goal is to incrementally load data from Oracle source database into a SQL Server database based on OBJID column which is case sensitive.
The current SSIS data flow task imports from an Oracle database via ADO.NET connection and loads it to a SQL Server database using a SQL query (shown below). The source Oracle data contains a unique 'OBJID' column, which originates as ROWID data type in Oracle. The SQL statement used to extract the data from Oracle uses the ROWIDTOCHAR() function to convert the OBJID column for SQL Server. The OBJID column is of type NVARCHAR (Latin1_General_CS_AS) in the SQL Server target database.
Unfortunately, I have do not have Created_Date or Modified_Date in my source data to use for incremental loading.
So far, I created a single-row SQL Task in SSIS to select the OBJID currently loaded in target db. The result set is written to a string Variable, which I wrote into the source SQL.
select objid
from dbo.target
However, the ADO.NET source query does not seem to pick up on OBJID variable in the where statement.
SELECT
account_date, emp_id, rowidtochar(objid) as objid
FROM
oracle.source
WHERE
rowidtochar(objid) <> CAST('"+ #[User::OBJIDSTG]+"' AS VARCHAR2 (18))
I also altered the SQL query by removing CAST() but got the same results.
Has anyone out there attempted this before? I'm thinking my problem lies in the data types but I'm not sure where to go from here.

SQL Server JBDC DATE gets wrong metadata result type

I have a strange problem:
When i create a column in SQL Server 2008, JDBC Driver 2.0, sqljdbc4.jar with Java 1.6
create table ctypes (dbms_date DATE NOT NULL, dbms_date_null DATE)
The data type in the database is correctly date
But when I access the table with JDBC select
The metadata says that the type is nvarchar, still the getDate() function is working.
The problem is that I am programming a framework that generically copies data and must rely on the data type.
I am not a big SQL Server specialist, so maybe it some configuration in the SQL Server server that is responsible, I left as much to the default values as possible.
The problem is fixed by downloading Driver 3.0

Converting FoxPro Date type to SQL Server 2005 DateTime using SSIS

When using SSIS in SQL Server 2005 to convert a FoxPro database to a SQL Server database, if the given FoxPro database has a date type, SSIS assumes it is an integer type. The only way to convert it to a dateTime type is to manually select this type. However, that is not practical to do for over 100 tables.
Thus, I have been using a workaround in which I use DTS on SQL Server 2000 which converts it to a smallDateTime, then make a backup, then a restore into SQL Server 2005.
This workaround is starting to be a little annoying.
So, my question is: Is there anyway to setup SSIS so that whenever it encounters a date type to automatically assume it should be converted to a dateTime in SQL Server and apply that rule across the board?
Update
To be specific, if I use the import/export wizard in SSIS, I get the following error:
Column information for the source and the destination data could not be retrieved, or the data types of source columns were not mapped correctly to those available on the destination provider.
Followed by a list of a given table's date columns.
If I manually set each one to a dateTime, it imports fine.
But I do not wish to do this for a hundred tables.
You could make a small FoxPro program that will loop through your list of tables and write out a SQL INSERT INTO statement for each record to a .sql file which you could then open from or paste into SQL Management Studio and execute. You could then control the date formats that will work with SQL Server's date type fields.
Something similar could be done in c#.

Error: ORA-28500:[Oracle][ODBC SQL Server Driver]String data, right truncation

We are trying to connect to Sql Server 2005 via Oracle 11gR2 gateway and when we query a view that gets data from Sql Server , we get this error :
Error: ORA-28500:[Oracle][ODBC SQL Server Driver]String data, right truncation
I have commented out some columns in the query running at Oracle, and it worked. The commented columns are in data type of VARHCAR(30), but there are other fields which are VARCHAR(30) too.
Is there any workaround for this error, if I add these 3 columns that fail the whole query, everything will be O.K., I tried to rename these fields at the view running at Sql Server 2005 which is the data source, no result.
Both ODBC and SQL Server drivers are installed, we are using the SQL Server driver,"dg4msql".
Oracle charset is AL32UTF8.
The most likely cause of this is that these column contain characters that Oracle will use more than one byte to store. The gateways sees that the column is defined in SQL Server as VARCHAR(30) and so it makes a VARCHAR2(30) column in Oracle, however (30) here is 30 bytes not 30 characters, so you can get truncation of the data if the total number of bytes Oracle wants to use is more than 30. (i.e. You have 30 characters in SQL Server but one of then requires 2 bytes in Oracle and so the length is now 31 so therefore too big).
As a workaround, change the VARCHAR(30) columns in the SQL Server to NVARCHAR(30) - the gateway will then know that it might get mutli-byte characters and translate the column definition as NVARCHAR and allow the inserts.
See the Gateway Data Type Conversion Table for 11gR2 for more information on how the columns will eb translated.

SSIS MYSQL to SQL Datatype

I'm trying to copy data from MySQL to SQL Server 2008.
My SSIS is generating error for time (DBTime) column in MySQL database. (cannot convert dbtime to dbtime2)
What datatype can i use in SQL server for time? I tired nvarchar, varchar and also tried data conversion task but i get same error.
You could use time or datetime.
EDIT:
Now that I see the type of data that MySQL uses for time what you probably want to do is to put the data into an nvarchar on the SQL Server side, and in SSIS you can invoke
TIME_FORMAT(timecol, '%H:%i:%S')
The SSIS tool lets you do specifications of how to manipulate individual columns before inserting into the other database using scripting.

Resources