0

Hi I am using DATASTAGE to import hive data into Oracle, I don't have any primary key constraints in hive but on Oracle I am having a combination primary key. For example I have a data which doesn't have duplicates on basis of whole record but the pk constraints has duplicate Table has columns Table name: item_details ;--(hive) no primary key constraints

Id mfg_date item exp_date


1 12-01-2018 abc 31-03-2018

2 12-01-2018 cde 28-02-2018

3 15-01-2018 efg 10-04-2018

4 12-01-2018 abc 10-04-2018

Where the mfg_date and item together are primary key for the target table(Oracle) which is same structure.

And I need to push the data into target table.

But it says a primary key violation and gets aborted.

Can anybody give me a solution.

Ps. We cannot change the schema for the tables

3
  • Remove the duplicates to avoid that error Commented Feb 13, 2020 at 18:19
  • That is not possible, IAM not the owner of the source data Commented Feb 15, 2020 at 3:19
  • Well there is a remove duplicate stage in DataStage - so it is possible Commented Feb 15, 2020 at 9:24

1 Answer 1

0

This is what I use [[twt]] for. it's faster than doing Lookup and join stages.

start by changing the output sql from Insert to Custom SQL.

then you can create a custom SQL Statement like the one below:

insert into <<target table>>
select Id, mfg_date, item, exp_date from [[twt]]
where not exist (select 1 from <<target table>> where <<target table>>.id = [[twt]].id)

it'll fire off records that don't exist. because custom sql allows for multiple statements, you can do your whole update this way.

By using [[twt]], you can change this to an ELT form of loading, and control the inserts.

thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.