2
-- A data set will be returned after reporting 2 parameters, I need to take this data set and put in variables.
@Clientetypoveiculo VARCHAR(5), @cdVeiculo int
as
if (@ClienteTipoVeiculo='Moto')
begin
    Select  mm.nmMarcaMoto, mom.nmModeloMoto, v.Renavam, v.Placa, v.AnoFabricacao,
            v.AnoModelo, v.Obs
    From Cliente C, TipoVeiculo tv, Veiculo v, MarcaMoto mm, ModeloMoto mom
        Where v.Vei_cdCliente           = c.cdCliente 
                and v.Vei_cdMarca       = mm.cdMarca    
                and v.Vei_cdModelo      = mom.cdModeloMoto              
                and tv.nmTipoVeiculo    = @ClienteTipoVeiculo and v.cdVeiculo=@cdVeiculo
end
 else if (@ClienteTipoVeiculo='Carro')      
    Select  mc.nmMarcaCarro, moc.nmModeloCarro, v.Renavam, v.Placa,
            v.AnoFabricacao, v.AnoModelo, v.Obs
    From Cliente C, MarcaCarro mc, ModeloCarro moc, TipoVeiculo tv, Veiculo v
        Where v.Vei_cdCliente           = c.cdCliente 
                and v.Vei_cdMarca       = mc.cdMarca    
                and v.Vei_cdModelo      = moc.codigo 
                and tv.nmTipoVeiculo    = @ClienteTipoVeiculo and v.cdVeiculo=@cdVeiculo  
  else
    raiserror ('Valor informado só pode ser Carro ou Moto',14,2)
The code you tried is really that posted? As it is a bit far, the selects need to be passed to some component
TQuery... Or is it just an example of what you’re trying? Try to improve the example as described here– Melissa
That’s the code right there. When running Procedure on Sqlserver it will ask for 2 parameters that can be: 'Car' or 'bike' and the other parameter will be the code to be searched. 


Ex: exec SPClienteVeiculo 'moto' , 1 


Retorno: tv.nmTipoVeiculo,c.nmCliente ,Vei_cdCliente,Vei_cdMarca ,moc.nmModeloMoto,mca.nmMarcaMoto,Renavam,Placa ,V.Obs ,AnoFabricacao ,AnoModelo
 This return I wanted to have in Dataset to display in Edit s.
– Cláudio Américo
Ahhh now understood this code is from the SQL Server database, I thought this code was from Delphi =S, is using which component in Delphi?
TADOStoredProc? I wonder if you could show me what you’ve tried on Delphi?– Melissa
Tip: it is better to edit your question by adding this information instead of running around in the comments, improve the title, explanation and everything else...
– Melissa