The runexecute script executes a stored procedure or T-SQL statement on Adaptive Server Enterprise through Adaptive Server Enterprise Web Services. This sample application invokes the execute Web method.
runexecute “web_service_URL” aseServerName user_ID password “SQLX_option” output_class count “sql_statement”
web_service_URL
The location of the Web service being used.
aseServerName
SOAP string indicating the name of the Adaptive Server Enterprise server in the interfaces file or LDAP server.
user_ID
The user ID needed to log in to the Adaptive Server Enterprise.
password
The password needed to log in to the Adaptive Server Enterprise.
SQLX option
String indicating one or more option parameters. These parameters specify characteristics of the SQLX result set. The following are valid option parameters:
binary={hex | base64}
columnstyle={element | attribute}
format={yes | no}
header={yes | no}
nullstyle={attribute | omit}
prefix=“value”
root={yes | no}
rowname=“value”
schemaloc=“value”
statement={yes | no}
tablename=“value”
targetns=“value”
You must provide values for value. For more information on SQLX functions and options, see XML Services in Adaptive Server Enterprise.
output_class
The kind of output desired. The following are valid values for this parameter:
schema - return an XML schema
dtd - return an XML DTD
data - return a result set
all - return schema, DTD, and data
count
The number of times to execute the statement. If the value of count is greater than 1, a session is created, and a persistent connection is used.
sql_statement
The statement to be executed on Adaptive Server Enterprise. This statement must be delimited by double quotes.
This example checks the version number for Adaptive Server Enterprise using a select statement.
runexecute "http://johndoe-sun:8183/services/ase" johndoe-sun sa nopasswordspecified "tablename=ws" all 1 "select @@version"
Adaptive Server Enterprise Web Services returns an XML schema, a DTD, and a result set containing the result of the executed statement.
This example executes a stored procedure called booksales on the pubs2 database. The stored procedure returns the number of copies sold for a specified book title ID.
runexecute "http://johndoe-sun:8183/services/ase" johndoe-sun sa nopasswordspecified "columnstyle=attribute,format=no,rowname=wsrow,prefix=Unnamedcol,nullstyle=attribute,header=yes" all 1 "execute booksales MC2222"
Adaptive Server Enterprise Web Services returns an XML schema, a DTD, and a result set containing the result of the executed statement.
This is the result set returned:
<?xml version="1.0" ?> <resultset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wsrow title="Silicon Valley Gastronomic Treats" total_sales="2032" Unnamedcol1="Books sold"/> </resultset>
This is the DTD returned:
<!ELEMENT resultset (row*)> <!ELEMENT row (title, total_sales, Unnamedcol1)> <!ELEMENT title (#PCDATA)> <!ELEMENT total_sales (#PCDATA)> <!ELEMENT Unnamedcol1 (#PCDATA)>
This is the schema returned:
<?xml version="1.0" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqlxml="http://www.iso-standards.org/mra/9075/ sqlx"> <xsd:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.iso-standards.org/mra/ 9075/sqlx.xsd" /> <xsd:complexType name="RowType.resultset"> <xsd:attribute name="title" type="VARCHAR_80" use="required"/> <xsd:attribute name="total_sales" type="INTEGER" use="optional"/> <xsd:attribute name="Unnamedcol1" type="VARCHAR_24" use="optional"/> </xsd:complexType> <xsd:complexType name="TableType.resultset"> <xsd:sequence> <xsd:element name="wsrow" type="RowType.resultset" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="VARCHAR_80"> <xsd:restriction base="xsd:string"> <xsd:length value="80"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="INTEGER"> <xsd:restriction base="xsd:integer"> <xsd:maxInclusive value="2147483647"/> <xsd:minInclusive value="-2147483648"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="VARCHAR_24"> <xsd:restriction base="xsd:string"> <xsd:length value="24"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="resultset" type="TableType.resultset"/> </xsd:schema>
This example executes a SQL query on the pubs2 database. The query returns the last names and cities of residence for authors who do not live in the same city as their publisher.
runexecute "http://johndoe-sun:8183/services/ase" johndoe-sun sa nopasswordspecified "tablename=ws,header=yes,schemaloc='http://www-edm/remote/svr/xmltestdir/resultset.xsd',targetns='http://www-edm/remote/svr/xmltestdir/'" data 1 "select distinct au_lname, authors.city from publishers, authors where authors.city not in (select city from publishers where authors.city = publishers.city)"
Adaptive Server Enterprise Web Services returns a result set containing the result of the executed statement.