1748159 Members
4089 Online
108758 Solutions
New Discussion юеВ

Incrementing in a script

 
SOLVED
Go to solution
rmueller58
Valued Contributor

Incrementing in a script

I have another flat file output result from Informix DB delimited with a pipe '|'


5995|0|1|JobApplicantCenterIssues.doc|5995_0_1.doc|
5996|2|1|test.doc|5996_2_1.doc|
177|0|2|Capacity Standards.doc|177_0_2.doc|
177|0|3|Capacity Standards.doc|177_0_3.doc|
177|0|1|Mentor Luncheon Conversations - Nov 07.doc|177_0_1.doc|
5996|0|1|Job Postings.doc|5996_0_1.doc|
177|0|4|Capacity Standards.doc|177_0_4.doc|
5997|0|1|test.txt|5997_0_1.txt|
177|0|5|AGENDA%20January%2019,%202009.pdf|177_0_5.pdf|
177|0|6|Empl_Verification_ssn.doc|177_0_6.doc|
177|0|7|Email Payroll Vouchers Custom.doc|177_0_7.doc|

COLUMN1 = appID
COLUMN2 = IterID (ALWAYS '0' Zero)
COLUMN3 = docID (may have multiples per appID)
COLUMN4 = Descriptive File Name(string)
COLUMN5 = stored File name

Column 5 = appID_IterID_docID.ext

The School is staging documents in a "staging area" that will be in the following Format:
EXAMPLE: Transcript1__0_.ext
EXAMPLE: LOR1__0_.ext
EXAMPLE: LOR2__0_.ext
EXAMPLE: Review2009_< appid>_0_.ext

For each document loaded to the staging location I need to check the docID in the SQL output and increment the docID beginning at 6 up to 100 so each record re-inserted will be unique.

I am looking for a way to define a counter for this and create an entry into a flat file like the one above, and copy the file and rename with the incremented docID.

I am using the "original file name" to base the "storename"

I am using an awk -F_ '{print $#}' to define each piece of the file name as a variable..

I wanted to pick brains again on this incrementing.

Any ideas appreciated
22 REPLIES 22
OldSchool
Honored Contributor

Re: Incrementing in a script

I'm afraid I'm not following how you want to transform this...ie: i don't see any relation from whats in the flat file and what in the EXAMPLE columns (they appear to be disjoint, at least to me).

Might help if you posted the awk you've got to date as well....
rmueller58
Valued Contributor

Re: Incrementing in a script

OLDSCHOOL,
Sorry for the confusion..

The table contains information about Documents..
||||

The unique identifier is docID.

I need to get information from the table for each and beginning at number 6 increment the by +1


rmueller58
Valued Contributor

Re: Incrementing in a script

There will likely be multiples for each appID, the only uniq identifier for each is the docID.
From the process I need to begin incrementing at number 6, if number 6 is taken, on to number 7 and so on.

OldSchool
Honored Contributor

Re: Incrementing in a script

Given:
EXAMPLE: Transcript1__0_.ext
EXAMPLE: LOR1__0_.ext
EXAMPLE: LOR2__0_.ext
EXAMPLE: Review2009_< appid>_0_.ext


Where in the flat file illustrated do you find LOR1 TRANSCRIPT...et all....I still see no connection between the data illustrated and the examples given

rmueller58
Valued Contributor

Re: Incrementing in a script

5995|0|1|JobApplicantCenterIssues_5995_0_1.doc|5995_0_1.doc|
5996|2|1|test_5996_2_1.doc|5996_2_1.doc|
177|0|2|Capacity Standards_177_0_2.doc|177_0_2.doc|
177|0|3|Capacity Standards_177_0_3.doc|177_0_3.doc|
177|0|1|Mentor Luncheon Conversations - Nov 07_|177_0_1.doc|
5996|0|1|Job Postings_5996_0_1.doc|5996_0_1.doc|
177|0|4|Capacity Standards_177_0_4.doc|177_0_4.doc|
rmueller58
Valued Contributor

Re: Incrementing in a script

OldSchool,

The String for "Descriptive Name" may vary, this is something that will fill a database field.
OldSchool
Honored Contributor

Re: Incrementing in a script

The String for "Descriptive Name" may vary, this is something that will fill a database field.

right..i got that...i got all the other stuff...but note of the EXAMPLES correspond to the DATA???? I know YOU know what/where DESCRIPTIVE NAME comes from....but I don't see it
rmueller58
Valued Contributor

Re: Incrementing in a script

IN the file name:

docID for 177 is 2 and 3 so far, there are two sources for this, slots 1-5 are loaded by a web client but 6-99 will be staged by the client through a scanning process.


177|0|2|Capacity Standards_177_0_2.doc|177_0_2.doc
177|0|3|Capacity Standards_177_0_3.doc|177_0_3.doc

SO for any new documents scanned for 177 I would need to increment record as follows:
177|0|6|Capacity Standards_177_0_6.doc|177_0_6.doc

for NEXT
177|0|7|Capacity Standards_177_0_7.doc|177_0_7.doc

Hope this makes more sense.
rmueller58
Valued Contributor

Re: Incrementing in a script

the "DESCRIPTIVE NAME" the original file name..

The application stores the document as "storename" so it strips off the front string. God only knows why.. That is out of my control.

I need to just take what they give me increment, but a flat file to load back into informix.