Importing csv file columns data into Data Block Using Oracle Forms [message #675455] |
Mon, 01 April 2019 01:20 |
|
rehmankhan
Messages: 22 Registered: July 2018
|
Junior Member |
|
|
I want read "CSV" File columns data into Oracle Forms Data Block. I have code when button press then nothing happen. How to solve this problem? I am using Oracle Forms Application 11g
Code:
Declare
in_file Client_Text_IO.File_Type;
linebuf VARCHAR2(1800);
BEGIN
in_file := client_Text_IO.Fopen(:WE_GROUP.FILE, 'r');
LOOP
Client_Text_IO.Get_Line(in_file, linebuf);
p_output_line(linebuf);
Client_Text_IO.New_Line;
END LOOP;
EXCEPTION
WHEN no_data_found THEN
Client_Text_IO.Put_Line('Closing the file...');
Client_Text_IO.Fclose(in_file);
END;
Procedure code:
PROCEDURE p_output_line(p_line varchar2) IS
vLINE VARCHAR2(4000);
vVALUE VARCHAR2(1000);
vCOMMA_COUNT NUMBER;
BEGIN
vLINE := p_line;
vCOMMA_COUNT := LENGTH(vLINE)- LENGTH(REPLACE(vLINE,',','')); -- COUNT THE NUMBER OF COMMAS
FOR I IN 1.. vCOMMA_COUNT+1 LOOP
vVALUE := SUBSTR(vLINE,1,INSTR(vLINE,',')-1); -- IF vLINE = 123,ABC,9877 THEN VVALUE WILL BE 123
IF vVALUE IS NULL THEN
vVALUE := vLINE;
END IF;
vLINE := SUBSTR(vLINE,INSTR(vLINE,',')+1) ; -- CHANGE 123,ABC,9877 TO BE ABC,9877
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
MESSAGE('Please Check the data type is appropriate on you excel file');
MESSAGE('Please Check the data type is appropriate on you excel file');
END;
|
|
|
|
|
|
|
|
|
|
|
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675467 is a reply to message #675466] |
Mon, 01 April 2019 05:25 |
cookiemonster
Messages: 13925 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You want an example of how to assign a local variable to a datablock item?
Really?
That's forms code at it's most absolute basic. If you really don't know how to do that then you need to stop trying to write forms code and go on a training course.
I'm not joking even a little bit.
I suspect you do know how to do that and have got your brain so tangled up with the concept of reading a file that you've lost sight of the fact that once the data is read from the file into a variable it is no different to data got from any other source.
So try actually thinking about it.
|
|
|