Professional Documents
Culture Documents
Oracle Forms-Reports and PL - SQL
Oracle Forms-Reports and PL - SQL
Vicky Thigale my requirment is to develop two forms .In the first form there are thee column sr. no. ,document name and a browse button using this button admin can upload a text or pdf file and in the another form end user can see the same content i.e. sr. no. ,document name and a button to view the respective document. please help to create browse button to upload pdf file on a custom form
Like Comment Follow Post Share 7 hours ago Juan Carlo Aquino Banayo likes this. Govindasamy Raja 1.when button pressed---upload any files to oracle database ----------------DECLARE vFilePath VARCHAR2(2000); BEGIN :file_name:=GET_FILE_NAME('\\EHSG02\D\RAJA\account','','','all files (*.*)',OPEN_FILE,TRUE); END; 2.give one save button to save the doc to oracle database ----------------------------------declare a varchar2(100); x number; t varchar2(100); S VARCHAR2(50); begin SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS') INTO t FROM DUAL; select substr(:file_name,25) into a from dual; load_file_to_my_acc (a,:q_no,:prepare,:GLOBAL.SYSTEMNAME,t,:description); x:=show_alert('AT'); EXCEPTION WHEN OTHERS THEN MESSaGE('File Upload Failed'); MESSAgE('File Upload Failed'); END; -------------------------3.create one directory in oracle database 4.which file u want upload put the file in this folder 5.create one table in stored the your documents like ----------------------------------------------------SQL> desc acc_dept; Name Null? Type ------------------------------- -------- ---ID NOT NULL VARCHAR2(20) NAME NOT NULL VARCHAR2(200) DOC NOT NULL BLOB USERNAME VARCHAR2(50) E_DATE DATE SYSTEMNAME VARCHAR2(50) TIME VARCHAR2(100) BLOB_NULL VARCHAR2(50) DESCRIPTION1 VARCHAR2(100) SIZE_MB NUMBER COMPCODE VARCHAR2(2) UNITCODE VARCHAR2(2)
https://www.facebook.com/groups/oraclefr/ 1/4
9/7/13
6.load_file_to_my_acc procedure code ---------------------------------------create or replace PROCEDURE load_file_to_my_acc (p_file_name IN acc_dept.name%TYPE,p_id IN acc_dept.id%TYPE,p_user IN acc_dept.username%TYPE,p_systemname IN acc_dept.systemname%TYPE,p_time in acc_Dept.time%type,p_description in acc_Dept.description1%type) AS v_bfile BFILE; v_blob BLOB; BEGIN INSERT INTO acc_dept (id, name, doc,e_Date,username,systemname,time,description1) VALUES (p_id, p_file_name, empty_blob(),sysdate,p_user,p_systemname,p_time,p_description) RETURN doc INTO v_blob; v_bfile := BFILENAME('ACC_DIR',p_file_name); Dbms_Lob.Fileopen(v_bfile, Dbms_Lob.File_Readonly); Dbms_Lob.Loadfromfile(v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile)); Dbms_Lob.Fileclose(v_bfile); COMMIT; END; 6 hours ago Like Govindasamy Raja view the pdf or any doc -------------------------1.create one text item or list item give the file name 2.click the view file coding -----------------------------extract_file_acc(:id,:filename); SELECT DISTINCT FILE_PATH INTO :GLOBAL.WORD FROM PATH_sETUP WHERE USERNAME=:GLOBAL.users AND SYSTEMNAME=:GLOBAL.SYSTEMNAME AND FILE_EXTN='doc'; SELECT DISTINCT FILE_PATH INTO :GLOBAL.PDF FROM PATH_sETUP WHERE USERNAME=:GLOBAL.users AND SYSTEMNAME=:GLOBAL.SYSTEMNAME and FILE_EXTN='pdf'; SELECT DISTINCT FILE_PATH INTO :GLOBAL.EXCEL FROM PATH_sETUP WHERE USERNAME=:GLOBAL.users AND SYSTEMNAME=:GLOBAL.SYSTEMNAME and FILE_EXTN='xls'; SELECT DISTINCT FILE_PATH INTO :GLOBAL.RAR FROM PATH_sETUP WHERE USERNAME=:GLOBAL.users AND SYSTEMNAME=:GLOBAL.SYSTEMNAME and FILE_EXTN='rar'; declare a varchar2(1000); begin SELECT substr(:filename,-3) into a from dual; if a='pdf' OR a='PDF' then declare AppID PLS_INTEGER; a varchar2(1000); begin select ' \\Ehsg02\D\RAJA\lob_output_acc\'||:filename INTO A FROM DUAL; AppID :=DDE.App_Begin(:GLOBAL.PDF||A,DDE.APP_MODE_NORMAL); end; end if; if a='doc' OR a='DOC' OR a='docx' or a='DOCX' then declare AppID PLS_INTEGER; B VARCHAR2(500); begin select ' \\Ehsg02\D\RAJA\lob_output_acc\'||:FILENAME INTO B FROM DUAL;
https://www.facebook.com/groups/oraclefr/ 2/4
9/7/13
AppID :=DDE.App_Begin(:GLOBAL.WORD||B,DDE.APP_MODE_NORMAL); end; end if; if a='rar' OR a='RAR' OR A='zip' OR A='ZIP' then declare AppID PLS_INTEGER; C VARCHAR2(500); begin select ' \\Ehsg02\D\RAJA\lob_output_acc\'||:FILENAME INTO c FROM DUAL; AppID := DDE.App_Begin(:GLOBAL.RAR ||C,DDE.APP_MODE_NORMAL); end; end if; if a='xls' OR a='XLS' OR a='docx' or a='DOCX' then declare AppID PLS_INTEGER; d varchar2(500); begin select ' \\Ehsg02\D\RAJA\lob_output_acc\'||:FILENAME INTO d FROM DUAL; AppID := DDE.App_Begin(:GLOBAL.EXCEL||d,DDE.APP_MODE_NORMAL); end; end if; EXCEPTION WHEN NO_DATA_FOUND THEN MESSAGE('FILE FORMAT NOT FOUND'); MESSAGE('FILE FORMAT NOT FOUND'); end ; 3.create one directory in oracle database for extract the file to save 4.extract_file_acc -procedure -----------------------create or replace PROCEDURE extract_file_acc(product_id in char,file_name in char) IS vblob BLOB; vstart NUMBER := 1; bytelen NUMBER := 32000; len NUMBER; my_vr RAW(32000); x NUMBER; l_output utl_file.file_type; BEGIN -- define output directory l_output := utl_file.fopen('LOB_OUT_ACC',file_name,'wb',32767); vstart := 1; bytelen := 32000; -- get length of blob SELECT dbms_lob.getlength(doc) INTO len FROM acc_dept WHERE id = product_id; -- save blob length x := len; -- select blob into variable SELECT doc INTO vblob FROM acc_dept WHERE id = product_id; -- if small enough for a single write IF len < 32767 THEN
https://www.facebook.com/groups/oraclefr/ 3/4
9/7/13
utl_file.put_raw(l_output,vblob); utl_file.fflush(l_output); ELSE -- write in pieces vstart := 1; WHILE vstart < len and bytelen > 0 LOOP dbms_lob.read(vblob,bytelen,vstart,my_vr); utl_file.put_raw(l_output,my_vr); utl_file.fflush(l_output); -- set the start position for the next cut vstart := vstart + bytelen; -- set the end position if less than 32000 bytes x := x - bytelen; IF x < 32000 THEN bytelen := x; END IF; end loop; END IF; utl_file.fclose(l_output); end; ---------------------------6 hours ago Like
https://www.facebook.com/groups/oraclefr/
4/4