- In my schema, I have a reference number column in my settlement table with a null value of varchar2 type, that I want to update it continuously.
- Then I've created a sequence called
ref_seq_numusing a built-in function. I want to use it (
ref_seq_num) within my functionget_ref_numto update the sequence ref. number to my settlement table, which the return type also is varchar2 and I have a function like belowCREATE OR REPLACE FUNCTION get_ref_num RETURN settlement.ref_nr %TYPE IS v_ref_seq settlement.ref_nr%TYPE; BEGIN v_ref_seq := to_char(sysdate, 'YYYYMMDD')||LPAD(ref_seq_num.nextval, 8,'0'); RETURN v_ref_seq; END get_ref_num;
However, I bum into this error message 1/55 PLS-00302: component 'ref_nr' must be declared. I also tried changing the data type to varchar2 and error message is PLS-00215: String length constraints must be in range (1 .. 32767) How can I fix it?