Monday, October 26, 2009

Restrict or Protect Oracle Forms Developer from SQL Injection.

For Developer6i:
FORMS60_RESTRICT_ENTER_QUERY=true/false

For Developer9i/10g:
Open Default.env file from the foollowing path
\forms90\server\default.env
and write FORMS90_RESTRICT_ENTER_QUERY=true/false
Must restart from service/oc4j.

Wednesday, October 21, 2009

Data Convert From a FILE to CLOB

CREATE OR REPLACE Procedure Dpr_fileToClob(Fname in VARCHAR2, Fdir in VARCHAR2, Outclob out CLOB)
IS

fclob CLOB;
theBFile BFILE;
num NUMBER :=0;
src_offset NUMBER :=1;
dest_offset NUMBER :=1;
lang_context NUMBER :=1;

BEGIN

dbms_lob.createtemporary(fclob,FALSE,DBMS_LOB.SESSION);

theBFile := BFileName(Fdir,Fname);

dbms_lob.fileOpen(theBFile);

dbms_lob.loadClobFromFile(dest_lob =>fclob,
src_bfile =>theBFile,
amount =>dbms_lob.getLength(theBFile),
dest_offset =>dest_offset,
src_offset =>src_offset,
bfile_csid =>0,
lang_context =>lang_context,
warning =>num
);

dbms_lob.fileClose(theBFile);

Outclob := fclob;

end;
/

Data Convert From a FILE to BLOB

CREATE OR REPLACE Procedure Dpr_fileToBlob(Fname in VARCHAR2, Fdir in VARCHAR2, OutBlob out BLOB)

IS

fblob BLOB;
theBFile BFILE;

Bsrc_offset NUMBER :=1;
Bdest_offset NUMBER :=1;

BEGIN

dbms_lob.createtemporary(fblob,FALSE,DBMS_LOB.SESSION);

theBFile := BFileName(Fdir,Fname);

dbms_lob.fileOpen(theBFile);

dbms_lob.loadblobfromfile(dest_lob => fblob ,
src_bfile => theBFile ,
amount => dbms_lob.getLength(theBFile),
dest_offset => Bdest_offset,
src_offset => Bsrc_offset
);

dbms_lob.fileClose(theBFile);

OutBlob := fblob;

End;
/

Data Convert From CLOB to BLOB

CREATE OR REPLACE Function Fnc_Clob_to_Blob (P_clob_in in clob)
Return blob

is
v_blob blob;
v_offset integer;
v_buffer_varchar varchar2(32000);
v_buffer_raw raw(32000);
v_buffer_size binary_integer := 32000;

Begin
--
If p_clob_in is null Then
return null;
End If;
--
DBMS_LOB.CREATETEMPORARY(v_blob, TRUE);
v_offset := 1;

FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(p_clob_in) / v_buffer_size)

Loop

dbms_lob.read(p_clob_in, v_buffer_size, v_offset, v_buffer_varchar);
v_buffer_raw := utl_raw.cast_to_raw(v_buffer_varchar);

dbms_lob.writeappend(v_blob, utl_raw.length(v_buffer_raw), v_buffer_raw);
v_offset := v_offset + v_buffer_size;

End Loop;

Return v_blob;

End Fnc_Clob_to_Blob;
/

Monday, October 19, 2009

Clear or Delete Htree Data form Htree View

PROCEDURE Prc_Clear_Htree_Data(P_Tree_item varchar2,
P_Search_String varchar2)
IS
/*
* P_Tree_item - Htree Item.
* P_Search_String - Tree Node Label that which you want to Delete/Clear.
* give the exact node label (Character must be same).
*
* This Procedure will clear or delete Tree View from your given
* search_string & child node.
*/
Htree Item;
DeleteNode FTREE.NODE;
ItemName Varchar2(30) :=p_Tree_item;
vSearchString Varchar2(200):=p_Search_String;

BEGIN
Htree := FIND_ITEM(ItemName);

DeleteNode := FTREE.FIND_TREE_NODE(htree,vSearchString,FTREE.FIND_NEXT ,
FTREE.NODE_LABEL,
FTREE.ROOT_NODE ,
FTREE.ROOT_NODE
);
IF NOT FTREE.ID_NULL(DeleteNode)
THEN FTREE.DELETE_TREE_NODE(Htree, DeleteNode);
END IF;
END;