Still searching how to load the content of a .d file

Marie_epf

New Member
Hi All

I still can't load the content of a .d file in the table which is in a Progress database.

After deleting of the table's fields I create a query and a buffer I open the query and try this:

DEF VAR handle_fields AS HANDLE EXTENT 100.
DEF VAR i AS INTEGER NO-UNDO.
DEF VAR rows AS INTEGER NO-UNDO.

DO i=1 to rows:
handle_fields = blo:BUFFER-FIELD(i).
END.

qlo:GET-FIRST().

REPEAT:
IF qlo:QUERY-OFF-END THEN LEAVE.
DO TRANSACTION :
input from value(get-value("input")).
qlo:GET-CURRENT(EXCLUSIVE-LOCK).
blo:BUFFER-CREATE().
DO i=1 to rows:
handle_fields:BUFFER-VALUE = get-value(handle_fields:LABEL).
import handle_fields:BUFFER-VALUE
END.
input close.
END.
qlo:GET-NEXT().
END.
DELETE OBJECT blo.
DELETE OBJECT qlo.
END.

It doesn't work so if someone has an idea ...
Thanks
 

MSilva

New Member
Hi!

I don't know if I really understood your problem... You want just to LOAD data in your table???

Your ".d" file is a normal delimited text file containing DATA ??

You table is a normal already created table???

It seems that you prog is a little bit confusing...

Create a new procedure and Try this:

input from "your_file.d" .

repeat:
create yourtable.
import delimiter ";(or other separator according you text file)"
first_field second_field third_field and_so_on .
end.


Sorry, if i did not understand the problem...




MSilva
 

Marie_epf

New Member
Hi MSilva

You've understood my problem.
My table is already created and I want to load new data in.
But the fact is this program is used for many tables which have differents fields .....So I can't do as you told me because I don't know the fields' name...

Thanks for your help!!!!
 
Hi,

You may try this one:

def var s as char no-undo.
s = "mytable".

output to load.p.

put unformatted "input from " + s + ".d." skip.
put unformatted "repeat:" skip.
put unformatted " create " + s + "." skip.
put unformatted " import " + s + "." skip.
put unformatted "end.".

output close.

run load.p.


Best regards,
Gabor
 

Marie_epf

New Member
I know that all of this is working with progress but it doesn't work when you put it in webspeed .....

I need speedscript
thx
 

Marie_epf

New Member
maybe it would be possible to display the content of the file and then to put it in the table ...

If someone has an idea......


Thx All
 
Here's a procedure I have written to do a dynamic load of a table.

There is a bit of a trick with the multi-extent fields which makes it more complex than I'd like (all the li_extra stuff). If anyone has any improvments please post.

The stream ls_in needs to be defined in the main block (it could probably be passed as a handle?). Could really do with some more error checking in case .d format is incorrect.

Code:
PROCEDURE LoadTable :
/*------------------------------------------------------------------------------
  Purpose:  load a progress table from .d data file
------------------------------------------------------------------------------*/
def input parameter ipc_TableName as char no-undo.
def input parameter ipc_DataFile as char no-undo.

def var lh_buffer as handle no-undo.
def var lh_field as handle no-undo.

def var lc_fields as char extent 255 no-undo.
def var li_idx as int no-undo.
def var li_idx2 as int no-undo.
def var li_extra as int no-undo.

create buffer lh_buffer for table ipc_TableName buffer-name "lb_table".

input stream ls_in close.
input stream ls_in from value(ipc_DataFile).

repeat:
    import stream ls_in lc_fields.

    /* skip junk progress data admin places at end of file */
    if lc_fields[1] = "." and lc_fields[2] = "" then leave.
    li_extra = 0.

    do transaction:
        lh_buffer:buffer-create().
    
        do li_idx = 1 to lh_buffer:num-fields:
            lh_field = lh_buffer:buffer-field(li_idx).

            do li_idx2 = 1 to max(1, lh_field:extent):
                if lh_field:extent = 0
                then lh_field:buffer-value = lc_fields[li_idx + li_extra].
                else assign
                    li_extra = li_extra + 1 when li_idx2 > 1
                    lh_field:buffer-value(li_idx2) =
                        lc_fields[li_idx + li_extra].
            end.
        end.
    
        lh_buffer:buffer-release().
    end. /* transaction */

end.

input stream ls_in close.

END PROCEDURE.

This should work fine with run-time only progress, unlike the load.p solution.


Simon.
 

Marie_epf

New Member
Thank tou very much Simon your procedure works very well and you have to define ls_in as:

define stream ls_in.


That's all !!!

THX ALL
 
Top