dbTalk Databases Forums  

Delete Query...

comp.databases.paradox comp.databases.paradox


Discuss Delete Query... in the comp.databases.paradox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Willard J. Hoppe
 
Posts: n/a

Default Delete Query... - 01-13-2006 , 10:17 AM






I have a database with a field named PULLED? that is either a "Y" or blank.

How do I write code to go through and delete all the people with a "Y" in
the PULLED? field, and put them into a new database in the same directory
called PEOPLE PULLED.db?

I started out, but got a little nervous because the query was writing
automatically to the :PRIV: directory... I was unsure just what checking I
should be using (for existing tables, etc.).

-b



Reply With Quote
  #2  
Old   
Robert Wiltshire
 
Posts: n/a

Default Re: Delete Query... - 01-13-2006 , 01:00 PM







There is a setting in paradox that deals with auxilliary tables.
And basically how I think of that is,
there can be some intermediate tables that are created by pdox,
or you can turn that setting off,
so that no tables are created,
and those queries run faster.

Examples : Inserted, Changed, Deleted

If you actually do a delete query,
and you dont have an aux table created,
then the records will just disappear.

Backing up data as you hone your method is always a good idea.
Or copying elsewhere until you perfect it.

Two query based solutions that spring to mind are :

Solution #1
Two queries and add table to history
Query#1 : Checkplus query with all records and add answer to a delete
history table
Query#2 : delete query and not care if there is an aux table

Solution#2
One delete query and add table to history
Query#1 :delete query that creates an aux table "deleted.db"
and then add "deleted.db" to a delete history table

Good luck
Robert Wiltshire









"Willard J. Hoppe" <billh (AT) nospam (DOT) brraspam.com> wrote

Quote:
I have a database with a field named PULLED? that is either a "Y" or blank.

How do I write code to go through and delete all the people with a "Y" in
the PULLED? field, and put them into a new database in the same directory
called PEOPLE PULLED.db?

I started out, but got a little nervous because the query was writing
automatically to the :PRIV: directory... I was unsure just what checking
I should be using (for existing tables, etc.).

-b




Reply With Quote
  #3  
Old   
Mike Kennedy
 
Posts: n/a

Default Re: Delete Query... - 01-13-2006 , 01:19 PM



Bill,

I suggest:
1. Make a backup of your main table!!!
2. Create an empty Table named PeoplePulled, borrowing the Structure and
Family from the main table
3. Run a query on the main table, extracting all the fields in records
where PULLED = Y
4. Copy this ANSWER table into the Empty table.
5. Run a query on the main table, deleting all records where PULLED = Y

Mike


"Willard J. Hoppe" <billh (AT) nospam (DOT) brraspam.com> wrote

Quote:
I have a database with a field named PULLED? that is either a "Y" or blank.

How do I write code to go through and delete all the people with a "Y" in
the PULLED? field, and put them into a new database in the same directory
called PEOPLE PULLED.db?

I started out, but got a little nervous because the query was writing
automatically to the :PRIV: directory... I was unsure just what checking
I should be using (for existing tables, etc.).

-b




Reply With Quote
  #4  
Old   
Willard J. Hoppe
 
Posts: n/a

Default Re: Delete Query... - 01-13-2006 , 03:56 PM



By default, when records are deleted in a query, does it always go to
:PRIV:deleted.db?

If it does, I can code to just copy that file to what I want, and I think
that will take care of the issue.

-b



"Willard J. Hoppe" <billh (AT) nospam (DOT) brraspam.com> wrote

Quote:
I have a database with a field named PULLED? that is either a "Y" or blank.

How do I write code to go through and delete all the people with a "Y" in
the PULLED? field, and put them into a new database in the same directory
called PEOPLE PULLED.db?

I started out, but got a little nervous because the query was writing
automatically to the :PRIV: directory... I was unsure just what checking
I should be using (for existing tables, etc.).

-b




Reply With Quote
  #5  
Old   
Steven Green
 
Posts: n/a

Default Re: Delete Query... - 01-13-2006 , 05:14 PM



"Willard J. Hoppe" wrote:

Quote:
By default, when records are deleted in a query, does it always go to
:PRIV:deleted.db?
by default, yes..


Quote:
If it does, I can code to just copy that file to what I want, and I think that
will take care of the issue.
do what Michael said.. query out the records, rename the table or add the
records, THEN delete the records.. that way, you can error trap along the way,
save your butt if the process fails in the middle, etc, etc., etc..

dee-fense.. dee-fense..


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------




Reply With Quote
  #6  
