Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

i got thie error Error: SyntaxError: Unexpected token P in JSON at position 0

User_V22OJApr 3 2022

i got thie error Error: SyntaxError: Unexpected token P in JSON at position 0
and this is my code
DECLARE
l_new_file Blob := EMPTY_BLOB() ;
l_doc_id NUMBER;
l_names T_STR_ARRAY := T_STR_ARRAY();
l_values T_STR_ARRAY := T_STR_ARRAY();
l_teller NUMBER;
l_record_nr NUMBER;
v_mime VARCHAR2(100) := 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
v_length NUMBER;
l_new_file_name VARCHAR2(200);

CURSOR c_template IS
SELECT ATTACH_FILENAME
, ATTACH_DATA
FROM TBL_ATTACH_FILE
WHERE ATTACH_id = :TEMPLAT;
r_template c_template%ROWTYPE;

CURSOR c_employee IS
SELECT FIRST_NAME
FROM OEHR_EMPLOYEES
WHERE EMPLOYEE_ID = :EMPLOYEE;
r_employee c_employee%ROWTYPE;

FUNCTION replace_special_chars ( l_text VARCHAR2 ) RETURN VARCHAR2 IS
l_return VARCHAR2(4000);
BEGIN
l_return := l_text;
l_return := SUBSTR(REPLACE ( l_return, '&', '&'), 1, 4000);
l_return := SUBSTR(REPLACE ( l_return, '<', '<'), 1, 4000);
l_return := SUBSTR(REPLACE ( l_return, '>', '>'), 1, 4000);
l_return := SUBSTR(REPLACE ( l_return, chr(10), '<w:br/>'), 1, 4000);

RETURN l_return;
END;
BEGIN
OPEN c_template;
FETCH c_template INTO r_template;
IF c_template%NOTFOUND
THEN
Wwv_flow.debug('NOT FOUND');
raise_application_error ( -20000, 'no template found');
null;
END IF;
CLOSE c_template;

SELECT "SQ_ATTACH_FILE".nextval
INTO l_doc_id
FROM dual;

l_teller := 1;
OPEN c_employee;
FETCH c_employee into r_employee;
if c_employee%FOUND
THEN
l_names.EXTEND(1);
l_values.EXTEND(1);

l_names(1) := '#FIRST_NAME#';
l_values(1) := r_employee.first_name;
l_new_file := ooxml_util_pkg.get_file_from_template ( r_template.ATTACH_DATA, l_names, l_values);
l_new_file_name := 'Uitnodiging_'||l_doc_id||'.docx';
v_length := DBMS_LOB.GETLENGTH(l_new_file);
owa_util.mime_header( v_mime, FALSE );
htp.p('Content-length: ' || v_length);
htp.p('Content-Disposition: attachment; filename="'||l_new_file_name||'"');
owa_util.http_header_close;

wpg_docload.download_file( l_new_file );
END IF;
CLOSE c_employee;
END;

Comments
Post Details
Added on Apr 3 2022
0 comments
1,286 views