PDOX4.5--Comparing fields between records (except ONE field)

PDOX4.5--Comparing fields between records (except ONE field)

Post by DANIEL DESORMEA » Tue, 18 Apr 1995 04:00:00



Hey all,

        I need some help to figure out a way to compare two records in a
table with PDOX4.5 for Windows to see if the records match.  What I want to
do find out is if there's a way to compare field values EXCEPT for ONE
specific field.  I don't like the idea of comparing ALL fields one by one (
it makes one heckuvan "if" statement with the table I'm working with --
about 25 different fields).

Thanks to anyone that can help.

 
 
 

PDOX4.5--Comparing fields between records (except ONE field)

Post by Karen Reardo » Tue, 18 Apr 1995 04:00:00


Quote:>    I need some help to figure out a way to compare two records in a
> table with PDOX4.5 for Windows to see if the records match.  What I want to
> do find out is if there's a way to compare field values EXCEPT for ONE
> specific field.  I don't like the idea of comparing ALL fields one by one (
> it makes one heckuvan "if" statement with the table I'm working with --

I'm sure there is a better way to do this in ObjectPAL, but I had to
do this in DOS once to verify duplicate dataentry into a database that
had to submit data to the state.  I did a scan loop that bounced from
table to table, field to field and compared.  You could have it skip
the field you don't want.  I also then had it show any fields that
didn't match, I put them into a different table.  Would be interested
in how you could do this better in ObjectPAL.
karen Reardon

 
 
 

PDOX4.5--Comparing fields between records (except ONE field)

Post by Todd Fa » Tue, 18 Apr 1995 04:00:00



Quote:

>Hey all,

>        I need some help to figure out a way to compare two records in a
>table with PDOX4.5 for Windows to see if the records match.  What I want to
>do find out is if there's a way to compare field values EXCEPT for ONE
>specific field.  I don't like the idea of comparing ALL fields one by one (
>it makes one heckuvan "if" statement with the table I'm working with --
>about 25 different fields).

>Thanks to anyone that can help.

Well, an easy way to make your field-by-field comparison would be to use
TCursor::copyToArray() (or UIObject::copyToArray() I suppose).  Use this method on
both records, putting the values into DynArray's.  Then, use forEach on them to iterate
through the arrays and do the comparison.  This is what I'm thinking:

var
        ar1     DynArray                AnyType
        ar2     DynArray                AnyType
        Field   String
endvar

TC.attach(....)

TC.<find first record>
TC.copyToArray(ar1)

TC.<find second record>
TC.copyToArray(ar2)

forEach Field in ar1
        if not ar1[Field]=ar2[Field] then
                <error>
                quitloop
        endif
endForEach

This method above will only work with records that have been posted already.  If you need
to compare an unposted record to a posted one, things are slightly more complicated
because you need to access the record buffer.  You have two options that I can think of.  
The first is use the UIObject version of the copyToArray() method for the unposted
record, which should access the record buffer automatically.  The second option is not so
clean:  use dmGet() on the unposted record, which will be fairly tedious because you'll
have to do it on each field individually.  Good luck.

Todd
--
====================================================================

"His mind is somewhat too much taken up with his mind." - John Earle
My employer couldn't possibly have such great ideas; therefore, the
ones expressed above must be my own.  :-D
====================================================================

 
 
 

PDOX4.5--Comparing fields between records (except ONE field)

Post by Mathew Gyokers Eli » Wed, 19 Apr 1995 04:00:00


 The easy way to reference fields if you don't know their names or
just have too many is to do it by the ordinal # of the field:

tc.(xx) ....

Where XX is some integer value the represents the field you want to address
in the TC.

So if you knew there were 5 fields in the table:

var
siloop smallint
endvar

for siloop from 1 to 5
if tc1.(siloop)<>tc2.(siloop) then
msgstop("Hey!","Got a mismatch here "+tc1.(siloop)+"\n"+tc2.(siloop))
endif
endfor

---

sorry, meant to put that inside of a scan loop.

Now in your situation, if the field you didn't care about was #4, then
inside the for loop do:

if siloop=4 then loop endif

to have it skip that #.

To make it easy on yourself, you could write a query that returned all of the
fields except the ones you wanted, then go into the scan loop and IF
comparisons.

If you didn't want to rely on your knowledge of the table's # of fields,
then you could use ENUMFIELDxxxx xxx=names of structure, etc.

That'll get you partway there I think.

--
Beavis kicks ASS! He KICKS 'em! Kicks, KICKS!  He rules, he RULES, RULES!!

 
 
 

PDOX4.5--Comparing fields between records (except ONE field)

Post by Kuo-Sheng (Kas » Fri, 21 Apr 1995 04:00:00


:       I need some help to figure out a way to compare two records in a
: table with PDOX4.5 for Windows to see if the records match.  What I want to
: do find out is if there's a way to compare field values EXCEPT for ONE
: specific field.  I don't like the idea of comparing ALL fields one by one (
: it makes one heckuvan "if" statement with the table I'm working with --
: about 25 different fields).

Just use a variable to store things.  You can refer to fields by, uh,
moving fields, I think.  (use keyboard macros, if I remember correctly,
like RIGHT, since PDOXDOS put tableview for traversals)

--
+==========================================================================+

| Pretty good Paradox for Windows Programmer                               |
| Self-proclaimed Treknologist                                             |
| Editor XCOM: Unofficial Strategy Guide http://userwww.sfsu.edu/~kschang  |
+==========================================================================+

 
 
 

1. Duplicating Rows In a recordset (well except for one field)

Im trying desperatelly to duplicate the rows of a recordset (and also the
values), and I keep get exceptions.... I need a pseaudo code for that:

I tried using:
    flds = rs.getFields
    rs.addNew
    fld = flds.getfield
    rs.moveFirst
    item = fld.getvalue
    rs.moveLast
    fld.putValue(item)

but it sucks.
I also tried using getRows, but it seems like it doesnt act like as the
documentation claims...
any ideas ? (a sample code for that would be just great).

2. deleted access still allows access

3. Field length modification results in deletion of field in reports, forms PDOX4.0

4. US-AR-ORACLE BACKEND PROGRAMMER

5. insert data from one field in one table to another field in another table

6. Trigger script on field exit?

7. Need Help: search/replace data in one field/one record, by queries or script: PDOX5

8. Start up oppportunities

9. When comparing a field name with a column name of more than one word

10. How to copy a field from one record to a related record in the same database

11. Copying a record in a field to several records in same field

12. Comparing a Null field with a char field

13. How to Compare Tables, Fields, & Field Properties