This is a test procedure to parse out lines of a memo and output it. I'm not sure why it doesn't work. It complains that it doesn't like the value assigned to the memo_field_tx variable. The error is :
'FIRST LINE
SECOND LINE
THIRD & LAST LINE' is not a valid integer value
'FIRST LINE
SECOND LINE
THIRD & LAST LINE' is not a valid integer value
Code:
PROCEDURE PR_PARSE_MEMO_INFOTRAC
IS
/* Current position in string */
lv_current_pos NUMBER(2);
/* End of line position to determine length of line */
lv_eol_pos NUMBER(2);
/* End of string position to determine max of loop */
lv_eos_pos NUMBER(2);
-- FOR TESTING - this field will be passed in as parameter in production
memo_field_tx VARCHAR2(1000);
BEGIN
/* Initialize variables */
lv_current_pos := 0;
lv_eol_pos := 0;
lv_eos_pos := 0;
-- FOR TESTING to determine memo_field_tx
memo_field_tx := 'FIRST LINE'||chr(10)||'SECOND LINE'||chr(10)||'THIRD & LAST LINE';
WHILE lv_eos_pos < LENGTH(memo_field_tx)
LOOP
lv_eol_pos := INSTR(SUBSTR(memo_field_tx,lv_current_pos),chr(10));
IF lv_eol_pos < 63 THEN
DBMS_output.put(RPAD(SUBSTR(UPPER(memo_field_tx),lv_current_pos,lv_eol_pos - 1),62,' '));
ELSE
DBMS_output.put(SUBSTR(UPPER(memo_field_tx),lv_current_pos,62));
END IF;
/* Reset current position to the end of line position skipping the line break char */
lv_current_pos := lv_eol_pos + 1;
/* Determine position in string */
lv_eos_pos := lv_eos_pos + lv_eol_pos;
END LOOP;
END PR_PARSE_MEMO_INFOTRAC;