File: import_clr.xml

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (137 lines) | stat: -rw-r--r-- 5,180 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 -  
 -  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
 -  project.
 -  
 -  Copyright (C) 1998-2018 OpenLink Software
 -  
 -  This project is free software; you can redistribute it and/or modify it
 -  under the terms of the GNU General Public License as published by the
 -  Free Software Foundation; only version 2 of the License, dated June 1991.
 -  
 -  This program is distributed in the hope that it will be useful, but
 -  WITHOUT ANY WARRANTY; without even the implied warranty of
 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 -  General Public License for more details.
 -  
 -  You should have received a copy of the GNU General Public License along
 -  with this program; if not, write to the Free Software Foundation, Inc.,
 -  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 -  
 -  
-->
<refentry id="fn_import_clr">
  <refmeta>
    <refentrytitle>import_clr</refentrytitle>
    <refmiscinfo>udt</refmiscinfo>
  </refmeta>
  <refnamediv>
    <refname>import_clr</refname>
    <refpurpose>This function automatically creates the SQL Type wrappers based on 
    the CLR Reflection API.</refpurpose>
  </refnamediv>
  <refsynopsisdiv>
    <funcsynopsis id="fsyn_import_clr">
      <funcprototype id="fprot_import_clr">
        <funcdef>any <function>import_clr</function></funcdef>
        <paramdef>in <parameter>assemblies_vector</parameter> any</paramdef>
        <paramdef>in <parameter>classes_vector</parameter> any</paramdef>
    	<paramdef><optional>in <parameter>security_mode</parameter> integer</optional></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>
  <refsect1 id="desc_import_clr">
    <title>Description</title>
    <para>This function automatically creates the SQL Type wrappers based on 
    the CLR Reflection API.</para>
  </refsect1>
  <refsect1 id="params_import_clr">
    <title>Parameters</title>
    <refsect2><title>assemblies_vector</title>
      <para>a vector of assembly names (as VARCHAR) to look into (or null).</para>
    </refsect2>
    <refsect2><title>classes_vector</title>
      <para>a vector of type names to create SQL type wrappers for (or null to mark 
	    all the types in the assemblies specified by assemblies_vector. In that case the 
	    <computeroutput>assemblies_vector</computeroutput> cannot be NULL).</para>
    </refsect2>
    <refsect2><title>security_mode</title>
      <para>This optional parameter defines the access mode as follows:</para>
	  <simplelist>
	    <member><emphasis>0</emphasis> - restricted (default if unspecified)</member>
	    <member><emphasis>1</emphasis> - unrestricted</member>
	  </simplelist>
    </refsect2>
  </refsect1>
  <!--
  <refsect1 id="ret_import_clr"><title>Return Types</title>
    <para></para>
  </refsect1>
  -->
  <refsect1 id="examples_import_clr">
    <title>Examples</title>
    <example id="ex_import_clr"><title>Importing a Class</title>
 <para>Here is a simple C# program that we can import and use with Virtuoso.  
 This example requires that you are running Virtuoso with CLR support.</para>

 <para>Using a text editor create a C# source file in the server 
 root directory called sanity.cs, with the following contents:</para>

 <programlisting><![CDATA[
using System;

public class sanity
{
    public static string test(string  name) {
       return "Hello "+ name + ", from Virtuoso";
    }
}
]]></programlisting>
 <para>This sample needs to be compiled into bytecode assembly before it can 
 be used.  Use a command prompt that is suitably set up to find .NET 
 utilities in its path, the .NET Framework SDK installation provides a 
 shortcut in the Start menu to a command prompt that is preconfigured.  
 From the command prompt change directory to the Virtuoso server root 
 containing the C# source file.  Execute:</para>

 <programlisting><![CDATA[
C:\Program Files\OpenLink\Virtuoso 3.0\bin>csc /target:library sanity.cs
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
Copyright (C) Microsoft Corporation 2001. All rights reserved.
]]></programlisting>

 <para>Now this library must be introduce to the Virtuoso Server.  Using ISQL 
 use the following commands to test the CLR:</para>

 <programlisting><![CDATA[
C:\Program Files\OpenLink\Virtuoso 3.0\bin>isql 1112
Connected to OpenLink Virtuoso
Driver: 03.00.2315 OpenLink Virtuoso ODBC Driver
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Type HELP; for help and EXIT; to exit.
SQL> DB..import_clr (vector ('sanity'), vector ('sanity'));

Done. -- 300 msec.
SQL> select sanity::test('Rob');
callret
VARCHAR
______________________________________________

Hello Rob, from Virtuoso

1 Rows. -- 60 msec.
]]></programlisting>
 
 <para>Congratulations, you have proven that your Virtuoso server 
 can run .NET classes.</para>

    </example>
  </refsect1>
  <refsect1 id="seealso_import_clr">
    <title>See Also</title>
    <para><link linkend="runtimehosting">The Runtime Hosting Chapter</link></para>
    <para><link linkend="fn_unimport_clr">unimport_clr</link></para>
  </refsect1>
</refentry>