User defined sql functions enable sql developers to club the sql statements and logic together in a method, hence avoiding repetition of code and also helps in keeping the code organized and clean.
Like any other technology, while writing sql functions there is often a need to debug the code by printing data at various stages. The DBMS_OUTPUT package enables you to print messages and data using the PUT and PUT_LINE procedures.
DBMS_OUTPUT.PUT (item IN VARCHAR2);
DBMS_OUTPUT.PUT ('value: ' || value);
DBMS_OUTPUT.PUT ('Welcome to VerticalHorizons');
The PUT procedure that takes a NUMBER is obsolete but it is still supported for legacy reasons.
When you call PUT_LINE the item you specify is automatically followed by an end-of-line marker.
DBMS_OUTPUT.PUT_LINE (item IN VARCHAR2);
DBMS_OUTPUT.PUT_LINE ('value: ' || value);
DBMS_OUTPUT.PUT_LINE ('Welcome to VerticalHorizons');
The PUT_LINE procedure that takes a NUMBER is obsolete but it is still supported for legacy reasons.
These two procedures aid in debugging sql functions and turn out to be very useful while writing complex logic.
Please leave your footprints in comments section if there are better way of doing the things…!!