Loop-Problems, Newbee needs help

Sabrina01

New Member
Hi All,

I need help -.- Since 2 days I'm trying to build a CSV-Database-Export with Progress, but no success till now...
(btw: I'm from germany and my english is not even the best, so I hope you will understand my Problem)
I am at home now so I can't even post my Code -.-

The Problem is the loop-code, which means I declare the String 'R,L,B,D,G', these are the possible entrys in my Table.Type - Field.
There is also a Table.RefNr - Field, Table.Type and this one together are building the Primary-Key.
Now I intended to go by a do-block with if-block inside to get every TYPE-REFNR combo. I just want every row in this CSV, I opened the Stream and it wont stop to write,
this means I always have to kill the Code cause it doesn't stop after round about 550.000 sets of Data (big Table) it just starts all over.

Please help me 1 week ago I started with Progress nearly 0 programming experiences...

Greetings from Germany, Sabrina
 

Stefan

Well-Known Member
Actual code breaks all language barriers. Are you trying to do the following?

Code:
OUTPUT TO 'table.csv'.
FOR EACH table WHERE LOOKUP( table.type, 'R,L,B,D,G' ) > 0 NO-LOCK:
   EXPORT DELIMITER ';' table.
END.
OUTPUT CLOSE.

Note that the query above will result in a table scan (due to the lookup function). If you have an index with type and refnr and RLBDG would result in a small subset of the records then you could consider:

Code:
DEF VAR cc AS CHAR INIT 'R,L,B,D,G'.
DEF VAR ii AS INT.

OUTPUT TO 'table.csv'.

DO ii = 1 TO NUM-ENTRIES( cc ):
   FOR EACH table WHERE table.type = ENTRY( ii, cc ) NO-LOCK:
      EXPORT DELIMITER ';' table.
   END.
END.
OUTPUT CLOSE.
 

Sabrina01

New Member
Thanks a lot Stefan!

Your second piece of code looks like excactly what I was tryin to build.
I see it can be so simple... my code contains round about 40 lines -.-*

Greetings
 

Cringer

ProgressTalk.com Moderator
Staff member
If you're still having trouble and it's easier to post in German I can translate for you... :)
 
Top