No sorting in the temp table

Kayal

New Member
I have 26k records in a file ( say, Input ), and I want to pass it to the temp table in the same order that I have in my input file ; How is this possible?
 

TomBascom

Curmudgeon
I'm not sure what you mean by "pass", I'm assuming that you mean that you wish to populate a temp-table with the contents of a file. Here is an example:

Code:
/* given a file named "data.txt" whose contents are:
abc
xyz
def
fred
george
xyzzy
 */

define temp-table tt_example no-undo
  field f1 as character format "x(30)"
.

input from value ( "data.txt" ).
repeat:
  insert tt_example.
end.
input close.

for each tt_example:
  display f1.
end.
Your actual problem likely has a more complicated structure ;)

In this example the key to "in the same order" is that I did not bother to create an index on the temp-table. That may, or may not, be a suitable solution for your problem space. But given the lack of insight into what you actually need I have decided to go with a minimalist approach. Clarified requirements might result in a different approach.
 

tamhas

ProgressTalk.com Sponsor
By the same token, if the above satisfies your need, you could use a WORK-TABLE instead of a TEMP-TABLE.
 

TomBascom

Curmudgeon
Yes. But using work-tables with large data sets is risky. It is very easy to exhaust memory that way. And if you happen to do that on the server the server will crash.
 

tamhas

ProgressTalk.com Sponsor
True enough ... but testable. I just think that people forget about work-tables these days, but they are a good fit for some use cases.
 
Top