Fórum Como usar DbGrid com SP...? #264074
04/01/2005
0
Olá,
Não estou conseguindo utilizar o DbGrid com Stored Procedure, a minha SP é para inserir itens de um pedido e eu gostaria de utilizar um DBGrid, mas não consigo adicionar os Fields, se alguem puder me ajudar eu agradeço.
Não estou conseguindo utilizar o DbGrid com Stored Procedure, a minha SP é para inserir itens de um pedido e eu gostaria de utilizar um DBGrid, mas não consigo adicionar os Fields, se alguem puder me ajudar eu agradeço.
T.maciel
Curtir tópico
+ 0
Responder
Posts
04/01/2005
Sremulador
você esta utilizando uma query convencional ???
Responder
Gostei + 0
04/01/2005
T.maciel
Este é o código da SP
[size=9:e9f54b2966]create proc inserir_item_venda @venda int, @produto int, @qtd int, @valor money, @estoque int output
as
if not exists(select * from Venda where NumVenda = @venda)
begin
return(1)
end
if not exists(select * from Produto where CodigoProduto = @produto)
begin
return(2)
end
if exists (select * from ItemVenda where NumVenda = @venda and CodigoProduto = @produto)
begin
return(3)
end
select @estoque = Quantidade from Produto where CodigoProduto = @produto
if (@qtd > @estoque)
begin
return(4)
end
declare @custo money
set @custo = (select PrecoCusto from Produto where CodigoProduto = @produto)
begin transaction
insert ItemVenda values(@venda, @produto, @qtd, @valor, @custo)
if @@error 0
begin
rollback
return
end
update Produto set Quantidade = Quantidade - @qtd where CodigoProduto = @produto
if @@error 0
begin
rollback
return
end
commit[/size:e9f54b2966]
[size=9:e9f54b2966]create proc inserir_item_venda @venda int, @produto int, @qtd int, @valor money, @estoque int output
as
if not exists(select * from Venda where NumVenda = @venda)
begin
return(1)
end
if not exists(select * from Produto where CodigoProduto = @produto)
begin
return(2)
end
if exists (select * from ItemVenda where NumVenda = @venda and CodigoProduto = @produto)
begin
return(3)
end
select @estoque = Quantidade from Produto where CodigoProduto = @produto
if (@qtd > @estoque)
begin
return(4)
end
declare @custo money
set @custo = (select PrecoCusto from Produto where CodigoProduto = @produto)
begin transaction
insert ItemVenda values(@venda, @produto, @qtd, @valor, @custo)
if @@error 0
begin
rollback
return
end
update Produto set Quantidade = Quantidade - @qtd where CodigoProduto = @produto
if @@error 0
begin
rollback
return
end
commit[/size:e9f54b2966]
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)