Posts Tagged ‘oracle forms 10g

19
Nov
09

Upload dan Read File di Forms 10g

Ini adalah potongan code sederhana untuk mengupload dan membaca file teks. Dalam contoh ini digunakan :TXT_DELIMITER untuk pemisah antara nilai kolom satu dan kolom selanjutnya.

/*UTK BROWSE FILE*/
declare
vchfilename	varchar2(100);
begin
vchfilename 	:= CLIENT_GET_FILE_NAME(NULL, NULL, 'TEXT FILES (*.TXT)|*.TXT', NULL, OPEN_FILE);
end;

/*UTK BACA FILE*/
declare
fHandle     	client_text_io.file_type;
vchBuff     	varchar2(1800);
nmbPos		number;  			--ini menandakan letak delimiter.

begin
fHandle 	:= client_text_io.fopen(vchfilename, 'r');
LOOP
Client_Text_IO.Get_Line(fHandle, vchBuff);

nmbPos := instr(vchBuff, :TXT_DELIMITER, 1, 1);
--mencari karakter delimiter dalam vchbuff, dimulai dari karakter pertama, yang pertama kali ditemukan.

:KOLOM_SATU := upper(trim(substr(vchBuff, 1, nmbPos-1)));
--ambil karakter dari karakter pertama sampai pos-1.

vchBuff := substr(vchBuff, nmbPos+1);
--delete karakter pertama s/d pos+1.

:KOLOM_DUA := upper(trim(substr(vchBuff, 1, nmbPos-1)));
--ambil karakter dari karakter pertama sampai pos-1.

vchBuff := substr(vchBuff, nmbPos+1);
--delete karakter pertama s/d pos+1.

dst.

Client_Text_IO.New_Line;
END LOOP;

client_text_io.fclose(fHandle);

exception when others then
client_text_io.fclose(fHandle);
end;
Advertisements



Blog Stats

  • 36,654 hits

RSS World News

  • Why would Trump invite Putin back for more? July 20, 2018
    There will be verdicts, votes -- and now Vlad? And it'll all end with a victory parade of sorts. This fall is going to be *lit* in Washington.
  • Trump is inviting Putin to Washington July 20, 2018
    President Donald Trump hopes to welcome Russian President Vladimir Putin in Washington this fall, White House press secretary Sarah Sanders said in a statement Thursday.
  • See intel chief stunned by Putin invite July 20, 2018
    Director of National Intelligence Dan Coats reacted to breaking news that Russian President Vladimir Putin is scheduled for a visit to Washington in the fall, according to the White House.
  • Jake Tapper: What the hell is going on? July 19, 2018
    CNN's Jake Tapper reacts to White House press secretary Sarah Sanders' statement that says President Trump disagrees with Putin's "sincere" proposal to interrogate Americans.
  • Reversals deepen questions about Trump and Putin's meeting July 19, 2018
    When President Donald Trump insisted he meet his Russian counterpart one-on-one, he cited the potential for leaks as rationale to bar aides from attending the session.
Advertisements