Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Records From Another Table 1

Status
Not open for further replies.

wrgt9740

Programmer
Dec 5, 2020
35
PH
I've been reviewing the clipper code of our programmer who has already left, and I could not see how he was able to update records of a different table.
The two tables involved are ITEMS.DBF and TRANSACT.DBF. ITEMS.DBF has fields CODE and DESCRIPTION, while TRANSACT.DBF has fields INVOICE, CODE and DESCRIPTION. Values of CODE and DESCRIPTION of TRANSACT.DBF are taken from the same field names of ITEMS.DBF. In ITEMS.DBF, when the DESCRIPTION is updated, somehow the DESCRIPTION of TRANSACT.DBF is also updated.
I suspect indices of tables created at the start of the program are responsible, but I could not see in the code how the two tables are connected.
I also studied the code for ITEMS.DBF on how it updates records using SELECT ITEMS, REPLACE ITEMS->DESCRIPTION WITH [value] commands, but nothing was mentioned about TRANSACT.DBF.
Sorry if what I'm describing is confusing. I'm also confused.
 
Are you absolutely sure the two descriptions are meant to be updated to match? I would have imagined that the
description in the transact table would refer to a description of the transaction not the item.

I can imagine the default could be matching the item, but why update it, if you can refer to the current item via the code
to get the current description.

There is no 'cascade' function in Clipper (god, it has been a while - I think I have seen cascade in some 1980s dbms ? Delta
or DataEase? - maybe some Borland thing? Delphi? Paradox?)

I would search for lines with REPLACE and DESCRIPTION on the same line or perhaps the original programmer wrote a UDF to
cascade changes in which case you are perhaps looking for a macro substitution such as
Code:
REPLACE &

If I had to do this, I would have made a UDF with parameters for the target table, fieldto replace, value to replace and code to search for.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
The two descriptions are the same. This database design is not ideal, but it's what the programmer created. If in ITEMS.DBF, PEN and BLUE as CODE and DESCRIPTION would be one record, then TRANSACT.DBF would also have PEN and BLUE as CODE and DESCRIPTION, plus other details like invoice number, quantity, price, etc. But if I would update ITEMS.DBF and change to RED, then TRANSACT.DBF would also magically change to RED.

There is no 'cascade' function in Clipper (god, it has been a while - I think I have seen cascade in some 1980s dbms ? Delta
or DataEase? - maybe some Borland thing? Delphi? Paradox?)

I don't have much knowledge in database programming, and I'd like to know more about this.

I'll keep looking at all of the .PRG files for what you suggested. This is more or less the code to update ITEMS.DBF:

@ 6,30 say eCODE
@ 7,30 get eDESCRIPTION
read
...
replace ITEMS->DESCRIPTION with eDESCRIPTION
index on CODE to ITEM1
release all
return
...

then nothing about TRANSACT.DBF
 
Well, that would only update ITEMS not TRANSACT.

If you are willing, send me the code all zipped up you can find me through your favourite
search engine : f i n e d a t a dot c o m

I'm sure you will work it out. Not looking to charge (or do much frankly) or steal your code.

Odd that the programmer wanted an index on code after replacing the description... which
should not be required anyway.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Thank you for the offer, but I wouldn't want to bother much of your time. I'll just keep scanning the PRG files.
 
Cool, I offered because I have to tools to search the code.

Do you know which version/compiler/linker is being used?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Did you find anything?

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
sorry for the delay. i still haven't found anything from the prg files yet. i think the programmer used clipper 5.2. i saw a folder named "clip52" and a file inside named "clipper.52".
 
Well good luck, even running a Clipper app is somewhat challenging in the modern (64bit) age.

I think I have a 5.2 compiler somewhere, but not used it in a while!

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Wrg,

Even if you can't want to share the code, we can try and help you with debugging and stepping through it. Do you have a Clipper compiler, so that you can recompile with a debug option?

Alternatively, depending on whether it used third-party libraries, you might be able to compile, run and debug it in Harbour, using one of the IDEs available.

Assuming it doesn't use any third-party libraries, you could just share the names of the prg files, and we could write a batch file that compiles the program so that you can step through it.

Anyway, it's all up to you, wrg. Let us know how you want to proceed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top