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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
<?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_vd_remote_proc_wrapper">
<refmeta>
<refentrytitle>vd_remote_proc_wrapper</refentrytitle>
<refmiscinfo>rmt</refmiscinfo>
</refmeta>
<!--
Parameters:
dsn - remote datasource name
remote_name - name of remote procedure
local name - name of PL wrapper to be created
metadata - vector of vectors containing a parameters information
each of vectors need to have following structure:
type of parameter - 'IN'/'OUT'/'INOUT'
name of parameter - the name of parameter
data type - SQL datatype of parameter as string (ie.'VARCHAR', "INT' etc.)
SOAP type - a XSD/custom datatype for SOAP/WSDL actions (if not needed, must
be empty string ie. '')
status_code - returns status code of wrapper generation
error_message - returns error message if status code is different than 00000
make_resultset - causes wrapper to be made to return result set.
description - to add special comment to the wrapper for VSMX feature
example (usage in PL routine code):
...
declare state, msg varchar;
vd_remote_proc_wrapper ('Northwind.dbo.Sales By Year;1', 'MS.SQL.SALES_BY_YEAR'
, 'sql_lite', vector (vector ('IN', '_from', 'VARCHAR', ''), vector ('OUT',
'_to', 'DATETIME', '')), state, msg , 1, 'This is a test');
if (state <> '00000')
signal (state, msg);
...
-->
<refnamediv>
<refname>vd_remote_proc_wrapper</refname>
<refpurpose>Creating a PL wrapper for remote procedure execution</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_vd_remote_proc_wrapper">
<funcprototype id="fproto_vd_remote_proc_wrapper">
<funcdef>varchar <function>vd_remote_proc_wrapper</function></funcdef>
<paramdef>in <parameter>dsn</parameter> varchar</paramdef>
<paramdef>in <parameter>remote_name</parameter> varchar</paramdef>
<paramdef>in <parameter>local_name</parameter> varchar</paramdef>
<paramdef>in <parameter>metadata</parameter> any</paramdef>
<paramdef>out <parameter>status_code</parameter> varchar</paramdef>
<paramdef>out <parameter>error_message</parameter> varchar</paramdef>
<paramdef>in <parameter>make_resultset</parameter> integer</paramdef>
<paramdef>in <parameter>description</parameter> varchar</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_vd_remote_proc_wrapper">
<title>Description</title>
<para>This is to create a PL stored procedure to execute a Remote Stored Procedures. It returns results as a SQL result set as well as an array(vector) depending of the 'make_resultset' flag.
</para>
</refsect1>
<refsect1 id="params_vd_remote_proc_wrapper">
<title>Parameters</title>
<refsect2>
<title>dsn</title>
<para>the remote datasource name</para>
</refsect2>
<refsect2>
<title>remote_name</title>
<para>name of the remote procedure</para>
</refsect2>
<refsect2>
<title>local_name</title>
<para>name of the PL wrapper to be created locally</para>
</refsect2>
<refsect2>
<title>metadata</title>
<para>A vector of vectors containing a parameters information
each of vectors need to have following structure:
</para>
<simplelist>
<member>type of parameter - 'IN'/'OUT'/'INOUT' </member>
<member>name of parameter - the name of parameter</member>
<member>data type - SQL datatype of parameter as string (for example
'VARCHAR', 'INT' etc.)</member>
<member>SOAP type - a XSD/custom datatype for SOAP/WSDL actions (if not needed, must
be empty string ie. '')</member>
</simplelist>
</refsect2>
<refsect2>
<title>status_code</title>
<para>returns SQL status code of the PL wrapper generation</para>
</refsect2>
<refsect2>
<title>error_message</title>
<para>returns the error message if status code is different than 00000</para>
</refsect2>
<refsect2>
<title>make_resultset</title>
<para>A flag 0/1 default 0. If is true (1) the wrapper will be generated to return result set. Otherwise will be generated to return an array.</para>
</refsect2>
<refsect2>
<title>description</title>
<para>The text of a comment to added to the wrapper. It then will be shown as a method
description if the PL wrapper is published as a SOAP method.
</para>
</refsect2>
</refsect1>
<refsect1 id="examples_vsp_calculate_digest"><title>Examples</title>
<example id="ex_vsp_calculate_digest"><title>Creating a PL wrapper which returns resultset</title>
<para>The following example will create a PL wrapper
to invoke the MS SqlServer Stored Procedure 'Northwind.dbo.CustOrderHist'
</para>
<programlisting><![CDATA[
-- the wrapper creation (fragment of Virtuoso/PL)
declare state, msg varchar;
vd_remote_proc_wrapper ('Northwind.dbo.CustOrderHist', 'MS.SQL.CustOrderHist',
'sql_lite', vector (vector ('IN', '_CustomerID', 'VARCHAR', '')), state, msg , 1, 'This is a test');
if (state <> '00000')
signal (state, msg);
-- PL wrapper source that will be created
create procedure "MS"."SQL"."CustOrderHist" (IN "_CustomerID" VARCHAR) returns any array array
{
--PL Wrapper for remote procedure
--##This is a test
--"DSN:sql_lite PROCEDURE:Northwind.dbo.CustOrderHist"
declare dta, mdta any;
declare params any;
params := vector ("_CustomerID");
set_user_id ('dba');
rexecute ('sql_lite', '{call "Northwind"."dbo"."CustOrderHist" (?)}', NULL, NULL, params, 0, mdta, dta);
exec_result_names(mdta[0]);
declare i, l integer;
i := 0; l := length (dta);
while(i<l) {
exec_result(dta[i]);
i:=i+1;
}
}
-- result from execution
SQL> "MS"."SQL"."CustOrderHist" ('ALFKI');
ProductName Total
VARCHAR NOT NULL INTEGER
_______________________________________________________________________________
Aniseed Syrup 6
Chartreuse verte 21
Escargots de Bourgogne 40
Flotemysost 20
Grandma's Boysenberry Spread 16
Lakkalikri 15
Original Frankfurter grne Soe 2
Raclette Courdavault 15
Rssle Sauerkraut 17
Spegesild 2
Vegie-spread 20
11 Rows. -- 18 msec.
]]></programlisting>
</example>
</refsect1>
<refsect1 id="seealso_vsp_calculate_digest"><title>See Also</title>
<para>
<link linkend="fn_rexecute">rexecute</link>
<link linkend="fn_vd_remote_data_source">vd_remote_data_source</link>
</para>
</refsect1>
</refentry>
|