Hi all experts,
Quick context: We are pushing some file from our local server to Prod Server and we need to read the number of rows in the file, on the destination folder, and compare against the original file, in order to make sure file was not corrupted along the way:
So I found this function that can get the size of the file in the remote server, but I need to know the total records in the file.
Does someone know how to do that, or modify this function to read the row count instead of the file size?
Our Database info:

CREATE OR REPLACE FUNCTION FileSizedev (
HostIP VARCHAR2,
PortNo VARCHAR2,
UserName VARCHAR2,
Pass VARCHAR2,
Dir VARCHAR2,
FileName VARCHAR2
)
RETURN NUMBER
IS
oConn UTL_TCP.connection;
pList ftp.t_string_table;
vFileFound BOOLEAN;
vFilesize VARCHAR2(100);
vFound BOOLEAN;
vFin NUMBER;
vIni NUMBER;
vRet NUMBER;
BEGIN
-- Initialize flag
vFound := FALSE;
BEGIN
-- Login to FTP server
oConn := FTP.login (
p_host => HostIP,
p_port => PortNo,
p_user => UserName,
p_pass => Pass,
p_timeout => 100
);
-- List files in the directory
FTP.list(oConn, Dir, pList);
-- Logout from FTP server
FTP.logout(oConn, FALSE);
-- Search for the file in the directory listing
FOR j IN 1..pList.count LOOP
IF INSTR(pList(j), FileName, 1) <> 0 THEN
vFileFound := TRUE;
vFin := INSTR(pList(j), FileName, 1) - 2;
-- Find the starting position of the file size in the string
FOR i IN REVERSE 1..vFin LOOP
IF SUBSTR(pList(j), i, 1) = ' ' THEN
vIni := i;
EXIT;
END IF;
END LOOP;
-- Extract the file size
vFilesize := SUBSTR(pList(j), vIni, vFin - vIni + 1);
EXIT;
END IF;
END LOOP;
-- Return the file size or -1 if file is not found
IF vFileFound THEN
vRet := TO_NUMBER(TRIM(vFilesize));
ELSE
vRet := -1;
END IF;
EXCEPTION
WHEN OTHERS THEN
-- Handle different error codes
CASE SQLCODE
WHEN -29260 THEN
vRet := -2;
WHEN -29276 THEN
vRet := -3;
WHEN -20000 THEN
vRet := -4;
ELSE
RAISE;
END CASE;
END;
-- Return the result
RETURN vRet;
END;
/
Somebody suggested to rather compare the file hash:
l_hash := sys.dbms_crypto.hash( src => p_blob, typ => sys.dbms_crypto.hash_sh256 );
But the file is not inside the Database but the physical folder on the server.
How to get the Blob?
Any idea?
Thanks