Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is my code

Create database OfertaEmpleo
use OfertaEmpleo
go
Create table OfertaTrabajo
(

Nombre Varchar (100),
Titulo Varchar (100),
Tipo Varchar (100),
Ubicacion Varchar (200),
Salario int,
Requerimientos varchar (200)
);
go

create proc sp_listar_clientes
as
Select* from OfertaTrabajo order by Nombre
go

create proc sp_buscar_clientes
@Nombre Varchar (100)
as

select Nombre,Titulo,Tipo,Ubicacion,Salario,Requerimientos from OfertaTrabajo where Nombre like @Nombre + '%'
go

create proc sp_mantenimiento_clientes

@Nombre Varchar (100),
@Titulo Varchar (100),
@Tipo Varchar (100),
@Ubicacion Varchar (200),
@Salario int,
@Requerimientos varchar (200),
@accion varchar (100) output
as
if (@accion = '1')
begin
    declare @NomNuevo varchar(100), @Nommax varchar (100)
	set @Nommax = (select max (Nombre) from OfertaTrabajo)
	set @Nommax = isnull(@Nommax,'A0000')
	set @NomNuevo = 'A'+RIGHT(RIGHT(@Nommax,6)+10001,6)
	insert into OfertaTrabajo(Nombre,Titulo,Tipo,Ubicacion,Salario,Requerimientos)

	values (@NomNuevo,@Nombre,@Titulo,@Tipo,@Ubicacion,@Salario,@Requerimientos)
	set @accion= 'Se genero el Nombre:'+@NomNuevo
end
else if(@accion='2')
begin
     update OfertaTrabajo set Titulo=@Titulo, Tipo=@Tipo, Ubicacion=@Ubicacion, Salario=@Salario, Requerimientos= @Requerimientos where Nombre=@Nombre
	 set @accion='Se Modifico el Nombre:'+ @Nombre
end
else if (@accion='3')
begin
    Delete from OfertaTrabajo where Nombre=@Nombre
	set @accion = 'Se borro el Nombre;'+@Nombre
end
go


and I'm getting this error:
Msg 110, Level 15, State 1, Procedure sp_mantenimiento_clientes, Line 17 [Batch Start Line 27]
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.


What I have tried:

I did count the columns and are the same
Posted
Updated 8-Mar-23 14:09pm

1 solution

You specify 6 fields
SQL
insert into OfertaTrabajo(Nombre,Titulo,Tipo,Ubicacion,Salario,Requerimientos)

yet pass 7 values
SQL
values (@NomNuevo,@Nombre,@Titulo,@Tipo,@Ubicacion,@Salario,@Requerimientos)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900