This function requires dba privileges.
This function returns a string output stream initialized to contain the text of the file or its segment, on local file system path relative to the server's working directory.
file_to_string_output can handle longer files than file_to_string and the resulting string output, if too long to be converted into a varchar, can be stored inside a blob.
Access controls in the server configuration file apply. An attempt to access a file in a directory where access is not explicitly allowed will signal an error.
This example shows how to insert file contents into a table file_table with two columns.
create table
file_table (
ft_name varchar,
ft_cont long varbinary,
primary key (ft_name));
create procedure
insert_files (in fname varchar)
{
declare strout_handle any;
strout_handle := file_to_string_output (fname);
insert into file_table (ft_name, ft_cont)
values (fname, strout_handle);
strout_handle := file_to_string_output (fname, 10);
insert into file_table (concat (ft_name, '_1'), ft_cont)
values (fname, strout_handle);
strout_handle := file_to_string_output (fname, 10, 20);
insert into file_table (concat (ft_name, '_2'), ft_cont)
values (fname, strout_handle);
};
insert_file ('foo.dat');