Thank you very much, Morty and Hugh!
I just found out that the isql command line has two mode: file mode and
command line mode:
isql 1111 dba dba <file.sql>
isql 1111 dba dba exec="<command>"
Best,
Gang
B
On Tue, Apr 7, 2015 at 10:14 PM, Hugh Williams <hwilli...@openlinksw.com>
wrote:
> Hi Gang,
>
> You could also place the procedure to be loaded in a file (dump.sql) and
> use the “load” command to load it into the database:
>
> $ isql 1111 dba dba verbose=on banner=off prompt=off echo=ON errors=stdout
> exec='load dump.sql'
> Connected to OpenLink Virtuoso
> Driver: 07.10.3211 OpenLink Virtuoso ODBC Driver
> OpenLink Interactive SQL (Virtuoso), version 0.9849b.
> Type HELP; for help and EXIT; to exit.
>
> -- Line 1:
> CREATE PROCEDURE dump_one_graph
> ( IN srcgraph VARCHAR ,
> IN out_file VARCHAR ,
> IN file_length_limit INTEGER := 1000000000
> )
> {
> DECLARE file_name VARCHAR;
> DECLARE env,
> ses ANY;
> DECLARE ses_len,
> max_ses_len,
> file_len,
> file_idx INTEGER;
> SET ISOLATION = 'uncommitted';
> max_ses_len := 10000000;
> file_len := 0;
> file_idx := 1;
> file_name := sprintf ('%s%06d.ttl', out_file, file_idx);
> string_to_file ( file_name || '.graph',
> srcgraph,
> -2
> );
> string_to_file ( file_name,
> sprintf ( '# Dump of graph <%s>, as of %s\n@base <>
> .\n',
> srcgraph,
> CAST (NOW() AS VARCHAR)
> ),
> -2
> );
> env := vector (dict_new (16000), 0, '', '', '', 0, 0, 0, 0, 0);
> ses := string_output ();
> FOR (SELECT * FROM ( SPARQL DEFINE input:storage ""
> SELECT ?s ?p ?o { GRAPH `iri(?:srcgraph)` { ?s ?p
> ?o } }
> ) AS sub OPTION (LOOP)) DO
> {
> http_ttl_triple (env, "s", "p", "o", ses);
> ses_len := length (ses);
> IF (ses_len > max_ses_len)
> {
> file_len := file_len + ses_len;
> IF (file_len > file_length_limit)
> {
> http (' .\n', ses);
> string_to_file (file_name, ses, -1);
> gz_compress_file (file_name, file_name||'.gz');
> file_delete (file_name);
> file_len := 0;
> file_idx := file_idx + 1;
> file_name := sprintf ('%s%06d.ttl', out_file, file_idx);
> string_to_file ( file_name,
> sprintf ( '# Dump of graph <%s>, as of %s
> (part %d)\n@base <> .\n',
> srcgraph,
> CAST (NOW() AS VARCHAR),
> file_idx),
> -2
> );
> env := VECTOR (dict_new (16000), 0, '', '', '', 0, 0, 0,
> 0, 0);
> }
> ELSE
> string_to_file (file_name, ses, -1);
> ses := string_output ();
> }
> }
> IF (LENGTH (ses))
> {
> http (' .\n', ses);
> string_to_file (file_name, ses, -1);
> gz_compress_file (file_name, file_name||'.gz');
> file_delete (file_name);
> }
> }
>
>
> Done. -- 13 msec.
>
> -- Line 72:
> $
>
> Best Regards
> Hugh Williams
> Professional Services
> OpenLink Software, Inc. // http://www.openlinksw.com/
> Weblog -- http://www.openlinksw.com/blogs/
> LinkedIn -- http://www.linkedin.com/company/openlink-software/
> Twitter -- http://twitter.com/OpenLink
> Google+ -- http://plus.google.com/100570109519069333827/
> Facebook -- http://www.facebook.com/OpenLinkSoftware
> Universal Data Access, Integration, and Management Technology Providers
>
> On 7 Apr 2015, at 22:08, Morty <morty+virtu...@frakir.org> wrote:
>
> On Tue, Apr 07, 2015 at 04:36:39PM -0400, Gang Fu wrote:
>
> In the bash shell, we need to take care of single quote by converting ' to
> '"'"'.
>
>
> Gang --
>
> You can avoid some issues and debug more easily by using isql's run
> file syntax.
>
> temp_file=`mktemp /somedir/tmpXXXXX`
> $command_to_generate_procedure > $temp_file &&
> isql 1111 dba $dba_password $temp_file
>
> If there are any issues, you can look at the temporary file to debug
> quoting and the like.
>
> - Morty
>
>
> ------------------------------------------------------------------------------
> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> Develop your own process in accordance with the BPMN 2 standard
> Learn Process modeling best practices with Bonita BPM through live
> exercises
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> _______________________________________________
> Virtuoso-users mailing list
> Virtuoso-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users
>
>
>
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users