9 - How To Attach Document With Notification - Shareapps4u
9 - How To Attach Document With Notification - Shareapps4u
9 - How To Attach Document With Notification - Shareapps4u
** ==>The "Frame Target" field is not applicable for attributes of type document. For document attributes, this field is reserved for future use.
***==> If we want to pass a static value for document identifier(document id) then the format will be look like
plsqlblob:<package>.<procedure_name>/XXXXX . Here XXXX is a string value.
Example:- plsqlblob:XX_TEST_LEAVE_PKG.GETBLOBDOC/123
plsqlblob:XX_TEST_LEAVE_PKG.GETBLOBDOC/ABC_123
c) Now copy the both the attribute and paste it in message(make it a message attribute).Open the "LEAVE_BLOB_DOC" message attribute (attribute under message)
and click on the "Attach Content". This will display the document as icon in the notification
d) Save the workflow definition to database.
2) Pl/Sql Part
We have already save our workflow definition to database. Now we have to create pl/sql procedure that will generate the Blob document.
The format of the PL/SQL procedure must be as mentioned below.We need not to bother about the input parameter. Oracle Workflow Engine will take care of that.
RAISE;
End <procedure_Name>;
a) First we have to set the value item attribute "BLOB_DOC_ID" for document identifier.This can be done within triggering workflow procedure where we are setting
other attribute values.The value can be anything depending on the business requirement and design.We can define our own pl/sql logic to identify the desired value.
Example:- Since we are reading file from server hence we can set the value as <name of the medical document>_<itemkey>.
For simplicity we have use item key as document id.
b) Now we create a new procedure with the name same as that is given in default value of document attribute.(Remember the procedure will be under the same
package as we have mentioned in default value
1) create a oracle directory pointing to the directory where our file exists.
2) Define BFILE locator of the location where actually file is located.(bfilename utility is explained in 5) iRecruitment Data Migration - How To Migrate Resume topic)
3) Create a temporary BLOB or CLOB and its corresponding index in your default temporary tablespace using dbms_lob.createtemporary utility. This will help us
to manipulate the temporary LOBs with PL/SQL.
5) Now load the Blob into a local variable from file using utility DBMS_LOB.LOADBLOBFROMFILE.
DBMS_LOB.LOADBLOBFROMFILE (dest_lob => l_temp_blob,
src_bfile=>l_file_on_os,
amount=>dbms_lob.getlength(l_file_on_os)
,dest_offset=>l_dest_offset --in out parameter
,src_offset =>l_src_offset);
This will store the data from BFILE to internal BLOB.
dest_lob :- BLOB locator of the target for the load.
src_bfile :- BFILE locator of the source for the load.
amount :- Number of bytes to load from the BFILE.
dest_offset:- Offset in bytes in the destination BLOB (origin: 1) for the start of the write.
src_offset :- Offset in bytes in the source BFILE (origin: 1) for the start of the read
9) Now we have to set the "document_type" parameter. We have to set the value in the following format
MIME TYPE: can be determined from the extension of the document. The details of MIME type is discussed in 5) iRecruitment Data Migration - How To Migrate
Resume topic
NOTE:- 1) For CLOB Document most of the part is same, only we have to use DBMS_LOB.LOADCLOBFROMFILE utility to load the data from BFILE.
dest_offset :- Offset in characters in the destination CLOB (origin: 1) for the start of the write.
src_offset :-
bfile_csid :-
2) Instead of storing it in local variable then to output parameter, we can directly store it is output parameter.
Just for the shake of understanding of dbms_lob.Copy utility we stored it in local variable.
3) For PL/SQL and PL/SQL CLOB documents that contain text or HTML, the document generated by
the PL/SQL procedure can either be displayed within the text of a notification or included as an attachment.
Other types of content in PL/SQL CLOB documents, as well as all PL/SQL BLOB documents, can only be included as attachments.
5) if we don't make document id attribute(here for BLOB it is "BLOB_DOC_ID" and for CLOB it is "LEAVE_CLOB_DOC_ID" ) as message attribute,
References:- 1) https://metalink.oracle.com
2) Oracle Workflow Developer's Guide ( Release 12) B31433-04
Disclaimer:- This is a knowledge sharing site. This topic talks about a custom solution. Oracle may not provide you a support for any data
corruption or any other problem in your custom code/problem arises because of the custom code. The author is not responsible for any
kind of system/data problem appears because of usages of this code.Reader/implementer must do it on his/her own risk/responsibility.