lundi 17 juin 2019

Is there a way to create a stored procedure with if else exists?

Im learning about stored procedures and if else statements. I am not too sure where to put my codes such that a customer id is passed in, and If the customer id exists, create a Customer Order for the specified customer.

Otherwise, a new customer with the specified id is created. Barcodes of product items are passed as a table valued parameter.

And that when a product has been sold, the status of the product item must be changed to “sold”.

Thanks for any help received

my code is as below;

create procedure CustOrder
As
Begin
Declare @custID CHAR (6);
If EXISTS
begin
(Select CustomerID FROM CustomerRecord)
end
else
set @custID = 'c100';
end

Aucun commentaire:

Enregistrer un commentaire