Board index » delphi » Update SQL with a stored Procedure???

Update SQL with a stored Procedure???

I have a stored procedure that collects data from 2 different tables, how
can I write a Insert sql statement to allow only one of the tables to be
insertable. The one table is just a lookup table.

Here is what I currently have :

I have two tables, Compant and CAffl.

Company has two fields, Comp_Num and Comp_Name
CAffl has three fields, CA_Comp_Num, CA_Affl_Comp_Num, and CA_Cmnts.

I have a stored Procedure that links the table in the following manner

CREATE PROCEDURE sp_CompAffl @Company_ID Float  AS
select  c.CA_Comp_Num, c.CA_Affl_Comp_Num, c.CA_Cmnts, co.Comp_Name
from CAffl c, Company co
c.CAffl_Comp_Num = @Company_ID
c.CAffl_Affl_Comp_Num = co.Comp_Num
order by

How do I insert a record for this stored procedure? I only want to insert a
record for the CAffl table, not the Company table, it serves only as a
lookup here.


Re:Update SQL with a stored Procedure???

>I have a stored Procedure that links the table in the following manner

>CREATE PROCEDURE sp_CompAffl @Company_ID Float  AS
>select  c.CA_Comp_Num, c.CA_Affl_Comp_Num, c.CA_Cmnts, co.Comp_Name
>from CAffl c, Company co
>c.CAffl_Comp_Num = @Company_ID
>c.CAffl_Affl_Comp_Num = co.Comp_Num
>order by

1- Turn CachedUpdates on.
2- Attach a TUpdateSQL to UpdateObject.
3- Write the insert, delete, update queries that only touches those fields
from CAffl.
4- Remember now that you must call ApplyUpdates somewhere.

I'm assuming that your user will type the CA_Comp_Num, or you will provide
him/her a method for selecting this field value. If you want him to type the
Comp_Name, you'll need a more involved procedure to update the database. If
this is your case, you'll need the OnUpdateRecord event, so you can find the
code associated to that name first.


Other Threads