Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import into 9.1 table from excel or csv

Status
Not open for further replies.

fumbles

Programmer
Dec 9, 1999
43
0
0
US


Hi All -

I need to import values from a csv or excel into an existing field in an existing table in our database. We are updating price records in excel and would like to load them into an existing user field in the item table so we can do a bulk replace when the new pricelist date occurs. I do not program in progress other than to do very simple batch files in the character editor.

I can structure the csv by the item record that will correspond to the item record in the table. What commands would accomplish this?

Thanks in advance for any help.


Steve
 
Here's a basic skeleton of the code needed when your CSV file has two fields: item-id and price.

Code:
define temp-table t-input
    field t-item-id
    field t-item-price.

input from [input-csv-filename] no-echo.
repeat:
    create t-input.

    import delimiter "," 
        t-input.t-item-id 
        t-input.t-item-price.

end.

input close.

for each t-input:
   find item where item.item-id = t-input.t-item-id
        exclusive-lock no-wait no-error.
   if available item 
     then item.price = t-input.t-item-price.
   else message t-input.t-item-id " not found or locked."
        view-as alert-box.
end.
This will display items unavailable for update in a pop-up message box. You could adjust it to write errors to a logfile if desired.
 
thanks Michael - tweaked a little and it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top