Click here to Skip to main content
15,883,827 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
INSERT query below gives me an error. The error is: cannot insert NULL into empid

Is there anything wrong with my insert statements below. Thank you.

--- INSERT EMPID 5 TIMES GREATER THAN THE LARGEST EXISTING EMPID
INSERT INTO SALESPERSONS (empid)
SELECT MAX(EMPID) * 5
FROM SALESPERSONS

--ENAME IS MY NAME
INSERT INTO SALESPERSONS (ename) VALUES (MY NAME);

--rank will be whichever rank is associated with the lowest-paid --salesperson (using SELECT)
INSERT INTO SALESPERSONS (rank)
SELECT MIN(RANK) FROM SALESPERSONS


--salary is to be 10% more than the lowest-paid salesperson (use--SELECT clause).
INSERT INTO SALESPERSONS (salary)
SELECT MIN(SALARY)* 0.10 + MIN(SALARY) FROM SALESPERSONS
Posted
Updated 7-Feb-13 20:04pm
v4

1 solution

Yes: you must do that in one single INSERT query instead of four, or change the last 3 insert queries into UPDATE queries.
 
Share this answer
 
Comments
7prince 8-Feb-13 11:03am    
Thanks. How can I do that?

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