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,380 hits

RSS World News

  • After ISIS, 'Mosul can never be the same' October 17, 2017
    A few days ago, Mahmoud Saeed boarded a plane for a trip that is sure to be filled with trepidation.
  • What's next for ISIS after the fall of Raqqa? October 18, 2017
    US-backed forces in Raqqa said Tuesday that major military operations against ISIS had ended as they worked to clear out the remnants of sleeper cells and mines in the ruins of the Syrian city.
  • Video shows Raqqa execution spot October 18, 2017
    This exclusive drone footage shows empty streets and destroyed buildings in Raqqa, a city on the brink of being liberated from ISIS.
  • ISIS arrests: How many are from travel ban countries? October 17, 2017
    They called it the "US Project." Their goal, allegedly, was to carry out an ISIS terror attack on New York during Ramadan that would "show them what they hadn't seen in 2001."
  • US appeals for calm as allies clash in Iraq October 17, 2017
    The United States has made an urgent call for calm in northern Iraq as Iraqi forces and Kurdish fighters -- two of Washington's key allies in the region -- clash over disputed territory.