Oracle Loader Help - Variable Field

Asked

Viewed 20 times

0

I need to download a file .txt with multiple records for one table.

But this table contains a field (Seq) that does not exist in the text file and this field should always be 1 and 2. For example: the first imported record will be marked as 1, the second as 2, the third as 1, the room as 2, the fifth as 1, so on and so forth.

They gave me the idea to do it using for and if, but I couldn’t.

Follow the command of the Loader:

load data

infile '/home/oracle/dados1.txt'

badfile '/home/oracle/exemplo3.bad'

discardfile '/home/oracle/exemplo3.dsc'

truncate

into table produtos

fields terminated by ","

( codigo, nome, seq, data_inclusao )

1 answer

0

You can create a variable and initialize it as 1. In Insert you add it, after Insert checks and modifies it:

if variavel == 1 then 
   variavel := 2 
else 
   variavel := 1 
endif

I hope I’ve helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.