![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| copy file to a directory by sequence | fooky | UNIX for Dummies Questions & Answers | 4 | 11-24-2007 10:40 PM |
| adding string to a file | andy2000 | Shell Programming and Scripting | 8 | 04-17-2007 04:29 AM |
| Catpuring the last entry of a repetetive sequence from a file! | jobbyjoseph | SUN Solaris | 4 | 11-15-2006 11:59 AM |
| How to extract a sequence of n lines from a file | 0ktalmagik | Shell Programming and Scripting | 4 | 06-30-2006 12:24 AM |
| appending string to text file based on search string | malaymaru | Shell Programming and Scripting | 1 | 06-09-2006 09:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Adding a sequence string to a file
I have a pipe delimited file I need to add a sequence number to in the third field. The record fields will be variable length, so I have to parse for the second pipe. Another requirement is that the sequence number must be unique to all records in the file and subsequent files created, so the sequence numbers will be maintained by an Oracle sequence.
I'm thinking basically select nextval into a variable and insert it, but I'm not that certain on the best approach to doing so with a ksh. Any ideas on how to insert this sequence in a ksh? I'm not very familiar with sed/awk. TIA before: rec1field1sdss|rec1field2||rec1field4|rec1field5 rec2field1ff|rec2field2sds||rec2field4sdsds|rec2field5 rec3field1qwe|rec3field2wsxd||rec3field4sds|rec3field5 after: rec1field1sdss|rec1field2|1|rec1field4|rec1field5 rec2field1ff|rec2field2sds|2|rec2field4sdsds|rec2field5 rec3field1qwe|rec3field2wsxd|3|rec3field4sds|rec3field5 |
|
||||
|
maintaining the sequence number
Thanks for the help. I would love to use the ksh only method, but I have to maintain the sequence number across multiple files.
ex: file1: field1|field2|1|field3... field1|field2|2|field3... file2, which will be generated on the following day: field1|field2|3|field3... field1|field2|4|field3... These sequence numbers must remain unique to the records across files so we can keep track of them. They will be sent to a vendor and they will send them back at a later time. The boss wants to use an Oracle sequence to maintain uniqueness across all records sent out. Any ideas? TIA |
|
|||||
|
If you must use oracle sequence to put sequence number in file then You may need to use UTL_FILE package of oracle.
Other method is create some temp table in oracle load these files into that table with sql loader utility with third field as oracle sequence.Now select all records from that table concatenated with | and spool that file. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|