Cannot insert null value into column '', table column does not allow nulls. INSERT doesn't work
code:
ALTER PROCEDURE [dbo].[SP_LMS_dealerorusercreation_IUDS]
@dealrid bigint,
@rid bigint,
@stateid bigint,
@regonid bigint,
@Locid bigint,
@pid varchar(MAX),
@address varchar(max),
@dealrname varchar(25),
@landno bigint,
@mobno bigint,
@altcontno bigint,
@email varchar(35),
@desig varchar(25),
@reporting varchar(30),
@status int,
@action varchar(10),
@CompanyId Uniqueidentifier
AS
DECLARE @TranStatus VARCHAR(5)
BEGIN TRY
BEGIN TRANSACTION
IF(@action='Insert')
BEGIN
INSERT INTO LMS_dealerorusercreation(
rid,
stateid,
regonid,
Locid,
addres,
dealrname,
landno,
mobno,
altcontno,
email,
desig,
reporting,
status,
CompanyId
)
VALUES(
@rid,
@stateid,
@regonid,
@Locid,
@address,
@dealrname,
@landno,
@mobno,
@altcontno,
@email,
@desig,
@reporting,
@status,
@CompanyId
)
SELECT @dealrid = dealrid FROM LMS_dealerorusercreation WHERE mobno = @mobno AND email = @email
EXEC [dbo].[SP_LMS_SetDealerProductMapping]
@dealerId = @dealrid,
@prodid = @pid
SET @TranStatus='TRUE';
END
IF(@action='Update')
BEGIN
UPDATE LMS_dealerorusercreation set rid= @rid,
stateid=@stateid,
regonid=@regonid,
Locid=@Locid,
addres=@address,
dealrname=@dealrname,
landno=@landno,
mobno=@mobno,
altcontno=@altcontno,
email=@email,
desig=@desig,
reporting=@reporting,
status=@status
WHERE dealrid=@dealrid
SET @TranStatus='TRUE';
END
IF(@action='Delete')
BEGIN
DELETE FROM LMS_dealerorusercreation WHERE dealrid=@dealrid
SET @TranStatus='TRUE';
END
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
DECLARE @AI VARCHAR(MAX)
DECLARE @EM VARCHAR(MAX);
SET @AI = 'Not Provided'
SET @EM = ERROR_MESSAGE();
EXEC USP_SetException
@ExceptionDetail = @EM,
@AdditionalInfo = @AI
SET @TranStatus='FALSE';
END CATCH
SELECT @TranStatus;
Error receiving
Cannot insert NULL value into column "dealrid", table "DB_LMS.dbo.LMS_dealerorusercreation"; the column does not allow zeros. INSERT doesn't work.
-1
vinod
source
to share
3 answers
You need to do one of two things ...
- make sure you are passing a non-null value for the column or;
- make sure your column is null if this is the desired field property.
+2
Grant Thomas
source
to share
Errors I see in the code.
When inserting into the LMS_dealerorusercreation table, you never selected a column with a deal. Please choose the same.
INSERT INTO LMS_dealerorusercreation(
rid,
stateid,
regonid,
Locid,
addres,
dealrname,
landno,
mobno,
altcontno,
email,
desig,
reporting,
status,
CompanyId,
dealrid
)
VALUES(
@rid,
@stateid,
@regonid,
@Locid,
@address,
@dealrname,
@landno,
@mobno,
@altcontno,
@email,
@desig,
@reporting,
@status,
@CompanyId,
@dealrid
)
0
SriniV
source
to share
this is the message that reports the error.
you are trying to do an insert into the table where the contract was created, but not null. if you look at the insert statement you are not selecting and passing a value to it.
0
indio
source
to share