Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (anonymous):

Having a hard time figuring out a bug in some SQL code. The point is to add a column called "stars" to table "emp". The value of stars should be a line of asterisks for each $1000 in the employee's salary. Any ideas what I'm doing wrong?

OpenStudy (anonymous):

DROP TABLE emp; CREATE TABLE emp AS SELECT * FROM employees; ALTER TABLE emp ADD stars VARCHAR2(50); set serveroutput on DECLARE v_empno emp.employee_id%TYPE := 176; v_asterisk emp.stars%TYPE := NULL; v_sal emp.salary%TYPE; BEGIN SELECT salary INTO v_sal FROM emp WHERE employee_id = v_empno; LOOP INSERT INTO emp(stars) VALUES (v_asterisk); v_sal := v_sal - 1000; v_asterisk := v_asterisk || '*'; EXIT WHEN v_sal <= 0; END LOOP; COMMIT; DBMS_OUTPUT.PUT_LINE(v_empno || ' ' || v_sal || ' ' || v_asterisk); END; /

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
2 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
3 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!