Best Practice to fetch SQL Server data and Insert into Oracle Tables

Hello,
I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
We do not have any database dblinks from oracle to sqlserver and vice versa.
Any help is highly appreciable?
Thanks

Well, that's easy:
use a TimerTask to do the following every half an hour:
- open a connection to sql server
- open two connections to the oracle databases
- for each row you read from the sql server, do the inserts into the oracle databases
- commit
- close all connections

Similar Messages

  • How to extract data from xml and insert into Oracle table

    Hi,
    I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
    There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
    I need to extract the values of these columns and insert into the table
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>

    Re: Insert from XML to relational table
    http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta=

  • How to read ecel sheet and insert into oracle table

    hi all,
    am working on forms builder 6i. and i want , from a trigger to read from a a sheet excel file the data and insert into a table that i had aleady created.
    i whrite a code that can till now open the excel file but i cant read the data to insert it into the table.
    am using TEXT_IO.IS_OPEN to open the file
    TEXT_IO.GET_LINE to take each line
    and subst(x as variable) to read the first line , but the subsrt return nohing
    any solution??

    There's already a topic made on this: how to copy data from excel to oracle forms

  • MS SQL Server 2014: Error inserting into Temp table with index and identity field

    In this thread, I mentioned a problem with SQL Server 2014:
    SQL Server 2014: Bug with IDENTITY INSERT ON
    The question was answered, it is a bug. To keep you informed on this issue, I open this discussion.
    Problem:
    The code below works perfectly fine on MS SQL Server 2008 R2 and MS SQL Server 2012, but gives an error every second time the proc is executed on MS SQL Server 2014. If I do not define any index on the temp table, the problem disappears. Defining the index
    after the insert, does not help.
    SET NOCOUNT ON
    GO
    IF EXISTS (SELECT 1 FROM sys.procedures WHERE name = 'usp_Test') DROP PROC dbo.usp_Test;
    GO
    CREATE PROC dbo.usp_Test AS
    BEGIN
    SET NOCOUNT ON
    CREATE TABLE #Source(ID integer NOT NULL);
    INSERT INTO #Source VALUES (1), (2), (3);
    CREATE TABLE #Dest (ID integer IDENTITY(1,1) NOT NULL);
    CREATE INDEX #IDX_Dest ON #Dest (ID);
    PRINT 'Check if the insert might cause an identity crisis';
    SELECT 'Source' AS SourceTable, * FROM #Source;
    SELECT 'Destination' AS DestTable, * FROM #Dest;
    SET IDENTITY_INSERT #Dest ON;
    PRINT 'Do the insert';
    INSERT INTO #Dest (ID) SELECT ID FROM #Source;
    PRINT 'Insert ready';
    SET IDENTITY_INSERT #Dest OFF;
    SELECT * FROM #Dest;
    DROP TABLE #Source;
    DROP TABLE #Dest;
    END;
    GO
    PRINT 'First execution of the proc, everything OK';
    EXEC dbo.usp_Test;
    PRINT '';
    PRINT 'Second execution of the proc, the insert fails.';
    PRINT 'Removing the index #IDX_Dest causes the error to disappear.';
    EXEC dbo.usp_Test;
    GO
    DROP PROC dbo.usp_Test;
    GO

    There is some progress. Communication from a former Microsoft employee tells us this:
    Shivendra Vishal
    Engineer at Microsoft
    I am no longer with MS, and I do not have code access, however from the public symbols, I could make out following:
    sqlmin!SetidentI2I4+0x1f3:
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] ds:00000000`00000000=????????????????
    ExceptionAddress: 000007fef4d865d3 (sqlmin!SetidentI2I4+0x00000000000001f3)
    ExceptionCode: c0000005 (Access violation)
    ExceptionFlags: 00000000
    NumberParameters: 2
    Parameter[0]: 0000000000000000
    Parameter[1]: 0000000000000000
    Attempt to read from address 0000000000000000
    This is a read AV and from registers it is clear that we were trying to move the value of location pointed by qword of register rax which is not valid:
    rax=0000000000000000 rbx=0000000000000038 rcx=0000000000001030
    rdx=0000000000000006 rsi=00000001f55def98 rdi=00000000106fd070
    rip=000007fef4d865d3 rsp=00000000106fcf40 rbp=00000000106fcfe9
    r8=0000000000000000 r9=00000001f55def60 r10=00000001f55defa0
    r11=00000000106fcd20 r12=0000000000000000 r13=0000000000000002
    r14=00000001f49c3860 r15=00000001f58c0040
    iopl=0 nv up ei pl nz na po nc
    cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
    The stack is:
    # Child-SP RetAddr Call Site
    00 00000000`106fcf40 000007fe`f30c1437 sqlmin!SetidentI2I4+0x1f3
    01 00000000`106fd050 000007fe`f474e7ce sqlTsEs!CEsExec::GeneralEval4+0xe7
    02 00000000`106fd120 000007fe`f470e6ef sqlmin!CQScanUpdateNew::GetRow+0x43d
    03 00000000`106fd1d0 000007fe`f08ff517 sqlmin!CQueryScan::GetRow+0x81
    04 00000000`106fd200 000007fe`f091cebe sqllang!CXStmtQuery::ErsqExecuteQuery+0x36d
    05 00000000`106fd390 000007fe`f091ccb9 sqllang!CXStmtDML::XretDMLExecute+0x2ee
    06 00000000`106fd480 000007fe`f08fa058 sqllang!CXStmtDML::XretExecute+0xad
    07 00000000`106fd4b0 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    08 00000000`106fd5f0 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    09 00000000`106fd7e0 000007fe`f152cfaa sqllang!CSQLSource::Execute+0x86c
    0a 00000000`106fd9b0 000007fe`f152c9e8 sqllang!CStmtExecProc::XretLocalExec+0x25a
    0b 00000000`106fda30 000007fe`f152a1d8 sqllang!CStmtExecProc::XretExecExecute+0x4e8
    0c 00000000`106fe1e0 000007fe`f08fa058 sqllang!CXStmtExecProc::XretExecute+0x38
    0d 00000000`106fe220 000007fe`f08fb66b sqllang!CMsqlExecContext::ExecuteStmts<1,1>+0x427
    0e 00000000`106fe360 000007fe`f08fac2e sqllang!CMsqlExecContext::FExecute+0xa33
    0f 00000000`106fe550 000007fe`f0902267 sqllang!CSQLSource::Execute+0x86c
    10 00000000`106fe720 000007fe`f0909087 sqllang!process_request+0xa57
    11 00000000`106feee0 000007fe`f2bf49d0 sqllang!process_commands+0x4a3
    12 00000000`106ff200 000007fe`f2bf47b4 sqldk!SOS_Task::Param::Execute+0x21e
    13 00000000`106ff800 000007fe`f2bf45b6 sqldk!SOS_Scheduler::RunTask+0xa8
    14 00000000`106ff870 000007fe`f2c136ff sqldk!SOS_Scheduler::ProcessTasks+0x279
    15 00000000`106ff8f0 000007fe`f2c138f0 sqldk!SchedulerManager::WorkerEntryPoint+0x24c
    16 00000000`106ff990 000007fe`f2c13246 sqldk!SystemThread::RunWorker+0x8f
    17 00000000`106ff9c0 000007fe`f2c13558 sqldk!SystemThreadDispatcher::ProcessWorker+0x3ab
    18 00000000`106ffa70 00000000`775d59ed sqldk!SchedulerManager::ThreadEntryPoint+0x226
    19 00000000`106ffb10 00000000`7780c541 kernel32!BaseThreadInitThunk+0xd
    1a 00000000`106ffb40 00000000`00000000 ntdll!RtlUserThreadStart+0x21
    Unassembling the function:
    000007fe`f4d8658e 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d86591 4533e4 xor r12d,r12d
    000007fe`f4d86594 410fb7d5 movzx edx,r13w
    000007fe`f4d86598 4533c9 xor r9d,r9d
    000007fe`f4d8659b 4533c0 xor r8d,r8d
    000007fe`f4d8659e 488bc8 mov rcx,rax
    000007fe`f4d865a1 4489642420 mov dword ptr [rsp+20h],r12d
    000007fe`f4d865a6 41ff5230 call qword ptr [r10+30h]
    000007fe`f4d865aa 8b5597 mov edx,dword ptr [rbp-69h]
    000007fe`f4d865ad 4c8b10 mov r10,qword ptr [rax]
    000007fe`f4d865b0 4489642438 mov dword ptr [rsp+38h],r12d
    000007fe`f4d865b5 4489642430 mov dword ptr [rsp+30h],r12d
    000007fe`f4d865ba 458d442401 lea r8d,[r12+1]
    000007fe`f4d865bf 4533c9 xor r9d,r9d
    000007fe`f4d865c2 488bc8 mov rcx,rax
    000007fe`f4d865c5 c644242801 mov byte ptr [rsp+28h],1
    000007fe`f4d865ca 4488642420 mov byte ptr [rsp+20h],r12b
    000007fe`f4d865cf 41ff5250 call qword ptr [r10+50h]
    000007fe`f4d865d3 488b10 mov rdx,qword ptr [rax] <=================== AV happened over here
    000007fe`f4d865d6 488bc8 mov rcx,rax
    000007fe`f4d865d9 4c8bf0 mov r14,rax
    000007fe`f4d865dc ff5268 call qword ptr [rdx+68h]
    000007fe`f4d865df 488d55e7 lea rdx,[rbp-19h]
    000007fe`f4d865e3 4c8b00 mov r8,qword ptr [rax]
    000007fe`f4d865e6 488bc8 mov rcx,rax
    000007fe`f4d865e9 41ff5010 call qword ptr [r8+10h]
    000007fe`f4d865ed f6450a04 test byte ptr [rbp+0Ah],4
    I remember few issues with scan2ident function, I am not sure if they have fixed it however it appears that this is intoduced to SQL 2014 and we need help from MS to get this resolved as it needs code analysis.
    It is not getting simulated for other versions of SQL apart from SQL 2014.
    Also to add, interestingly, the value of rax is not visibly changed and it was successfully passed on to rcx, which has a valid value, so something should have changed the value of rax inside call to function using call qword ptr [r10+50h], and looking at this
    it appears that it might be a list of functions and we are going at particular offset [50h]. So, bottom line is that the call to function qword ptr [r10+50h], should be changing something in rax, and debugging/analyzing this code might give us some more idea.

  • How to read the data from XML file and insert into oracle DB

    Hi All,
    I have below require ment.
    I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
    Many Thanks.

    Sounds a lot like this question, only with less details.
    how to read data from XML  variable and insert into table variable
    We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us.  Plenty of examples abound on the forums that cover the topics you seek as well.

  • Is there a list of best practices for Azure Sql Server?

    I was talking with a Sql Server expert today and learned that Azure Sql Server can take up to a minute to respond to a query that normally takes a fraction of a second. This is one of those things where it's really valuable to learn it when architecting as
    opposed to when we go live.
    Is there a list of best practices for Azure Sql Server? If so, what are they?
    We will be calling the database from multiple instances, both Azure websites and Azure cloud services. The calls will be about 90% selects, 9% updates, and 1% inserts.
    thanks - dave
    What we did for the last 6 months -
    Made the world's coolest reporting & docgen system even more amazing

    Hi,
    Here are some documentation on Azure SQL Database to get you started.
    http://msdn.microsoft.com/en-us/library/azure/ee336279.aspx
    http://msdn.microsoft.com/en-us/library/azure/ff394102.aspx
    http://msdn.microsoft.com/en-us/library/azure/jj156164.aspx
    http://msdn.microsoft.com/en-us/library/azure/ee336282.aspx
    http://msdn.microsoft.com/en-us/library/azure/ee336256.aspx
    Regards,
    Mekh.

  • Where is Best Practices Analyzer for SQL Server 2014?

    Hi! Does anyone have a news about new version of BPA for SQL Server?

    Hi,
    The latest version of Best Practices Analyzer for SQL Server is SQL Server 2012 Best Practices Analyzer.
    You can download it from
    http://www.microsoft.com/en-us/download/details.aspx?id=29302
    I will update this thread when there is any update for SQL Server 2014 version.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • How to integrate from MS SQL SERVER 2005 and Flatfile to Oracle 10g.

    Hi
    I am new to ODI. I am trying to load sample data from MS SQL Server 2005 and Flatfile to Oracle 10g.
    1. I have created three models.
    1-1. SQL2005 (SRC_CUSTOMER table)
    1-2. Flatfile (SRC_AGE_GROUP.txt & SRC_SALES_PERSON.txt)
    1-3. Oracle 10g (TRG_CUSTOMER table)
    You may know I got those environments from the ODI DEMO environment.
    2. I could able to reverse the tables also.
    3. I have created an interface which contains source table (from MSSQL 2005), Flatfile and target table from ORACLE model.
    4. I have imported the knowledge modules. But I am confusing in selecting the knowledge modules to source and target tables.
    I've selected LKM File to SQL for flatfile model.
    I've also selected LKM SQL to SQL for MSSQL 2005 model and IKM Oracle Incremental Update for the target table (ORACLE).
    I've also implemented the interface that I created. It worked without errors. But there is no data in target table which is TRG_CUSTOMER.
    I really would like to know what happened and what the problems are.
    You can email me [email protected]
    Thanks in advance
    Jason Lee

    what did give for SRC_AGE_GROUP SRC_CUSTOMER join condition
    if it is
    (SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE=SRC_AGE_GROUP.AGE_MAX
    give it as
    (SRC_CUSTOMER.AGE>SRC_AGE_GROUP.AGE_MIN) AND SRC_CUSTOMER.AGE<SRC_AGE_GROUP.AGE_MAX

  • Split data and insert into different rows

    I have a string like 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi,"
    I have created a single column table
    I have to extract data from first untill comma(,) occurs and insert into the table like the following
    sfdsdf
    sfdsf
    sfsd
    qweqeqw
    iuoi
    Please help me how to do it

    Or a Single SQL query
    SELECT trim(',' from DECODE(ROWNUM,1,SUBSTR(STR,1,INSTR(STR,',',1)),
                                        LENGTH(STR)-LENGTH(REPLACE(STR,','))+1,SUBSTR(STR,INSTR(STR,',',-1,1)),
                                         SUBSTR(STR,INSTR(STR,',',1,ROWNUM-1), INSTR(STR,',',1,ROWNUM)-INSTR(STR,',',1,ROWNUM-1))
                                   ))  STR1
                     FROM (SELECT 'sfdsf,sfdsf,sfsd,qweqeqw,iuoi' STR FROM DUAL),ALL_TABLES
                     WHERE ROWNUM <= LENGTH(STR)-LENGTH(REPLACE(STR,','))+1
                      ORDER BY ROWNUM

  • Fetch data from one table and insert into two tables in desired format

    I have similar to the following data in a table and it is not normalized. The groupID is being used to group two records of similar nature.
    DECLARE @OldDoc TABLE (oldDocID INT, groupID INT, deptID INT)
    INSERT INTO @OldDoc (oldDocID, groupID) VALUES (1, NULL, 111),(2,NULL,111),(3,1,111),(4,NULL,333),(5,1,222),(6,NULL,333),(7,2,222),(8,2,333),(9,NULL,111),(10,3,222),(11,NULL,333),(12,3,444)
    I need to process the data from the above table (@OldDoc) and write into two new tables (@NewDoc and @NewDocGroup) as follows.
    oldDocID should be stored as newDocID when inserting to @NewDoc table. Only records with groupID NULL and one record (first one) per group should be considered (For example, oldDocID 5 is not considered as 3 and 5 belong to the same groupID 1) for insertion. 
    DECLARE @NewDoc TABLE (newDocID INT)
    INSERT INTO @NewDoc (newDocID) VALUES (1),(2),(3),(4),(6),(7),(9),(10),(11)
    All records from @OldDoc should be considered for insertion into @NewDocGroup table. OldDocID is inserted as NewDocID and deptID is as-is. Instead of groupID, the ID of the first record in the 
    group should be considered as parentNewDocID (For example, 3 is considered as parentNewDocID for newDocID 5 as 3 and 5 belong to the same groupID in @OldDoc table) for the newDocID.
    DECLARE @NewDocGroup (newDocID INT, parentNewDocID INT, deptID INT)
    INSERT INTO @NewDocGroup (newDocID, parentNewDocID, deptID) VALUES (1,1,111),(2,2,111),(3,3,111),(4,4,333),(5,3,222),(6,6,333),(7,7,222),(8,7,333),(9,9,111),(10,10,222),(11,11,333),(12,10,444)
    How do I accomplish the above using SQL ? Thanks for the help.

    >> I have similar to the following data in a table and it is not normalized. The group_id is being used to group two records [sic] of similar nature. <<
    Rows are not records. Tables have to have a key by definition. You do not do math with identifiers, so they should not be numeric. Let's ignore that error for now. In short, you are posting garbage. If you had followed Forum Netiquette, would you have posted
    this? 
    CREATE TABLE Old_Documents
    (old_doc_id INTEGER NOT NULL PRIMARY KEY, 
     group_id INTEGER, 
     dept_nbr INTEGER NOT NULL
       REFERENCES Departments (dept_nbr));
    INSERT INTO Old_Documents(old_doc_id, group_id, dept_nbr) 
    VALUES  (1, NULL, 111), 
    (2, NULL, 111), 
    (3, 1, 111), 
    (4, NULL, 333), 
    (5, 1, 222), 
    (6, NULL, 333), 
    (7, 2, 222), 
    (8, 2, 333), 
    (9, NULL, 111), 
    (10, 3, 222), 
    (11, NULL, 333), 
    (12, 3, 444);
    >> I need to process the data from the above table (Old_Documents) and write into two new tables (New_Documents and New_Documents_Groups) as follows. <<
    Just like punch cards and mag tape data processing! Being old and being new are a status, not another kind of entity. But that is how mag tapes work. And you even use the verb "fetch" from tape files. This design flaw is called  attribute splitting.
    Do you have a Male_Personnel and Female_Personnel table? NO! It is just Personnel! 
    >> old_doc_id should be stored as new_doc_id when inserting to New_Documents table. Only records [sic] with group_id NULL and one record [sic] (first [sic; no ordering in a table] one) per group should be considered (For example, old_doc_id 5 is not considered
    as 3 and 5 belong to the same group_id =1) for insertion. <<
    Think about your punch card mindset. Why did you physically materialize that redundant New_Documents table? Let me answer that: this is how you work with punch cards! In SQL we use a VIEW:
    CREATE VIEW New_Documents (new_doc_id)
    AS 
    SELECT old_doc_id 
      FROM Old_Documents;
    >> All records [sic] from Old_Documents should be considered for insertion into New_Documents_Groups table. The old_doc_id is inserted as new_doc_id and dept_nbr is as-is. Instead of group_id, the ID [sic: which identifier??] of the first [sic: tables
    have no ordering like a deck of punch cards] record [sic] in the group should be considered as parent_new_doc_id (For example, 3 is considered as parent_new_doc_id for new_doc_id 5 as 3 and 5 belong to the same group_id in Old_Documents table) for the new_doc_id.
    <<
    Why not use 5 as the parent? My guess is that you are trying to form equivalence classes. See:
    https://www.simple-talk.com/content/print.aspx?article=2020
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Error converting SQL Server DDL and views to Oracle

    I am trying to convert SQL Serve 2008 on windows to Oracle 11g using SQL Developer 3.2.20.09. I am using the jtds-1.2.7 drivers to connect to SQL Server.
    I have made several attempts to run the conversion and am getting the tables, indexes, and triggers converted with no issue. However, my Procedures and views are not coming across. All of them are giving similar errors as:
    "Failed To Convert Stored Procedure get_compvision > esp3.dbo.get_compvision:unexpected end of subtree: Line 0 Column 0"
    When I log into the source SQL Server environment using SQL Developer, I get an empty SQL Editor window with "null" when I try to {right-click -> "Open"} on the Procedure.
    Logging into SQL Server Administrator as the same user I can see the source code, so the issue appears to be related to SQL Developer and not my user privleges. I am a dbo alias in SQL Server.
    In addition, if I click on a view, I can see the data and metadata, but not the SQL that defines the view. I see tabs for column, data, triggers, and details.
    In addition, if I go to the "capture" for my Migration project and drill down to procedures, I can see them listed, but each and every procedure gives me a "/* DDL not accesible */" error. I get teh same results for views, triggers and indexes.
    Can someone help me? I have been googling for days!
    Edited by: user4714217 on Jan 24, 2013 12:54 PM

    SELECT v.vnd_c, CASE v.use_parent_addr_flg WHEN 0 THEN a.str_1 ELSE pa.str_1 END AS str_1,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.str_2 ELSE pa.str_2 END AS str_2,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.str_3 ELSE pa.str_3 END AS str_3,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.city ELSE pa.city END AS city,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.state ELSE pa.state END AS state,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.zipcode ELSE pa.zipcode END AS zipcode,
    CAST((CASE v.use_parent_addr_flg WHEN 0 THEN (CASE a.foreign_flg WHEN 1 THEN 'Y' ELSE 'N' END)
    ELSE (CASE pa.foreign_flg WHEN 1 THEN 'Y' ELSE 'N' END) END) AS char(1)) AS foreign_flg,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.country ELSE pa.country END AS country,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.cre_d ELSE pa.cre_d END AS cre_d,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.mod_d ELSE pa.mod_d END AS mod_d,
    CASE v.use_parent_addr_flg WHEN 0 THEN a.mod_by ELSE pa.mod_by END AS mod_by
    FROM dbo.om_vendor AS v LEFT OUTER JOIN
    dbo.om_address AS a ON a.vnd_id = v.vnd_id AND a.addr_c = 1 INNER JOIN
    dbo.om_owner AS o ON v.owr_id = o.owr_id INNER JOIN
    dbo.om_address AS pa INNER JOIN
    dbo.primary_vendors AS pv ON pa.vnd_id = pv.vnd_id ON o.part_id = pv.part_id
    WHERE (pa.addr_c = 1)
    WHICH TRANSLATES TO
    SELECT v.vnd_c ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_1
    ELSE pa.str_1
    END str_1 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_2
    ELSE pa.str_2
    END str_2 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.str_3
    ELSE pa.str_3
    END str_3 ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.city
    ELSE pa.city
    END city ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.STATE
    ELSE pa.STATE
    END STATE ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.zipcode
    ELSE pa.zipcode
    END zipcode ,
    (CASE v.use_parent_addr_flg
    WHEN 0 THEN (CASE a.foreign_flg
    WHEN 1 THEN 'Y'
    ELSE 'N'
    END)
    ELSE (CASE pa.foreign_flg
    WHEN 1 THEN 'Y'
    ELSE 'N'
    END)
    END) foreign_flg ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.country
    ELSE pa.country
    END country ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.cre_d
    ELSE pa.cre_d
    END cre_d ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.mod_d
    ELSE pa.mod_d
    END mod_d ,
    CASE v.use_parent_addr_flg
    WHEN 0 THEN a.mod_by
    ELSE pa.mod_by
    END mod_by
    FROM om_vendor v
    LEFT JOIN om_address a
    ON a.vnd_id = v.vnd_id
    AND a.addr_c = 1
    JOIN om_owner o
    ON v.owr_id = o.owr_id
    JOIN om_address pa
    JOIN primary_vendors pv
    ON pa.vnd_id = pv.vnd_id
    ON o.part_id = pv.part_id
    WHERE ( pa.addr_c = 1 );
    Edited by: user4714217 on Jan 24, 2013 1:43 PM

  • Fetch data from two tables and insert into one table

    I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
    DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
    INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
    Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director. 
    Data exists only for subset of plants and a Plant may have one or both roles.
    DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
    INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
    The above data needs to be inserted into one table (@PlantNew) as follows: 
    PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
    PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
    DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
    INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
    VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
    How do I achieve the above using SQL ? Thanks.

    like this
    INSERT @PlantNew  (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID) 
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    You're missing a FROM
    insert into @PlantNew
    SELECT p.PlantID,
    p.PlantName,
    CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
    PlantAssistantDirID,
    PlantDirID
    FROM @Plant p
    LEFT JOIN (SELECT PlantID,
    MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
    MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
    from @PlantDirector
    GROUP BY PlantID)pd
    ON pd.PlantID = p.PlantID

  • Insert current date and time into Oracle date type field

    I have a JDBC current date and time insert into Oracle 9i that almost works. It submits the current date and a fixed time into the Oracle date type field. I am using Tomcat 6.0.20.
    For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will insert as: 16-Feb-2010 12:00:00 AM
    The date part works but the time always shows 12:00:00 AM no matter what date or time the data is inserted.
    Here is what I have for my JDBC inserts and I also tried something with DateFormat:
    PreparedStatement ps; Date mydate = new Date(new java.util.Date().getTime()); //insert statement here.... stmt.setDate(1,mydate);
    I also tried:
    PreparedStatement ps; java.sql.Timestamp mydate = new java.sql.Timestamp(new java.util.Date().getTime()); SimpleDateFormat fmt = new SimpleDateFormat(.... //insert statement here.... ps.setTimestamp(1,fmt.format(mydate));
    Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
    Anyway to get the current date and time? For example if I insert the data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in Oracle.

    sportsMarkr wrote:
    Date mydate = new Date(new java.util.Date().getTime());Please see the javadocs for java.sql.Date and note the part that says "...to zero"
    [http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    If you want a date and time then use java.sql.Timestamp.

  • Build a sql query fro different table and insert into a table

    Hi I have a requirement ,
    i have some table 1 table which holds rules which rules i have to apply on the sql query
    2 table will hold table name and column name and transformation
    with these help of 2 tables i want to build a sql quey and the sql query need to be insert into another  table.

    Hi Karthick,
    I am not going to build Dynamic Data Model.
    i already have table 1 contains rules let's say COUNT,
    and another table contain source table name , column name , Target table name, Source Table name like that
    so with the help of these 2 tables i want to build Sql query and going to insert into 3rd table.

  • Read data from E$ table and insert into staging table

    Hi all,
    I am a new to ODI. I want your help in understanding how to read data from an "E$" table and insert into a staging table.
    Scenario:
    Two columns in a flat file, employee id and employee name, needs to be loaded into a datastore EMP+. A check constraint is added to allow data with employee names in upper case only to be loaded into the datastore. Check control is set to flow and static. Right click on the datastore, select control and then check. The rows that have violated the check constraint are kept in E$_EMP+ table.
    Problem:
    Issue is that I want to read the data from the E$_EMP+ table and transform the employee name into uppercase and move the corrected data from E$_EMP+ into EMP+. Please advise me on how to automatically handle "soft" exceptions in ODI.
    Thank you

    Hi Himanshu,
    I have tried the approach you suggested already. That works. However, the scenario I described was very basic. Based on the error logged into the E$_EMP table, I will have to design the interface to apply more business logic before the data is actually merged into the target table.
    Before the business logic is applied, I need to read each row from the E$EMP table first and I do not know how to read from E$EMP table.

Maybe you are looking for

  • Please help! Software doesn't work

    Hello all, I'm sort of having a major issue here. Almost every single program that I installed on my iMac does not open - including Google SketchUp for Mac, Call of Duty 2 for Mac (it's Universal, and yes I put the disc in), RollerCoaster Tycoon 3 (n

  • Select Recording Source issue on Audigy 2

    I unistalled and installed the program and can't get it to work. I have the Audigy 2 ZS plat. with the software and all. Problem I have when I open up the Organizer MediaSource Player everything works but the "select recording source" button or selec

  • Show a vi that is normally hidden

    Hi Guys,                i have a VI that has a subVI constantly running in the back ground, but i want a button on the main VI to allow a user to make the subVI visible, then when the user closes the sub VI i want it to go back to running in the back

  • Can't uninstall/reinstall Photoshop - startup.exe shuts down

    I've tried every proposed solution I could find, including the regsvr32 jscript.dll thing, running in XP SP2 mode (I'm in Vista), running in admin mode, running at the C:\ root, and putting the install files in an .iso, mounting it in a disk emulator

  • Customer sent money to wrong bank, how to correct?

    My client has multiple LE and multiple banks. Their customers sometimes do business with many of these businesses. Occasionally that customer will send their payment to the wrong bank account. What is the best way to get this to the correct OU? My th