How do you delete a relational record ? Pdox 5

How do you delete a relational record ? Pdox 5

Post by Shahid Ikram Bu » Mon, 03 Oct 1994 11:58:20



Hello all,

I have been trying to find a way but have not been able to figure out
how to delete a record that doesn't just have data in one table but
several. For example we keep customer's address and phone information
in one table and invoice and other merchandise information in another.

As of now, I do not know of a way to delete a customer so that all his/her
other records in other tables get deleted too.
How do you delete one entry so that all relational entries get deleted too ?

Any help will be greatly appreciated.

Thanks.

Shahid

                  Cruising Information Super Highway

 
 
 

How do you delete a relational record ? Pdox 5

Post by Greg Dunl » Tue, 04 Oct 1994 05:55:40




Quote:

>Hello all,

>I have been trying to find a way but have not been able to figure out
>how to delete a record that doesn't just have data in one table but
>several. For example we keep customer's address and phone information
>in one table and invoice and other merchandise information in another.

>As of now, I do not know of a way to delete a customer so that all his/her
>other records in other tables get deleted too.
>How do you delete one entry so that all relational entries get deleted too ?

Paradox does not support this type of activity, which is called a cascaded
delete. You either have to go through and delete all the individual dtail
records by hand before seleting the master record, or write code which will
accomplish the same thing.

--
Greg Dunlap

J-J-J-J-J-Jackpot!

 
 
 

How do you delete a relational record ? Pdox 5

Post by Shahid Ikram Bu » Tue, 04 Oct 1994 07:49:58



>Paradox does not support this type of activity, which is called a cascaded
>delete. You either have to go through and delete all the individual dtail
>records by hand before seleting the master record, or write code which will
>accomplish the same thing.
>--
>Greg Dunlap


Would you be so kind to give me an example of a code ? Or a rough approach ?

Thanks.

Shahid

                  Cruising Information Super Highway

 
 
 

How do you delete a relational record ? Pdox 5

Post by Kuo-Sheng (Kas » Thu, 06 Oct 1994 09:44:41




: >Paradox does not support this type of activity, which is called a cascaded
: >delete. You either have to go through and delete all the individual dtail
: >records by hand before seleting the master record, or write code which will
: >accomplish the same thing.

: Would you be so kind to give me an example of a code ? Or a rough approach ?

Use two tcursors:

tcmaster.attach(MasterTable)
tcdetail.attach(DetailTable)

;assume tcdetail is on the first record, if not use locate first

tcdetail.deleterecord() ;wipe out the current
while tcdetail.locatenext(MyField,"MyData")
  tcdetail.deleterecord()
endwhile
tcmaster.deleterecord() ; wipe out the master

There's probably a few steps missing the the idea is there...

--
==============================================================================

||   (the rest of this .sig is under construction...)                       ||
==============================================================================

 
 
 

1. rs deletes record while doing insert?

Hello, all.  I've been tracing a problem with ADO all day and I thought I
might see if anyone has any suggestions.  I have a server recordset
(adUseServer) using optimistic locking (adLockOptimistic) which is a Keyset.
The datasource is SQL7, but I'm connecting through a DSN, so I suppose I'm
using the ODBC provider.  I loop through this recordset and do the
following:

Insert 1 new record
Delete 1 existing record
Insert 4 records
Delete 2 records

It never makes it to the second set of delete operations.  While inserting
the 4 records, the first of the two records to be deleted disappears.  I've
triple checked to ensure that my code isn't accidentally deleting this
record and that the record is in fact in the recordset prior to these
inserts.  In both cases all is as expected, the records are there and the
code is only doing an insert.  To elaborate, by insert I mean I'm calling
rs.AddNew, calling rs!Field = Value for each value, then calling rs.Update.
For the deletes, I'm calling rs.MoveFirst, then rs.Find "Key = KeyValue".
Then if Not rs.EOF, I call rs.Delete adAffectCurrent.  When I get to the
second set of deletes, rs.EOF is true.

Here's the kicker!  This code executes inside a for loop.  If I set a
breakpoint on the first line of the body of the loop and add a Watch on
rs.RecordCount, THE CODE EXECUTES CORRECTLY!  If I take out the breakpoint
or the watch, the code fails (i.e. the record to delete can't be found).
I've tried to pull this out into a sample to send MS, but when done in the
little sample, it works correctly.  This code is also update related records
in several tables (via separate recordsets on the same connection) before,
during, and after these calls are made.  Does anyone have any suggestions at
all?  Your help is greatly appreciated.

Tom Woodward
United Systems & Software, Inc.

2. DDF Builder or DDF Maker Wanted!!!

3. Delete record Warning - Pdox 7

4. What's wrong with this statement?

5. PDox 5 for Win - Deleting Records

6. Paradox Multitasking

7. Checking if a delete will succeed (without doing the delete)

8. Having Trouble

9. Error 3167 Record Deleted when there is no deleted record

10. Checking if a delete will succeed (without doing the delete)

11. Doing Java GUI with Object Relational Mapping

12. help doing FoxPro-type relational browse in Paradox

13. SQL 7: Need to copy records from selective records to Prod syst in a relational database