Lock sql server table through DG4ODBC?
Hi
I'm using DG4ODBC to connect to SQL server 2008, querying data and insert to Oracle. Is it possible to lock the remote table in sql server, prohibit it from inserting any new record?
My Oracle version is 11.1.0.7.0, OS version : Red Hat Enterprise Linux Server release 5.3.
Thanks
Edited by: user1152556 on 21:20 06-05-2013
by default the gateway starts its own transaction on the SQL Server side and as soon as you even execute a select it locks the data until you execute a commit (even when only selecting data). Unfortunately the amount of data being locked now depends on the SQL Server version and on the lock mode chosen by the SQl Server (row/page/table).
Another option would be to explicit set a transaction isolation level for your gateway session using the passthrough command:
DECLARE
ret integer;
c integer;
BEGIN
c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB;
DBMS_HS_PASSTHROUGH.PARSE@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c, 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
ret := DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c);
dbms_output.put_line(ret ||' passthrough output');
DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@MSODBCSQLSERVER_DG4ODBC_EMGTW_1123_DB(c);
END;
Please check out your SQL Server documentation which isolation level will fit for your needs.
- Klaus
Similar Messages
-
I know I've REALLY struggled with this before. I just don't understand why this has to be soooooo difficult.
I can very easily do a straight Data Pump of a .xlsX File into a SQL Server Table using a normal Excel Connection and a normal Excel Source...simply converting Unicode to DT_STR and then using an OLE DB Destination of the SQL Server Table.
If I want to make the SSIS Package a little more flexible by allowing multiple .xlsX spreadsheets to be pumped in by using a Foreach Loop Container, the whole SSIS Package seems to go to hell in a hand basket. I simply do the following...
Put the Data Flow Task within the Foreach Loop Container
Add the Variable Mapping Variable User::FilePath that I defined as a Variable and a string within the FOreach Loop Container
I change the Excel Connection and its Expression to be ExcelFilePath ==> @[User::FilePath]
I then try and change the Excel Source and its Data Access Mode to Table Name or view name variable and provide the Variable Name User::FilePath
And that's when I run into trouble...
Exception from HRESULT: 0xC02020E8
Error at Data Flow Task [Excel Source [56]]:SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occured. Error code: 0x80004005.
Error at Data Flow Task [Excel Source [56]]: Opening a rowset for "...(the EXACT Path and .xlsx File Name)...". Check that the object exists in the database. (And I know it's there!!!)
I don't understand by adding a Foreach Loop Container to try and make this as efficient as possible has caused such an error unless I'm overlooking something. I have even tried delaying my validations and that doesn't seem to help.
I have looked hard in Google and even YouTube to try and find a solution for this but for the life of me I cannot seem to find anything on pumping a .xlsX file into SQL Server using a Foreach Loop Container.
Can ANYONE please help me out here? I'm at the end of my rope trying to get this to work. I think the last time I was in this quandry, trying to pump a .xlsX File into a SQL Server Table using a Foreach Loop Container in SSIS, I actually wrote a C# Script
to write the contents of the .xlsX File into a .csv File and then Actually used the .csv File to pump the data into a SQL Server Table.
Thanks for your review and am hoping and praying for a reply and solution.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Data Pump .xlsx into a SQL Server Table and the whole 32-Bit, 64-Bit discussion
First of all...I have a headache!
Found LOTS of Google hits when trying to data pump a .xlsx File into a SQL Server Table. And the whole discussion of the Microsoft ACE 64-Bit Driver or the Microsoft Jet 32-Bit Driver.
Specifically receiving this error...
An OLE DB record is available. Source: "Microsoft Office Access Database Engine" Hresult: 0x80004005 Description: "External table is not in the expected format.".
Error: 0xC020801C at Data Flow Task to Load Alere Coaching Enrolled, Excel Source [56]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel Connection Manager"
failed with error code 0xC0202009.
Strangely enough, if I simply data pump ONE .xlsx File into a SQL Server Table utilizing my SSIS Package, it seems to work fine. If instead I am trying to be pro-active and allowing for multiple .xlsx Files by using a Foreach Loop Container and a variable
@[User::FileName], it's erroring out...but not really because it is indeed storing the rows onto the SQL Server Table. I did check all my Delay
Why does this have to be sooooooo difficult???
Can anyone help me out here in trying to set-up a SSIS Package in a rather constrictive environment to pump a .xlsx File into a SQL Server Table? What in God's name am I doing wrong? Or is all this a misnomer? But if it's working how do I disable the error
so that is stops erroring out?Hi ITBobbyP,
According to your description, when you import data of .xlsx file to SQL Server database, you got the error message.
The error can be caused by the following reasons:
The excel file is locked by other processes. Please kindly resave this file and name it to other file name to see if the issue will be fixed.
The ACE(Access Database Engine) is not up to date as Vaibhav mentioned. Please download the latest ACE and install it from the link:
https://www.microsoft.com/en-us/download/details.aspx?id=13255.
The version of OFFICE and server bitness is not the same. To solve the problem, please refer to the following document:
http://hrvoje.piasevoli.com/2010/09/01/importing-data-from-64-bit-excel-in-ssis/
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Create material Master by connecting SAP Tables to SQL server tables
We would like to use data in SQL server tables to upload material master into ECC. We have a number of rules embedded into the SQL server tables and would like that the LSMW program should pick up records directly from the SQL table without passing through a flat file format. Can anyone guide us how to accomplish this. We are on SAP AFS ECC 5.0 Thanks in advance
Is anyone having any ideas on this ...?
-
Export SQL Server Table into Multiple Sheets in Excel
I'm trying to understand the example here.
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
Basically, I'm up to step #5.
5. Data Flow Task to populate the created sheet with data for that subject. The Data Flow looks like below
I don't understand this part. Has anyone worked with this sample before? Has anyone gotten this to work? I'm trying to learn SSIS better, but I'm finding it hard to get started with this stuff. I guess if I get a couple projects under
my belt, I'll be fine. The hardest part is getting started.
If anyone feels really ambitions today, maybe you can assist me with two other projects as well.
#1)
http://visakhm.blogspot.in/2011/12/simulating-file-watcher-task-in-ssis.html
#2)
http://sqlage.blogspot.in/2013/12/ssis-read-multiple-sheets-from-excel.html
http://beyondrelational.com/modules/24/syndicated/398/Posts/18163/ssis-how-to-loop-through-multiple-excel-sheets-and-load-them-into-a-sql-table.aspx
I'd greatly appreciate any help I can get with this.
Thanks!!
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Hi Ryguy72,
The solution introduced in Visakh’s blog does work. I have written the detailed steps for you:
1. Create an Excel file (Des.xls) as the destination file, rename the Sheet1 to “Excel Destination”, and add four columns: ID, Name, Subject, and Marks.
2. Create an Object type variable Subject, a String type variable SheetName, and a String type variable WorkSheetQuery.
3. Set the value of variable SheetName to “Excel Destination$”, and set the expression of variable WorkSheetQuery to:
"CREATE TABLE `" + @[User::SheetName] + "` (
`ID` Long,
`Name` LongText,
`Subject` LongText,
`Marks` Long
4. In the Execute SQL Task outside the Foreach Loop Container, set its General tab as follows:
ResultSet: Full result set
ConnectionType: OLE DB
Connection: LocalHost.TestDB (e.g. an OLE DB Connection to the source SQL Server table)
SQLSourceType: Direct input
SQLStatement: SELECT DISTINCT [Subject] FROM [TestDB].[dbo].[DynamicExcelSheetDemo]
5. In the Result Set tab of this Execute SQL Task, map result “0” to variable “User::Subject”.
6. In the Collection page of the Foreach Loop Container, set the Enumerator option to “Foreach ADO Enumerator”, and set the “ADO object source variable” to “User::Subject”.
7. In the Variable Mapping page of the container, map variable “User::SheetName” to index “0”.
8. Create an OLE DB Connection Manager to connect to the destination Excel file. Choose the provider as Native OLE DB\Microsoft Jet 4.0 OLE DB Provider, specify the fully qualified path of the Excel file (such as C:\Temp\Des.xls), and set the Extended Properties
option of the Connection Manager to “Excel 8.0”. Click “Test Connection” button to make sure the connection is established successfully.
9. Set the General page of the Execute SQL Task inside the container as follows:
ResultSet: None
ConnectionType: OLE DB
Connection: Des (e.g. the OLE DB Connection to the destination Excel file we create above)
SQLSourceType: Variable
SQLStatement: User::WorkSheetQuery
10. In the Data Flow Task, add an OLE DB Source component, set the connection manager to “LocalHost.TestDB”, set “Data access mode” to “SQL command”, and set the “SQL command text” to:
SELECT * FROM [TestDB].[dbo].[DynamicExcelSheetDemo] WHERE [Subject]=?
11. Click the “Parameters…” button, and map Parameter0 to variable “User::SheetName”.
12. Add an Excel Destination component, setup an Excel Connection Manager to the destination Excel file, set the data access mode to “Table name or view name variable”, and select variable name as “User::SheetName”. In this way, the OLE DB Provider can get
the Excel metadata and enable us to finish the column mappings correctly.
13. Since the Microsoft Jet 4.0 has only 32-bit driver, please make sure to set the Run64BitRuntime property of the IS project to False.
In addition, please note that there will be one useless worksheets “Excel Destination” in the Excel file. We can remove them manually or use a Script Task to delete this worksheet programmatically (need to install .NET Programmability Support feature during
Office installing).
Regards,
Mike Yin
TechNet Community Support -
Not able to select MS SQL Server tables in sqldeveloper using dblink
Hi All,
I able tp select MS SQL table columns in sqlplus prompt but i am not able to select same thing in sql developer using dblink.
If i use convert(<mycol>,'WE8ISO8859P1','utf8') in sqldeveloper its working, how to select MS SQL columns without convert function.
Thanks,
-ManiMani,
This is a problem with SQL*Developer and converting nvarchar characters.
The workround is to install the Oracle client software and use the option in SQL*Developer -
- Tools
- Preferences
- Database
- Advanced
- and click the 'Use OCI/Thick driver' option.
I made these steps -
- download the 11.1 client software from eDelivery -
http://edelivery.oracle.com/
- go through the administration screens (name, etc)
- on the next screen ' Media Pack Search' screen choose -
- Select a Product Pack - Oracle database
- Platform - Microsoft Windows (32-bit)
- Oracle® Database 11g Release 1 (11.1.0.6.0) Media Pack for Microsoft Windows (32-bit)
- then download -
Oracle® Database 11g Release 1 Client (11.1.0.6.0) for Microsoft Windows (32-bit) CD
- Install the Instant Client and also apply the 11.10.7 patchset to the ORACLE_HOME where you install the client. (if you are using 11.1.0.7 RDBMS)
- for Windows change the PATH system variable to make sure the 11.1 RDBMS and Client ORACLE_HOME directories are listed before any other Oracle directories
- started SQL*Developer and clicked the 'Use OCI/Thick driver' option
- could then run the select -
select "col2" from test_nvarchar@dg4msql ;
without any problems.
If this is still a problem for you then let us know the description of the columns in the SQL*Server table that give the problem and the exact errors you receive.
Regards,
Mike -
Recreating SQL Server Tables on Oracle
Hello,
I need to recreate several SQL Server tables in Oracle and am trying to figure out if there is an easier way to do it other than manually recreating them.
I have the SQL Server table scripts, and I have data load xls files that also contain the column names. I use TOAD for Oracle to do my database management, but there is currently no way to autmoatically create a table based on an external file.
Does anyone have any suggestions?
Thanks,
ChristineManually re-creating these SQL Server tables for Oracle is exactly the right thing to do.
SQL Server != Oracle
In other words, there are numerous differences. You need to look at each table and decide on the type of table (hash table, index organised table, partitioned tables), whether to cluster tables, the types of indexes to use, the data types for the columns to use (Oracle does not have boolean or auto incrementing data types). Oracle supports LONG, RAW, CLOB and BLOB for dealing with different types of binary and large data structures. LONG for example should not be used anymore. There are also specialised data types like BFILE. One can also define your own SQL data types.
You will only be doing yourself a favour, and the final database application, by going through the learning curve and manually converting each and every table. And no, it is not a huge task either. It sounds a lot more daunting that what it really is. -
So we have an Invoice .xlsx File from a 3rd party vendor. It contains two worksheets..."Enrolled" and "Engaged". The data and data columns in each worksheet is different. Is it possible to loop through multiple .xlsx files using SSIS
and a Foreach Loop Container for each spreadsheet, and then another Foreach Loop Container to control each worksheet, and pump the Excel data into a SQL Server Table first for "Enrolled" and then for "Engaged"? How can I control the Foreach
Loop Container in SSIS to process ONLY the "Enrolled" worksheet first? And then the "Engaged" worksheet next?
I know I have multiples out here and I apologize for that...but right now it seems as though I take three steps forward and then two back.
Any help would be GREATLY appreciated!
Thanks in advance!If the structure of the Excel sheets does not change from file to file then you can by having one ForEach Loop processing always the "Enrolled" sheet and another always the "Engaged" this is doable because the Excel OLEDB connector allows
to pick individual sheets, it is problematic therefore when sheet names themselves change.
MSDN has an example: https://msdn.microsoft.com/en-ca/library/ms345182.aspx
Arthur
MyBlog
Twitter -
How to convert from SQL Server table to Flat file (txt file)
I need To ask question how convert from SQL Server table to Flat file txt file
Hi
1. Import/Export wizened
2. Bcp utility
3. SSIS
1.Import/Export Wizard
First and very manual technique is the import wizard. This is great for ad-hoc and just to slam it in tasks.
In SSMS right click the database you want to import into. Scroll to Tasks and select Import Data…
For the data source we want out zips.txt file. Browse for it and select it. You should notice the wizard tries to fill in the blanks for you. One key thing here with this file I picked is there are “ “ qualifiers. So we need to make
sure we add “ into the text qualifier field. The wizard will not do this for you.
Go through the remaining pages to view everything. No further changes should be needed though
Hit next after checking the pages out and select your destination. This in our case will be DBA.dbo.zips.
Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
Hit next and then finish. Once completed you will see the count of rows transferred and the success or failure rate
Import wizard completed and you have the data!
bcp utility
Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported. For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
To create a format file all we really need is the type and the count of columns for the most basic files. In our case the qualifier makes it a bit difficult but there is a trick to ignoring them. The trick is to basically throw a field into the
format file that will reference it but basically ignore it in the import process.
Given that our format file in this case would appear like this
9.0
9
1 SQLCHAR 0 0 """ 0 dummy1 ""
2 SQLCHAR 0 50 "","" 1 Field1 ""
3 SQLCHAR 0 50 "","" 2 Field2 ""
4 SQLCHAR 0 50 "","" 3 Field3 ""
5 SQLCHAR 0 50 ""," 4 Field4 ""
6 SQLCHAR 0 50 "," 5 Field5 ""
7 SQLCHAR 0 50 "," 6 Field6 ""
8 SQLCHAR 0 50 "," 7 Field7 ""
9 SQLCHAR 0 50 "n" 8 Field8 ""
The bcp call would be as follows
C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
Given a successful run you should see this in command prompt after executing the statement
Starting copy...
1000 rows sent to SQL Server. Total sent: 1000
1000 rows sent to SQL Server. Total sent: 2000
1000 rows sent to SQL Server. Total sent: 3000
1000 rows sent to SQL Server. Total sent: 4000
1000 rows sent to SQL Server. Total sent: 5000
1000 rows sent to SQL Server. Total sent: 6000
1000 rows sent to SQL Server. Total sent: 7000
1000 rows sent to SQL Server. Total sent: 8000
1000 rows sent to SQL Server. Total sent: 9000
1000 rows sent to SQL Server. Total sent: 10000
1000 rows sent to SQL Server. Total sent: 11000
1000 rows sent to SQL Server. Total sent: 12000
1000 rows sent to SQL Server. Total sent: 13000
1000 rows sent to SQL Server. Total sent: 14000
1000 rows sent to SQL Server. Total sent: 15000
1000 rows sent to SQL Server. Total sent: 16000
1000 rows sent to SQL Server. Total sent: 17000
1000 rows sent to SQL Server. Total sent: 18000
1000 rows sent to SQL Server. Total sent: 19000
1000 rows sent to SQL Server. Total sent: 20000
1000 rows sent to SQL Server. Total sent: 21000
1000 rows sent to SQL Server. Total sent: 22000
1000 rows sent to SQL Server. Total sent: 23000
1000 rows sent to SQL Server. Total sent: 24000
1000 rows sent to SQL Server. Total sent: 25000
1000 rows sent to SQL Server. Total sent: 26000
1000 rows sent to SQL Server. Total sent: 27000
1000 rows sent to SQL Server. Total sent: 28000
1000 rows sent to SQL Server. Total sent: 29000
bcp import completed!
BULK INSERT
Next, we have BULK INSERT given the same format file from bcp
CREATE TABLE zips (
Col1 nvarchar(50),
Col2 nvarchar(50),
Col3 nvarchar(50),
Col4 nvarchar(50),
Col5 nvarchar(50),
Col6 nvarchar(50),
Col7 nvarchar(50),
Col8 nvarchar(50)
GO
INSERT INTO zips
SELECT *
FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
) as t1 ;
GO
That was simple enough given the work on the format file that we already did. Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
SSIS
Next is my favorite playground in SSIS
We can do many methods in SSIS to get data from point A, to point B. I’ll show you data flow task and the SSIS version of BULK INSERT
First create a new integrated services project.
Create a new flat file connection by right clicking the connection managers area. This will be used in both methods
Bulk insert
You can use format file here as well which is beneficial to moving methods around. This essentially is calling the same processes with format file usage. Drag over a bulk insert task and double click it to go into the editor.
Fill in the information starting with connection. This will populate much as the wizard did.
Example of format file usage
Or specify your own details
Execute this and again, we have some data
Data Flow method
Bring over a data flow task and double click it to go into the data flow tab.
Bring over a flat file source and SQL Server destination. Edit the flat file source to use the connection manager “The file” we already created. Connect the two once they are there
Double click the SQL Server Destination task to open the editor. Enter in the connection manager information and select the table to import into.
Go into the mappings and connect the dots per say
Typical issue of type conversions is Unicode to non-unicode.
We fix this with a Data conversion or explicit conversion in the editor. Data conversion tasks are usually the route I take. Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
New look in the mappings
And after execution…
SqlBulkCopy Method
Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy. Not only fast but also handy for those really “unique” file formats we receive so often
Bring over a script task into the control flow
Double click the task and go to the script page. Click the Design script to open up the code behind
Ref.
Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/ -
Hibernate mapping XML files for the two SQL Server tables below.
Hello all..,
Question 1:
I am working on a project that needs to support a database with an inherited legacy schema that you cannot change. The schema is provided below.Hibernate mapping XML files for the two SQL Server tables below. Please provide those two XML files. Assume some hypothetical package and class names. Assume that no "fancy" stuff such as lazy initialization, optimistic locking etc is needed at this time.
CREATE TABLE [SURVEY_ANSWERS] (
[ANSWER_ID] [int] IDENTITY (1,1) NOT NULL,
[QUESTION_ID] [int] NOT NULL,
[POSITION] [int] NULL,
[TEXT] [varchar](350) NULL
CREATE TABLE [dbo].[SURVEY_QUESTIONS] (
[QUESTION_ID] [int] IDENTITY (1, 1) NOT NULL ,
[TEXT] [varchar] (350) NULL
GO
ALTER TABLE SURVEY_ANSWERS
ADD CONSTRAINT pk_SURVEY_ANSWERS PRIMARY KEY(ANSWER_ID,QUESTION_ID);
ALTER TABLE [dbo].[SURVEY_QUESTIONS] ADD
PRIMARY KEY CLUSTERED
[QUESTION_ID]
GO
ALTER TABLE [dbo].[SURVEY_ANSWERS] ADD
FOREIGN KEY
[QUESTION_ID]
) REFERENCES [dbo].[SURVEY_QUESTIONS] (
[QUESTION_ID]
)Question 2:
Assume that you are working on a project developing, say, a banking application. You are the Architect and thinking that Hibernate ORM should be used for the entire access to the relational database. As usual, you have created (or auto-generated) a set of HBM XML files as well as POJOs for which you define the mappings. Assume now that a new requirement has just popped up. The system needs to be able to import new bank accounts and user information in bulk from a very large XML file at once and store it in the database. Assume the XML file contains all necessary information to populate fields in database tables. As performance is very important for this operation. Given this description, how would you approach the problem?
Please describe briefly.
-Thanks and regards
Praveen SoniYou're not fooling anyone Dennis_Mox. But nice try.Jeez, man. Mail me at denismox[at]yandex.ru, I will show you that exact test, dammit.
-
Error when insert data in Sql Server table(DateTime data type)
Hello all,
I have created a database link in oracle 11g to SQL Server 2008 using Sqlserver gateway for oracle,Oracle run on Linux and SQL Server run on Windows platform.
I have queried a table and it fetches rows from the target table.
I am using this syntax for insert a row in Sql Server table.
Insert into Prod@sqlserver (NUMITEMCODE, NUMPREOPENSTOCK, NUMQNTY, NUMNEWOPENSTOCK, DATPRODDATE , TXTCOMPANYCODE, "bolstatus", NUMRESQNTY )
Values (1118 , 1390.0 , 100.0 ,1490 , '2012-06-23 12:37:58.000','SFP' ,0 , 0 );
but it give me error on DATPRODDATE,The data type of DATPRODDATE column in Sql Server is DATETIME.
My Question is how can i pass the date values in INSERT statement for Sql Server DateTime data type.
RegardsJust as with Oracle, you have to specify the date using the to_date() function or use the native date format for the target database (if you can figure out what that is). This is good practice anyway and a good habit to get into.
-
ORA-02070: Error when updating a SQL Server table thru an Oracle View
I have a SQL Server table TIMESHEET which contains a number of VARCHAR and NUMERIC columns plus a DATETIME column.
Only the DATETIME column is giving me trouble.
On the ORACLE side I have a view which selects from the SQL Server table but in order to get the SELECT to work, I had to either put a CAST or TO_DATE function call around the DATETIME field
Below is the relevant part of the 2 view definitions I have tried
create view TIMESHEET as
SELECT
"TsKeySeq" as TS_KEY_SEQ,
"EmployeeNo" as EMPLOYEE_NO,
CAST("PeriodEnding" AS DATE) as PERIOD_ENDING,
. . . (more columns - not relevant)
FROM [email protected];
An update to the view generates this message
ORA-02070: database OLEMSQLPSANTDAS6 does not support CAST in this context
create view TIMESHEET as
SELECT
"TsKeySeq" as TS_KEY_SEQ,
"EmployeeNo" as EMPLOYEE_NO,
TO_DATE("PeriodEnding") as PERIOD_ENDING,
. . . (more columns - not relevant)
FROM [email protected];
An update to the view generates this message
ORA-02070: database OLEMSQLPSANTDAS6 does not support TO_DATE in this context
If I don't include either the TO_DATE() or CAST() then I get
Select Error: ORA-28527: Heterogeneous Services datatype mapping error
ORA-02063:preceding line from OLEMSQLSANTDAS6
Does anyone have any idea how to update a SQL Server DATETIME column thru an ORACLE view?You can't cast accross heterogenious databases and there is no need to. HSODBC treats SQL Server DATETIME column as DATE. For example, I have SQL Server table:
CREATE TABLE [Ops].[T_JobType](
[JobType] [varchar](50) NOT NULL,
[JobDesc] [varchar](200) NULL,
[InsertDt] [datetime] NOT NULL CONSTRAINT [InsertDt_00000006] DEFAULT (getdate()),
[InsertBy] [varchar](128) NOT NULL CONSTRAINT [InsertBy_00000006] DEFAULT (user_name()),
[LastUpdated] [datetime] NOT NULL CONSTRAINT [LastUpdated_00000006] DEFAULT (getdate()),
[LastUpdatedBy] [varchar](128) NOT NULL CONSTRAINT [LastUpdatedBy_00000006] DEFAULT (user_name()),
CONSTRAINT [T_JobType_PK] PRIMARY KEY CLUSTERED
[JobType] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [DATA01FG]
) ON [DATA01FG]Now on Oracle side I do:
SQL> desc "Ops"."T_JobType"@pbods
Name Null? Type
JobType NOT NULL VARCHAR2(50)
JobDesc VARCHAR2(200)
InsertDt NOT NULL DATE
InsertBy NOT NULL VARCHAR2(128)
LastUpdated NOT NULL DATE
LastUpdatedBy NOT NULL VARCHAR2(128)
SQL> select "InsertDt" from "Ops"."T_JobType"@pbods;
InsertDt
18-AUG-08
09-OCT-08
22-OCT-09
18-AUG-08
19-NOV-08
SQL> SY. -
How to delete rows in the SQL Server table based on the contents of Excel file
Hello, everyone,
I have an Excel file which contains data for certain dates. I need to load it in a SQL Server table. But before doing that, I need to check if the table already contains data for the dates in the Excel file. If it does, I need to delete those data
first. Not sure what is the best and efficient way to do this. Your help and guidance would be much appreciated.
Thank you in advance.there are multiple ways of doing this
Fastest method would be below
1. Have a data flow task using excel source. Then add a OLEDB destination to dump the data to a staging table
2. Have a Execute sql task to delete data from your actual table based on staging table data. The query would look like
DELETE t
FROM YourTable t
WHERE EXISTS (SELECT 1
FROM StagingTable
WHERE DateField = t.DateField)
3. Have another execute sql task to do final insert like
INSERT YourTable (Col1,Col2,...)
SELECT Col1,Col2,..
FROM StagingTable
the above operations will be set based and faster
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Writing a stored procedure to import SQL Server table data into a Oracle table
Hello,
As a new DBA I have been tasked with writing a stored procedure to import SQL Server table data into an Oracle table. I have been given many suggestions on how to do it from SQL Server but I I just need to write a stored procedure to run it from the Oracle side. Suggestions/guidance on where to start would be greatly appreciated! Thank you!
I started to write it based on what I have but I know this is not correct :/
# Here is the select statement for the data source in SQL Server...
SELECT COMPANY
,CUSTOMER
,TRANS_TYPE
,INVOICE
,TRANS_DATE
,STATUS
,TRAN_AMT
,CREDIT_AMT
,APPLD_AMT
,ADJ_AMT
,TRANS_USER1
,PROCESS_LEVEL
,DESCRIPTION
,DUE_DATE
,OUR_DATE
,OUR_TIME
,PROCESS_FLAG
,ERROR_DESCRIPTION
FROM data_source_table_name
#It loads data into the table in Oracle....
Insert into oracle_destination_table_name (
COMPANY,
CUSTOMER,
TRANS_TYPE,
INVOICE,
TRANS_DATE,
STATUS,
TRANS_AMT,
CREDIT_AMT,
APPLD_AMT,
ADJ_AMT,
TRANS_USER1,
PROCESS_LEVEL,
DESCRIPTION,
DUE_DATE,
OUR_DATE,
OUR_TIME,
PROCESS_FLAG,
ERROR_DESCRIPTION)
END;CREATE TABLE statements would have been better as MS-SQL and Oracle don't have the same data types.
OUR_DATE, OUR_TIME will (most likely) be ONE column in Oracle.
DATABASE LINK
Personally, I'd just load the data over a database link:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_table@mssql_db_link
As far as creating the database link from Oracle to MS-SQL ... that is for somebody else to answer.
(most likely you'll need to use an ODBC driver)
EXTERNAL TABLE
If the data from MS-SQL is in a CSV file, just use and external table.
same concept:
insert into oracle_destination_table_name ( <column list> )
select ... <transform data here>
from data_source_external_table
MK -
Hi All,
I am developing a straight source - target interface from a sql server table to a sql server table. While executing the interface, I get an error message -
" Cannot insert explicit value for identity column in table 'xxx' when IDENTITY_INSERT is set to OFF."
After investigating, it appears I have to execute -
SET IDENTITY_INSERT xxx ON
GO
This execution is session specific, ie I have to execute this statement each time ODI inserts into the target table. Is there a way I can have the tool run this statement ?
TIA
MN
ODI Version - 11g
Source - SQL Server 2008 R2
Target- SQL Server 2008 R2In IKM , before the Insert new Rows statement
Create a new command call it IDENTITY_INSERT_ON
In command on Target , paste the following statement
SET IDENTITY_INSERT <%=snpRef.getTable("L","TARG_NAME","A")%> ON
GOso this way before inserting , the required command is executed on Target table ,also please use the same properties (like technology, transaction ) as specified in Insert New Rows .
Hope this helps.
Maybe you are looking for
-
Help I think my power supply is going bad! Where can I buy parts?
I am getting random reboots and it doesn't seem to be the OS... My first guess is the power supply but I can't seem to find one to buy... Does anyone know where I can buy one at? Is there a good place for parts for the MEGA 180? Thanks Mobile Bob
-
i have save an MS Project Plan as an Excel Workbook, the problem is that the outlining of the project plan didn't come across. the Task name did not indented at all. I can see the outline level .so i assume that as first , second and third in outlin
-
I sleep my iPhone 4 and then it enters DFU Mode?
So basically, I downgraded iOS 7.0.6 (because it looks horrible and it's laggy) to iOS 6.1.3 on my iPhone 4 using a custom firmware I created with my SHSH Blobs for iOS 6.1.3. During the restore, I get error 37 and have to boot it tethered with a rec
-
Canon color sync profiles location. Where to put them?
Hi as part my canon printer installation, i downloaded some canon icc profiles. The canon site downloaded them to my desktop, not the right location clearly but what is the right location ?. Thanks Tony
-
As with my question I am having problems opening some PDF's in iBooks, some do some don't, what they do is flash open then close, anyone can help or advise ?