Ahsan Amin


1) When i delete a record from VFPs table, it is marked as deleted but not deleted permanently. How to delete permanently

2) How to select select the records that are not marked in a table

3)iF i use 'Clear' method in a form, the control that are placed on form start vanishing, how to stop that




Re: Some questions about VFP

hangover


Hi Ashan ... I can answer the first couple

1) use the PACK command

2) SET DELETED ON will automatically exclude deleted records from commands with a scope (such as BROWSE, LOCATE, SCAN, etc) and when using the SELECT - SQL command. Alternatively you can explicitly exclude them by using the DELETED () function, e.g.

SELECT * from table WHERE NOT DELETED ()

or

SCAN ALL FOR NOT DELETED ()

Dom







Re: Some questions about VFP

CetinBasoz

3) Why would you ever want to use 'clear' in a form

Anyway, since you did you can recover with code like:

thisform.LockScreen = .t.

thisform.Refresh

thisform.LockScreen = .f.






Re: Some questions about VFP

Alex Feldstein

Keep in mind, that PACK requires exclusive use of the table in question so it is used sparingly and only in a table maintenance routine. It is not needed often or at all if you plan to reuse the records marked for deletion.


See also:

BLANK

RECALL

Re: CLEAR. That is an old xBASE command that has no real use in a form.





Re: Some questions about VFP

Ahsan Amin

hi guyz,

thanks for your kind response. Please do write functionality against each command/function/method as commented.

Thanks

Ahsan





Re: Some questions about VFP

Alex Feldstein

Ahsan Amin wrote:

thanks for your kind response. Please do write functionality against each command/function/method as commented.

Ahsan,

Have you followed the links provided to the BLANK and RECALL commands above





Re: Some questions about VFP

Ahsan Amin

i want to select the records of my choice. What command to use





Re: Some questions about VFP

Alex Feldstein

Ahsan Amin wrote:
i want to select the records of my choice. What command to use

Use Select-SQL.

Select field1, field2 From MyTable Where MyCondition Into Cursor MyQueryData





Re: Some questions about VFP

Cindy Winegarden

Hi Ahsan,

To go a little further with what everyone else said, most Fox developers use SET DELETED ON in their applications so as to ignore deleted rows. SET DELETED is scoped to the data session so developers using private data sessions in their forms usually use a base form class of their own design and subclass all their other forms from that. In the LOAD() of the base class form they include SET DELETED ON.

Some developers PACK their tables as part of an off-hours maintenance routine since they can have exclusive use of the tables.

Many times when people ask a question like your #1 it is because they want to re-use a primary key and the Fox data engine won't let them. In my tables I use a Primary key value that is generated by a stored procedure. This value has nothing to do with the data and is used only for joining tables. When I have a Candidate key such as an invoice number or US Social Security number the Fox data engine stops the users from entering the same value twice. My usual advice when posters ask this question when they want to re-use a Primary Key is to think carefully about they want to re-use a Primary Key value since it isn't a good idea.

For your question #2, the simplest thing to do is to use SET DELETED ON either at the data session level or immediately before the SELECT statement. In my apps I use only the default data session so I issue SET DELETED ON at the beginning of my Main program and everything is fine after that.