Powershell and oracle and duplicate data in table

I have created powershell script to  insert data in oracle table   from csv file and I want to know how to stop insert  duplicate row when Powershell script runs multiple time My powershell script is as follow:
'{0,-60}{1,20}'
-f
"Insert TEEN PREGNANCY ICD9 AND ICD10 CODES into the su_edit_detail ",(Get-Date
-Format yyyyMMdd:hhmmss);
$myQuery
=
SET PAGES 600;
SET LINES 4000;
SET ECHO ON;
SET serveroutput on;
WHENEVER sqlerror exit sql.sqlcode;
foreach
($file
in
dir
"$($UCMCSVLoadLocation2)"
-recurse
-filter
"*.csv")
$fileContents
=
Import-Csv
-Path
$file.fullName
foreach ($line
in
$fileContents)
$null
= Execute-NonQuery-Oracle -sql
insert into SU_EDIT_DETAIL(EDIT_FUNCTION,TABLE_FUNCTION,CODE_FUNCTION,CODE_TYPE,CODE_BEGIN,CODE_END,EXCLUDE,INCLUDE_X,OP_NBR,TRANSCODE,VOID,YMDEFF,YMDEND,YMDTRANS)
Values
('$($line."EDIT_FUNCTION")','$($line."TABLE_FUNCTION")','$($line."CODE_FUNCTION")','$($line."CODE_TYPE")','$($line."CODE_BEGIN")','$($line."CODE_END")',' ',' ', 'MIS', 'C', ' ', 20141001, 99991231,
20131120)
Vijay Patel

please read "PLEASE READ BEFORE POSTING"
This forum is about the Small Basic programming language.
Try another forum.
Jan [ WhTurner ] The Netherlands

