www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
csv_cols_def
csv_load
csv_load_file
csv_parse
csv_table_def
file_delete
file_dirlist
file_mkdir
file_mkpath
file_open
file_stat
file_to_string
file_to_string_outpu...
file_unlink
get_csv_row
gz_file_open
os_chmod
os_chown
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Phrases
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web & Internet
XML
XPATH & XQUERY

Functions Index

file_to_string_output

get contents of a file as a string output stream
file_to_string_output (in file varchar, in from integer, in to integer);
Description

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.

Parameters
file – a varchar path relative to server's working directory.
from – an optional integer byte offset of the start of the segment to extract. Defaults to 0.
to – an optional integer byte offset of the end of the requested segment. Defaults to file length.
Examples
Insert file contents into a table

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');
      
See Also

file_to_string , string_to_file , string_output