Board index » delphi » Delete Sql

Delete Sql

Hi all,

I have a little problem in getting a delete-statement in D5 to work.
I have two tables ('YEAR' and 'CATEgory', both paradox) with a master-detail
relationship, the field 'year'(date-format) being the foreign key in the
detail-table.
Now what I want is to implement a cascading-delete, so when I delete a
certain year in 'YEAR', all the records with the same year in 'CATEgory'
also get deleted. Nothing new here, you know the drill.

But how do I implement that in Delphi? Do I use TQuery or TUpdateSql? Also
the field 'year' is a date-field, so how do I handle that in my sql-string?
It must be something like: delete from category where year =
form1.dbedit.text;

This is highly frustrating, since I do these sort of things in Oracle every
day, but for some reason I can't do it in delphi!

Hope someone can help.

Jesse

--
Jesse van Oort
het Want 115
9733 BG  Groningen
050 - 5417271
06 - 21223832
jesse.van.o...@xs4all.nl

 

Re:Delete Sql


Define your query with parameters, then set the parameter values and prepare
as in:

with yourQuery do
begin
  ParamByName('P_DATE).AsString := form1.dbedit.text;
  Prepare;
end;
---------
Regards,
Peter

Re:Delete Sql


Peter Kobor <pko...@pfksystems.com> schreef in berichtnieuws
38bc274d$0$16...@news.sanjose1.level3.net...

Quote
> Define your query with parameters, then set the parameter values and
prepare
> as in:

> with yourQuery do
> begin
>   ParamByName('P_DATE).AsString := form1.dbedit.text;
>   Prepare;
> end;
> ---------
> Regards,
> Peter

Right!! Why is it that I always find out the answer myself just after I post
a message to a newsgroup, and always the same answer that I get from those
newsgroups?
Lots of thanks anyway, it looks more or less like the Delphi-equivalent of
Oracle bind-variables, so just what I needed.

Thanks again,

Jesse

--
Jesse van Oort
het Want 115
9733 BG  Groningen
050 - 5417271
06 - 21223832
jesse.van.o...@xs4all.nl

Other Threads