Abbas
Abbas

Reputation: 5044

checking whether stored procedure inserted record

i have written stored procedure, where i am first checking whether the record for a particular is repeated more than thrice, if yes it should not insert new record, else it should insert the record in the database.

now in the if condition i have insert query, now i want to know how should i be able to know whether the insert query fired successfully or not. because if the IF statement fails it wont execute insert query, and what should i write in the else statement, so that i can come to know whether the insert query executed or not.

i am using VB.Net as a front end... please tell me the condition how i will be able to know the insert query fired or not.

Regards Abbas Elecrticwala

Upvotes: 0

Views: 564

Answers (1)

serhat_pehlivanoglu
serhat_pehlivanoglu

Reputation: 982

you can return a bit value depending on the insert. like

create proc myproc
-- your variables here
as
begin
if (your condition )
begin
your insert query
select '1'
end
else
begin
select '0'
end
end

you can check the result in vb, and you will know depending on the bit value.

Upvotes: 1

Related Questions