Home » Developer & Programmer » Forms » Importing csv file columns data into Data Block Using Oracle Forms (Oracle Forms 11g, Windows)
Importing csv file columns data into Data Block Using Oracle Forms [message #675455] Mon, 01 April 2019 01:20 Go to next message
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 #675457 is a reply to message #675455] Mon, 01 April 2019 03:25 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Somthing must happen.
You need to debug your code and see which lines actually get executed.
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675458 is a reply to message #675457] Mon, 01 April 2019 04:10 Go to previous messageGo to next message
rehmankhan
Messages: 22
Registered: July 2018
Junior Member
cookiemonster wrote on Mon, 01 April 2019 03:25
Somthing must happen.
You need to debug your code and see which lines actually get executed.

How to debug code?
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675459 is a reply to message #675458] Mon, 01 April 2019 04:37 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
You use a debugger (forms has a debug mode read up on it).
If you don't have a debugger then generally you write code to display/write to a file* data that tells you what is going on - what line you're on, what the values of relevant variables are.
You could use the message built-in for that.


* delete as appropriate
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675462 is a reply to message #675459] Mon, 01 April 2019 04:49 Go to previous messageGo to next message
rehmankhan
Messages: 22
Registered: July 2018
Junior Member
cookiemonster wrote on Mon, 01 April 2019 04:37
You use a debugger (forms has a debug mode read up on it).
If you don't have a debugger then generally you write code to display/write to a file* data that tells you what is going on - what line you're on, what the values of relevant variables are.
You could use the message built-in for that.


* delete as appropriate
I have this code. Do you know code about read "CSV" File and show "CSV" data into data block


declare 
l_out_file CLIENT_text_io.file_type; 
linelog varchar2(32767); 
BEGIN 
l_out_file := CLIENT_text_io.fopen( :WE_GROUP.FILE, 'r' ); 
 
LOOP 
BEGIN 
CLIENT_text_io.get_line( l_out_file, linelog);

EXCEPTION 
WHEN NO_DATA_FOUND THEN 
EXIT; 
END; 
END LOOP; 
standard.commit;

 
CLIENT_text_io.fclose( l_out_file ); 
END;

Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675463 is a reply to message #675462] Mon, 01 April 2019 04:57 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
That's deeply pointless code.
You're getting lines from a file, putting them in a local variable, and then doing nothing with the local variable.

There's no point reading a file unless you are going to do something with the contents.
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675464 is a reply to message #675463] Mon, 01 April 2019 05:02 Go to previous messageGo to next message
rehmankhan
Messages: 22
Registered: July 2018
Junior Member
cookiemonster wrote on Mon, 01 April 2019 04:57
That's deeply pointless code.
You're getting lines from a file, putting them in a local variable, and then doing nothing with the local variable.

There's no point reading a file unless you are going to do something with the contents.
Then, how to show data into block using local variable?
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675465 is a reply to message #675464] Mon, 01 April 2019 05:10 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
By assigning to a datablock item.
Re: Importing csv file columns data into Data Block Using Oracle Forms [message #675466 is a reply to message #675465] Mon, 01 April 2019 05:12 Go to previous messageGo to next message
rehmankhan
Messages: 22
Registered: July 2018
Junior Member
cookiemonster wrote on Mon, 01 April 2019 05:10
By assigning to a datablock item.
Please share example
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 Go to previous message
cookiemonster
Messages: 13917
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.
Previous Topic: webuutil -- application := CLIENT_OLE2.create_obj('Excel.Application') not working
Next Topic: FRM-50016 Legal Characters are 0-9 -+E Error Oracle Forms
Goto Forum:
  


Current Time: Thu Mar 28 15:31:14 CDT 2024