Similar Messages

  • Business Components and oracle.jbo.domain.Date

    Hello I have the next problem I have a Busines Component and I have to acess to rows who have Dates and with oracle.jbo.domain.Date I can4t acess to the day, month, year .
    Can anyone Help me how can I do to access this dates?
    Thanks a lot your your help.

    Hi,
    This is the trilogy problem:
    oracle.jbo.domain.Date
    oracle.sql.DATE
    java.util.Date
    The question is how to translate from one object type to another.
    You can use the following:
    oracle.jbo.domain.Date tmpDate = null;
    SimpleDateFormat tmpLocalFormat = new SimpleDateFormat();
    SimpleDateFormat tmpLocalFormat2 = new SimpleDateFormat();
    // Obtenir la date du sommaire
    tmpDate = (oracle.jbo.domain.Date) session.getValue("DateElem");
    // Initialisation des objets de formatage de date
    tmpLocalFormat.applyPattern("yyyy-MM-dd");
    tmpLocalFormat2.applyPattern("dd-MM-yyyy");
    // Conversion du format de date yyyy-MM-dd => dd-MM-yyyy
    tmpWhereClause = new String(tmpLocalFormat2.format(tmpLocalFormat.parse(tmpDate.toString())));
    // Ajouter ` la clause "Where" la contrainte de la date
    tmpWhereClause = "DrqSommaireInitial.DATE_SOMMAIRE = TO_DATE('" + tmpWhereClause + "', 'DD-MM-YYYY')";
    Take a look also to class calendar...
    null

  • Save and refresh after entering data inoto table ( update)

    hello guys,
    im using abap webdynpro now. and im facing a problem with the saving and update " refresh function"
    I have entry table and some other text input.
    the thing im doing is to enter data in the filed, attachment, drop down selection. then the data will be saved into the table in the same page
    and need to refresh the page automaticlly when doing this. so the used does not have to do it manully
    please help me in this..code, source, or hints.
    Thanks
    Lily

    thanks Manas Dua 
    I could do that, but this is going to be problem with performance side.
    I want a method or something to make it easier, faster too
    please help me in code or something if that possible.
    Regards
    Lily

  • Save and refresh after entering data inoto table.

    hello guys,
    im using abap webdynpro now. and im facing a problem with the saving and update " refresh function"
    I have entry table and some other text input.
    the thing im doing is to enter data in the filed, attachment, drop down selection. then the data will be saved into the table in the same page
    and need to refresh the page automaticlly when doing this. so the used does not have to do it manully
    please help me in this..code, source, or hints.
    Thanks
    Lily

    well , the guys guid me to some ideas.
    yes..after entering data into filed, textinput. the data will goes to the table after clicking " save" button. after that I want the table to be updated.
    thanks

  • Duplicate data in table

    I am designing a form that has two tables. The user is supposed to enter their data in the first table, and that data automatically copies to the second table (so when they print the form, they have two copies of the same thing while only having to enter the data once).
    I created a dynamic input table with one row and set that row to repeat row for each data item, minimum count 9. This way, nine rows appear when the form renders and if we need to increase them later, it is a simple change of that number. Then, I set all of the table fields to global data binding and copied the table, setting the second table to read only.
    My problem is, when I enter a value in the first data entry field, it copies the data to the entire column of the table! I don't understand why it is doing this, since Adobe automatically renames duplicate fields (ie. row1Item will be row1Item[1], row1Item[2] and so on). I even went so far as to add a script to change the name of the fields:
    var rownum = this.parent.instanceIndex + 1;
    this.name = "rowItemInput" + rownum;
    But that hasn't helped at all. I still have the same problem.
    Any ideas as to what I am doing wrong?

    I set all of the table fields to global data binding
    This is what causing the problem.Remove Global to the fields and try it would work.You might get different data in each field.
    instead of making fields global.
    You need to keep the below script on the initialize of the duplicate table item field.
    this.rawValue = xfa.resolveNode("originalTable.Row2.Remarks").rawValue;
    Hope this works..!!
    Vjay

  • DECODE function in Oracle gives duplicate data

    Hi,
    I want to retrieve distinct result using decode function and given below are the queries for that.
    SELECT DISTINCT O.*, DECODE(TA,'AP',AMT,'AC1',AMT,'AC2',AMT,'AC3',AMT,'AC4',AMT,NULL) AS CA,
    DECODE(TA,'AD1',AMT,NULL) AS DA FROM HT O, HIS H, V_CV
    WHERE O.HID=H.HID AND H.HTYP='TRN' AND O.HID = V.HID AND V.CID = '5' ORDER BY CA ASC;
    which gives me
    HID   TA      PT     AMT     CA         DA
    2     A     V     4.1     4.1     null
    3     C     V     14.02 14.02     null
    1     D     V 5.1     null          5.1
    4     D     V     6.21     null      6.21
    which is correct but i want to do sorting on two different column which do not exit in the database and they are dynamic.So i Modified the Query but i am getting duplicate results
    SELECT DISTINCT O.*,
    DECODE(o.TA,cr.TA,o.AMT,NULL) AS CA,
    DECODE(o.TA,de.TA,o.AMT,NULL) AS DA
    FROM HT O,
    HIS H,
    V_CV,
    (select TA from RTD where Ttype= 'C') cr,
    (select TA from RTD where Ttype= 'D') de
    WHERE
    O.HID=H.HID
    AND H.HTYP='TRN'
    AND O.HID = V.HID
    AND V.CID = '5'
    ORDER BY CA ASC
    which gives me
    HID   TA      PT     AMT     CA         DA
    2     A     V     4.1     4.1     null
    3     C     V     14.02 14.02     null
    3     C     V     14.02 null      null
    1     D     V 5.1     null          5.1
    1     D     V 5.1     null          null
    4     D     V     6.21     null      6.21
    2     A     V     4.1     null     null
    which is obviously giving HID 2,3,1 as duplicate value since DECODE select a value and compares with all item where i want only single comparison.
    Any help regarding this would be appreciated.
    Edited by: Pawanchoure on Jul 5, 2011 7:14 AM

    Why don't you have any join conditions specified for your two inline views cr and de?
    If you want help with a query you should post DDL and inserts statements to create enough test data for someone to produce the set of results that you are looking for.
    HTH -- Mark D Powell --

  • NVARCHAR - NVARCHAR2 datatype mapping between sql server and oracle.

    Question regarding size allocation that occurs for NVARCHAR columns in sql server to NVARCHAR2 in Oracle in the migration tool.
    The migration tool has converted NVARCHAR columns to be twice their size as NVARCH2 in Oracle. Example, a table whose column is mycol NVARCHAR(40) gets migrated as mycol NVARCHAR2(80).
    In SQL Server land, the designation of a column as NVARCHAR(40) will physically store the column as 80 bytes. However, as I understand from this excerpt (taken from here: http://www.oracle.com/technology/oramag/oracle/03-nov/o63tech_glob.html), that Oracle in essence will do the same thing for NVARCHAR2:
    To make it easy to allocate proper storage for Unicode values, Oracle9i Database introduced character semantics. You can now use a declaration such as VARCHAR2(3 CHAR), and Oracle will set aside the correct number of bytes to accommodate three characters in the underlying character set. In the case of AL32UTF8, Oracle will allocate 12 bytes, because the maximum length of a UTF-8 character encoding is four bytes (3 characters * 4 bytes/character = 12 bytes). On the other hand, if you're using AL16UTF16, in which case your declaration would be NVARCHAR2(3), Oracle allocates just six bytes (3 characters * 2 bytes/character = 6 bytes). One difference worth noting is that for UTF-8, a declaration using character semantics allows enough room for surrogate characters, whereas for UTF-16 that is not the case. A declaration such as NVARCHAR2(3) provides room for three UTF-16 code units, but a single supplementary character may consume two of those code units.
    As I read this, NVARCHAR(40) in sql server should be equivalent to NVARCHAR2(40) in Oracle and not NVARCHAR2(80) as it gets translated to - am I missing something? We have a rather large database to migrate so I need to get this size allocation right (and I obviously don't want to truncate any data).
    Thanks -

    Right - well, that's what I'm suggesting is that NVARCHAR(8) in SQL Server is equivalent to NVARCHAR2(8) in Oracle. Truncation will occur after 8 of any character, including, say, double byte Kanjii characters, which would physically store 16 bytes in the NVARCHAR(8) NVARCHAR2(8) column defn. I tried that in both SQL Server and Oracle, and the behavior is the same.
    Also, technically, NVARCHAR2(8) and VARCHAR2(8 CHAR) is roughly the same in terms of behavior, except that in the first case, the physical storage is 16 bytes, while in the second case, it's 24 bytes (to account for 'supplemental' characters or true UTF-8 compliance). Same truncation occurs after 8 of -any- character be it single byte ascii or double byte kanjii, which is the behavior I expect.
    Thanks for looking into this. What I decided to do was the following:
    What was originally defined in SQL Server as varchar (and translated to VARCHAR2 with the CHAR designation), I removed the CHAR designation since I truly want that number of bytes to be stored, and not characters (for columns I do not care about UTF8 or 16 compliance - that will also mimic the same behavior I currently have on the SQL Server side. For anything that was nvarchar in SQL Server, I went ahead and created them as VARCHAR2 with the CHAR designation, with the same size (not double the value as was in SQL Server which the documentation says it gets translated to). I did this since we probably will need true UTF-8 compliance down the line, and since I had the hood open, it was easy enough to do. I could also have converted NVARCHAR(n) to NVARCHAR2(n) (and not n*2) as what was happening in the migration.
    I tested strings in both cases, and I think I have my solution.
    Edited by: kpw on Sep 24, 2008 11:21 AM

  • Database independant ETL in ODI for SQL Server and Oracle

    Hi,
    We have a requirement to create ETL which can be run for both SQL Server and Oracle.
    We have some tables to be filled from operational database to data warehouse using business requirement.Our goal is to create code which should be database independant.
    We will provide all DB details at the start of execution and it will code for as per provided details.
    The same can be achieved by Talend.
    I wanted to know if same can be achieved in ODI.
    Any pointers regarding this would be helpful.
    Thanks,
    Mahesh

    A quick trick: Provide one more value at the start of execution. It is something like a flag. For example db_flag. It can be either 'O' or 'S'.
    Open both  oracle and sql server KM. Copy one of the KM code to other KM and put an if condition to check the flag.
    if (#DB_FLAG.equalsTo("O")){
    Oracle code goes here...........
    }else{
    SQL Server code goes here...........
    Its a pure KM customization.
    Bhabani
    http://dwteam.in

  • Frequently transfering databases between MS SQL and Oracle

    Hello all,
    I am looking for a solution to easily, efficiently and be able to migrate/transfer databases between MS SQL and Oracle frequently.
    I need to be able to replicate a databases on Ms SQL and Oracle for testing purposes. I will need to do this on frequent basis - almost once a week.
    Please suggest what would be the best way.
    Thanks in advance.

    Hi Justin,
    You have guessed it right to a great extend. Yes dont actually need to develop, rather need to test an application that supports SQL and Oracle databases. Now when testing the application its obviously vital to create proper systematic test data. This usually takes a lot of time and effort from the testing team/team-member. So, yes what I need to do is create the test data on one database(may it be SQL or Oracle) and migrate/transfer the data into the database on another server( ie. SQL to Oracle or Oracle to SQL).
    So,
    Are you developing a product that works against both SQL Server and Oracle and trying to synchonize development efforts?Yes, thats correct to extend, I need to test an application against both the servers, as it supports both types of databases, and try to reduce the test setup efforts (literally double the amount) that go in after manual creating same data on each type of database.
    Are you trying to replicate structural changes between systems?I am not 100% sure, what you mean by this. But whats important and enough for me is to replicate the data. It would not be a lot of work to run the scripts and create empty schema objects.
    Are you trying to replicate data changes between systems? The fact that you're only doing this weekly suggests that you're not working in a traditional replication environment.Yes, again as I mentioned above. It would be sufficient for me to just get a copy of the initial dataset. And then replicating changes to it would not be that important. However, if I can achieve a solution to this, I can by all means create a new database on the one server (SQL or Oracle) and take the data-set of the most recent/correct changes and replicate it on the other type of server as and when needed.
    No - this is not a traditional replicating environment. I say weekly, because it is usually once in a week or forthnight that someone from the team will need to spent time to manually copy the test-data onto the another type of server in order to run the same testcases on two types of servers.
    How do you handle conflicts (i.e. if I modify a row in both systems, which modification wins)? This is not really a problem in my scenario, as I only need to be able to transfer the data across to the different server and forget about the two databases actually being in-sync.
    I have also, looked at DTS for a possible solution on SQL, however it seems highly un-realistic, having to map somewhere like 250 tables from the a drop-down list, only because the two database servers use different cases to represent tables internals. So, table 'Table' in my application's SQL database is called 'TABLE' is my applications Oracle database. DTS is highly inefficient in dealing with this. Also, having 250 tables move makes this a bit of a pain.
    Thank you Justin for your response; I highly appreciate your inputs.
    Regards, Nisarg

  • How to avoid duplicate data while inserting from sample.dat file to table

    Hi Guys,
    We have issue with duplicate data in flat file while loading data from sample.dat file to table. How to avoid duplicate data in control file.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    LKR

    No, a control file will not remove duplicate data.
    You would be better to use an external table and then remove duplicate data using SQL as you query the data to insert it to your destination table.

  • SQL and Oracle in synchronization

    I have to synchronize for about 2 months one Oracle 9.i database and one SQL server 2000, Standard edition database, both running on Win 2K Server. Every change made on either of the databases (the best is there are only 4-5 tables reflected) has to be provided on the other side almost in real time. I choused to use SQL server as a way to do it. For Oracle I have only the ODBC connectivity (supplied for free) and I did have a lot of problems in ORA 8.1.6... Needless to say, there's no money for third party products or even new ORA transfer utility, as the 2-month are not sufficient time.
    I did set up linked servers between SQL server and Oracle and trying to make some triggers working for me, but is this the best way to do it? May be somebody has better experience...
    Any ideas will be greatly appreciated.
    Thanks,
    MJ

    Do you really like to implement a two way replication between M$ SQL and Oracle?
    Maybe you can try this using the heterogenous gateway and Oracle Advanced replication. Don't know if this could work our test environment would be ready but actually there's no time to try.
    Will keep you informed if I know more.
    In this way you don't need any third party sw and I think it could work, but never have tried it out.
    Could be an interesing challenge ;-)
    Michel

  • Replication between Oracle and SQL Server

    Does anyone have any experience with replicating data between SQL Server and Oracle database system? If so, I am experiencing time out errors when replicating data. I replicating from SQL Server 2k to Oracle and it time out on the Oracle side.

    how to configure my apply process to work with sql server by getway , I want to make replication
    note :
    I make dblink between oracle and sql and make insert from oracle to sql
    is it sufficient to make replication by OEM between oracle and oracle and then add new apply process to work with gateway for sql server and how ?

  • I need step by step way to make replication between oracle and sql server

    I succeeded in make dblink between oracle and microsoft sql
    and I try to insert data using dblink to microsoft sql
    what will I do now to make replication between them

    how to configure my apply process to work with sql server by getway , I want to make replication
    note :
    I make dblink between oracle and sql and make insert from oracle to sql
    is it sufficient to make replication by OEM between oracle and oracle and then add new apply process to work with gateway for sql server and how ?

  • PHP and Oracle DB Job Find

    Hi every ones:
    I'm develop some applications using PHP and Oracle and php give me a lot of advantage. in bouth way of access to a database, OCI and mod plsql.
    How can i say to Oracle THANKS FOR TAKE SERIOUS PHP TECNOLOGY!!!
    I work actually for a company that implement all (Microsoft) and i want find a job with PHP and Oracle programming. Any body have idea that where i need look?

    How can i say to Oracle THANKS FOR TAKE SERIOUS PHP
    TECNOLOGY!!!You just did! Thanks!
    You can help Oracle with scripting languages even more, by completing the questionnaire on scripting langauges at:
    http://www.oracle.com/go/?&Src=1545492&Act=10
    Alison

  • How to find duplicate data

    Dear All,
    please help me.
    I have a table named OT it has two columns which i want to apply composite primary key. but when i apply it returns error ORA-02437: cannot vlidate - primary key voilated, i applied enable novalidate but error still there. please let me know how can i find where is and what is duplicate data.
    please reply thank you.....

    Isn't this easy to understand?
    create table test_table
      col1        number,
      col2        number,
      col         varchar2(1)
    insert into test_table values (1, 1, 'A');
    insert into test_table values (1, 1, 'B');
    insert into test_table values (1, 1, 'C');
    insert into test_table values (1, 1, 'D');
    insert into test_table values (1, 2, 'D');
    insert into test_table values (1, 3, 'D');
    insert into test_table values (1, 4, 'D');
    select *
      from test_table;
    COL1                   COL2                   COL
    1                      1                      A  
    1                      1                      B  
    1                      1                      C  
    1                      1                      D  
    1                      2                      D  
    1                      3                      D  
    1                      4                      D  
    7 rows selected
    delete
      from test_table a
    where rowid < (
                      select max(rowid)
                        from test_table b
                       where a.col1 = b.col1
                         and a.col2 = b.col2
    select *
      from test_table;
    COL1                   COL2                   COL
    1                      1                      D  
    1                      2                      D  
    1                      3                      D  
    1                      4                      D

Maybe you are looking for

  • Creating pdf from folders of files & retaining structure

    Hi there! I am hoping someone can tell me how to pdf entire folders of files into one file yet still retain the file structure so that it follows the logical sequence that it is already sitting in. I have several folders of folders with many hundreds

  • Strange Problem in HTML DB 2.0 version-

    I am creating one application which consists of 2 tab pages. At end of 2nd tab page, i will make a insert statement to insert data in database. Now, when i enter data in first tab page and go to next tab page, data from first page disappears. But on

  • Database home page not opening in oracle linux 4 after installation?

    I have just installed oracle 10g express edition R8 (32 bit) in oracle linux 4 (oem 4) which is running on vmware. After installation on going application(start)->oracle 10g express edition ->Go To database home page. Database home page starts on kon

  • I need a copy of asd 2.6.3

    I need this for my quad 2.5 GHZ G5. Anybody know where I can get a bootable copy?  Tim < Edited By Host >

  • Disabling Profit center in VA01 and VA02

    Hi geeks, I have a requirement where i need to disable the profit center column for some specific sales document types in VA01 and VA02. Please guide me with the User-exit to complete the requirement. -Jiyaaaa