General discussion

Locked

Need help with a stored procedure that inserts and creates data using T-SQL

By Lin2021 ·
this is what i have so far, newbie and struggling.

create procedure prc_insertinvoice

as
declare @int cuscode int, @int err int, @err int, @invtotal decimal, @int inv_num int;
begin
begin transaction
set @int toterr = 0;
insert into customer(cus_lname, cus_fname, cus_balance)
values('balance', 'frank', 0);
set @int err= @@err;
if @interr <0
set @inttoterr=@interr
set @int cuscode=scope identity();
insert into invoice(cus_code, inv_date, p_descript, p_price, inv_subtotal, inv_balance)
values (@intcuscode, '2-11-2011', 'milk', 5, 5, 5)
set @interr=@@err
if @interr <0
set @inttoterr=@interr
set @int inv_num = scope identity();
set @ invtotal = (select inv_total from invoice where inv_number=@int inv_num)

ALL I HAVE SO FAR, HELP!!!!!!!!!!!!!!!!!

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Back to Web Development Forum
0 total posts (Page 1 of 1)  

Software Forums