Old   
Steve Urbach
 
Posts: n/a

Default Re: Delete Query... - 01-13-2006 , 08:19 PM



On Fri, 13 Jan 2006 16:56:49 -0500, "Willard J. Hoppe"
<billh (AT) nospam (DOT) brraspam.com> wrote:

Quote:
By default, when records are deleted in a query, does it always go to
:PRIV:deleted.db?

If it does, I can code to just copy that file to what I want, and I think
that will take care of the issue.

-b


The Term is ADD (after the first time if you don't create the Peopled
Pulled.db before hand)
as in Add :Priveleted.db to "People Pulled.db"

BTW I dislike tablenames that have spaces in their names or exceed 8.3
naming. It is just asking for problems down the road. P_pulled.db?

Steve U
Quote:
"Willard J. Hoppe" <billh (AT) nospam (DOT) brraspam.com> wrote in message
news:43c7d29d$1 (AT) pnews (DOT) thedbcommunity.com...
I have a database with a field named PULLED? that is either a "Y" or blank.

How do I write code to go through and delete all the people with a "Y" in
the PULLED? field, and put them into a new database in the same directory
called PEOPLE PULLED.db?

I started out, but got a little nervous because the query was writing
automatically to the :PRIV: directory... I was unsure just what checking
I should be using (for existing tables, etc.).

-b



Reply With Quote
  #7  
Old   
Régis Duc Dodon
 
Posts: n/a

Default Re: Delete Query... - 01-14-2006 , 03:18 AM



Why not to use "subtract" table in that case?
Is there some "restrictions" to subtract table, because I have never
seen a post in which someone recommand it.
Régis

Steven Green a écrit :
Quote:
"Willard J. Hoppe" wrote:

By default, when records are deleted in a query, does it always go to
:PRIV:deleted.db?

by default, yes..

If it does, I can code to just copy that file to what I want, and I think that
will take care of the issue.

do what Michael said.. query out the records, rename the table or add the
records, THEN delete the records.. that way, you can error trap along the way,
save your butt if the process fails in the middle, etc, etc., etc..

dee-fense.. dee-fense..

--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------

Reply With Quote
  #8  
Old   
Steven Green
 
Posts: n/a

Default Re: Delete Query... - 01-14-2006 , 06:25 AM



Régis Duc Dodon wrote:

Quote:
Why not to use "subtract" table in that case?
"subtract" is a different process.. subtract this from that, and see what's left in
that..


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------




Reply With Quote
  #9  
Old   
Mike Kennedy
 
Posts: n/a

Default Re: Delete Query... - 01-15-2006 , 02:35 PM



Quote:
I suggest:
1. Make a backup of your main table!!!
2. Create an empty Table named PeoplePulled, borrowing the Structure and
Family from the main table
3. Run a query on the main table, extracting all the fields in records
where PULLED = Y
4. Copy this ANSWER table into the Empty table.
5. Run a query on the main table, deleting all records where PULLED = Y

Mike
Typo... step 4 should say ADD the answer table... sorry...

If you intend running this procedure frequently, whereby any new PULLED=Y
records must transfer to the PeoplePulled table, then you may need to detect
potential "duplicate keys" in the PeoplePulled table (in advance), possible
structural changes to one of the tables which were not replicated in the
other one, etc...

- Mike




Reply With Quote
  #10  
Old   
Michelle Burnore
 
Posts: n/a

Default Re: Delete Query... - 01-16-2006 , 03:06 PM



Willard J. Hoppe wrote:
Quote:
By default, when records are deleted in a query, does it always go to
:PRIV:deleted.db?

Willard,

Sample code to do what you want.

method pushButton(var eventInfo Event)
var
DelQry Query
DataTbl, BuTbl, PulledTbl Table
oldname, newname String
endvar

; first backup your table

DataTbl.attach("your table name here")
BuTbl.attach("whatever you want to call backup")

if isTable(BuTbl) then
if msgQuestion("Copy table", "Overwrite " + BuTbl + "?") = "Yes" then
DataTbl.copy(BuTbl)
endIf

; now run your query

DelQry = Query

yourtablename.DB | Pulled |
Delete | not blank |

EndQuery

if not DelQry.executeQBE()
then
errorshow()
return
endif

; now rename it

oldtable = "riv:deleted.db"
newtable = "whatever you want to call it"
PulledTbl.attach(oldtable)
if isTable(newtable) then
if msgQuestion("Confirm", newtable+ " exists. Overwrite it?") =
"Yes" then
PulledTbl.rename(newtable)
endif
endMethod


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.