rp_sqlredirect: Implementation
The RPC known as rp_sqlredirect has been implemented using
Sybase's Open-Server / Server-Library for Unix. The RPC may be
invoked as follows (note: the 1>, 2> etc symbols are representative
of prompts seen within isql. They are provided here only as a
placekeeper to help the eyes follow the flow):
1> exec servername...rp_sqlredirect
2> @dbname ,
3> @sqlstmt ,
4> @srcserver ,
5> @srcuserid ,
6> @srcpasswd ,
7> @dstserver ,
8> @dstuserid ,
9> @dstpasswd ,
10> @dsttable
Each RPC parameter is described below:
- servername
- The name of the Open Server. Originally this was intended to be
generic and applied to each different server. So far this has not been
a necessity, and hence we only have one open server known as open_acs_dds.
- @dbname
- The name of the database from which you are selecting data.
- @sqlstmt
- The SQL statement you wish to be executed in @db. For example,
``select * from table'' would select the entire contents of table.
Note that the SQL statement should be enclosed in single quotes (')
for most applications.
- @srcserver
- The name of the source dataserver. Continuing with
our example, this might be acs_dds.
- @srcuserid
- A valid username on @srcserver.
- @srcpasswd
- The password corresponding to @srcuserid.
- @dstserver
- The name of the destination dataserver. For example, sybase1.
- @dstuserid
- A valid username on @dstserver.
- @dstpasswd
- The password corresponding to @dstuserid.
- @dsttable
- The name of the table on @dstserver where the result
set of @sqlstmt will be placed. The table will be created automatically
and if there is already a table with that name, it will be dropped
and recreated. Note that if you specify an existing table, it
will be dropped! This table name should always be full qualified.
For example, use 'fred..foobar' instead of just foobar.
As with @sqlstmt, this name is generally placed inside of single
quotes (') for most applications.
The rp_sqlredirect RPC performs the following steps:
- Login to @srcserver as @srcuserid.
- Login to @dstserver as @dstuserid.
- Execute @sqlstmt in @dbname on @srcserver.
- Examine result set and create a @dsttable on @dstserver.
- Initiate bulk copy in on @dstserver using result set from @srcserver.
- Logout of @srcserver and @dstserver.
The RPC will return a completion code of 0 upon success. Informative
error messages should be returned to the client on both success and
failure.
Back to the SQL-Redirect Index Page