how can I turn this code into a function with the same output?
declare
record_name employees%ROWTYPE;
begin
FOR record_name IN (SELECT (a.first_name || ' ' || a.last_name) complete_name,
b.DEPARTMENT_NAME complete_name2
FROM employees a , departments b
WHERE ROWNUM < 1000 and a.DEPARTMENT_ID=b.DEPARTMENT_ID)
LOOP
DBMS_OUTPUT.PUT_LINE('Employee name: ' || record_name.complete_name
||'DEPARTMENT name: '||record_name.complete_name2);
END LOOP;
END;
Fast example, i don’t know whether is some type that not have integrity limitation because not always will be
varchar(4000)enought. but i heard something about this type but now i dont exactly know wether exists.When you will work with this in app layer, must somehow format returned string.