Hi,
I am working to solve the following issue. I have a pl/sql script that reads values from a text file and plugs them into a query and writes the query output to an excel file.
The text file is created from an excel file that my end users email weekly. It contains a single columns of data. Sometimes the converted text file contains trailing whitespaces which causes the query not to return any data when there is actually data in the database.
So, here is what part of the script looks like:
DECLARE
f utl_file.file_type;
debug utl_file.file_type;
n schema.table.column%TYPE;
end_of_file number;
type vcur is REF CURSOR;
lver vcur;
ct number;
nf boolean;
BEGIN
f := utl_file.fopen(directory,file.txt,'R');
debug := utl_file.fopen(directory,file.log,'A');
end_of_file := 0;
WHILE end_of_file = 0
loop
BEGIN
utl_file.get_line(f,n);
if length(n) != 0 then
n:= trim(n);
open lver for
select column from table where column = n order by column;
utl_file.put_line(debug, 'select column from table where column ='|| n||'order by column',true);
.......
In the debug file, what I see for the values that are not returning data and have a trailing space is this:
select column from table where column =245 order by column;
and the ones that return data and do not have a trailing space is this:
select column from table where column =386order by column;
As you can see the script has code that trims the whitespace, but this is not actually happening. When I manually delete the whitespace in the text file and run the script, data gets returned as it should.
So, I am not sure what else to do. I could use the ORDCOM api to read directly from the excel file. But I am stumped as to why the trim function is not working.
Thanks.