Board index » delphi » SQL Update for Stored Procedure

SQL Update for Stored Procedure

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
where
c.CAffl_Comp_Num = @Company_ID
and
c.CAffl_Affl_Comp_Num = co.Comp_Num
order by
 co.Comp_Name

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:SQL Update for Stored Procedure


The stored procedure just returns a result set based on your SELECT statement.
I insert a record in one of the tables, create another stored procedure and do
your insert.  You can pass the column values as parameters.

John

Quote
Deane Hafling wrote:
> 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
> where
> c.CAffl_Comp_Num = @Company_ID
> and
> c.CAffl_Affl_Comp_Num = co.Comp_Num
> order by
>  co.Comp_Name

> 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.

Other Threads