Home » SQL & PL/SQL » SQL & PL/SQL » Insert statement to read values from a file
Insert statement to read values from a file [message #2533] Wed, 24 July 2002 02:50 Go to next message
shad
Messages: 50
Registered: October 2000
Member
Hi all.

I have a table with about 38 columns.
I would lie to add new rows for only 9 columns (or for all columns but with values in 9 coumns and null values in the rest).
I would like to create a script file that will insert new records into a table because I have a lot of rows to be inserted.

The insert statement must read values from a file say (say in csv format). Is there an easier way to do this? How do I make sure the INSERT statement reads values from the file and I do not have to hardcode the values in the Values Clause of INSERT.

Below is how I started tackling a problem.
------------------------------------------------------
ACCEPT ref prompt 'Please enter the client reference number:'
ACCEPT date prompt 'Please enter the transaction date:'
ACCEPT type prompt 'Please enter the transaction type:'
ACCEPT custody prompt 'Please indicate if custody is used:'
ACCEPT amount prompt 'Please enter the custody amount:'
ACCEPT vatamount prompt 'Please enter the custody vat amount:'
ACCEPT user_id prompt 'Please enter the user id:'
ACCEPT method prompt 'Please enter the payment method:'
ACCEPT total_amount prompt 'Please enter the total amount:'
insert into wams.transactionlog
(clientref,transactiondate,transactiontype,custody,
custodyamount,custodyvatamount,userid,paymentmethod,totalamount)
values (&ref,&date,&type,&custody,&amount,&vatamount,&user_id,&method,&total_amount);
------------------------------------------------------
Cheers
Shad
Re: Insert statement to read values from a file [message #2534 is a reply to message #2533] Wed, 24 July 2002 03:43 Go to previous message
Epe
Messages: 99
Registered: March 2002
Member
If using a csv-input file, I'd use sql-loader instead of an insert-script...
Previous Topic: Program constructs
Next Topic: Stored procedures
Goto Forum:
  


Current Time: Thu Apr 25 17:15:26 CDT 2024