Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have insert trigger problem can somebody help !!!!

Status
Not open for further replies.

kspiderman

IS-IT--Management
Dec 16, 2004
9
0
0
US
below is my code to copy from invoices(header) to ca_temp_invoices.
then trigger should be work to copy x_invoic(detail) to ca_temp_x_invoic.

if I copy 4 invoice in to temp_invoices, then I should have all 4 x_invoic(deatil) information should be copyed in to ca_temp_x_invoic but only copy 1 of last inovoice number detail is copyed in to ca_temp_x_invoic. "CAN SOMEBODY HELP". I been reading professional SQL Server 2000 Programming book for couple days to find but couldn't.

"My Trigger begins"

CREATE Trigger CA_Temp_X_inv_Ins_Del on dbo.ca_temp_invoices for
insert as

Declare @status tinyint
Declare @doc_no varchar (15)


select @status=inserted.status, @doc_no=inserted.doc_no from inserted

if @@rowcount = 0 return -- no rows affected, exit immediately
if @doc_no = null return

BEGIN
Begin Tran

insert ca_temp_x_invoic
select * from x_invoic where status=@status and order_no=@doc_no and desc_type=1

--exec CA_Insert_T_inv @status, @doc_no
COMMIT
END
 
When you do the select what's you output..
select * from x_invoic where status=@status and order_no=@doc_no and desc_type=1


Dr.Sql
Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top