Quick Start to Using SAP Sybase IQ As a Web Client

This section illustrates how to use SAP Sybase IQ as a web client application to connect to an SAP Sybase IQ HTTP server and access a general HTTP web service. It does not illustrate SAP Sybase IQ web client capabilities to a full extent. Many SAP Sybase IQ web client features are available that are beyond the scope of this topic.

You can develop SAP Sybase IQ web client applications that connect to any type of online web server, but this section assumes that you have started a local SAP Sybase IQ HTTP server on port 8082 and want to connect to a web service named SampleHTMLService, created with the following SQL statements:

CREATE SERVICE SampleHTMLService
    TYPE 'HTML'
    USER DBA
    AUTHORIZATION OFF
    AS CALL sp_echo(:i, :f, :s);

CREATE PROCEDURE sp_echo(i INTEGER, f REAL, s LONG VARCHAR)
RESULT(ret_i INTEGER, ret_f REAL, ret_s LONG VARCHAR)
BEGIN
    SELECT i, f, s;
END;

Perform the following tasks to create an SAP Sybase IQ web client application:

  1. Run the following command to create an SAP Sybase IQ client database if one does not already exist:

    iqinit -dba DBA,sql client-database-name

    Replace client-database-name with a new name for your client database.

  2. Run the following command to start the client database:

    iqsrv16 client-database-name.db
  3. Run the following command to connect to the client database through Interactive SQL:

    dbisql -c "UID=DBA;PWD=sql;SERVER=client-database-name"
  4. Create a new client procedure that connects to the SampleHTMLService web service using the following SQL statement:

    CREATE PROCEDURE client_post(f REAL, i INTEGER, s VARCHAR(16), x VARCHAR(16))
        URL 'http://localhost:8082/SampleHTMLService'
        TYPE 'HTTP:POST'
        HEADER 'User-Agent:SATest';
  5. Execute the following SQL statement to call the client procedure and send an HTTP request to the web server:

    CALL client_post(3.14, 9, 's varchar', 'x varchar');

The HTTP POST request created by client_post looks similar to the following output:

POST /SampleHTMLService HTTP/1.0
ASA-Id: ea1746b01cd0472eb4f0729948db60a2
User-Agent: SATest
Accept-Charset: windows-1252, UTF-8, *
Date: Wed, 9 Jun 2010 21:55:01 GMT
Host: localhost:8082
Connection: close
Content-Type: application/x-www-form-urlencoded; charset=windows-1252
Content-Length: 58

&f=3.1400001049041748&i=9&s=s%20varchar&x=x%20varchar

The web service SampleHTMLService running on the web server extracts the parameter values for i, f, and s from the POST request and passes them as parameters to the sp_echo procedure. Parameter value x is ignored. The sp_echo procedure creates a result set which is returned to the web service. Agreement in parameter names between the client and the web server is essential for proper mapping.

The web service creates the response which is sent back to the client. The output displayed in Interactive SQL should be similar to the following output:

Attribute Value
Status HTTP/1.1 200 OK
Body
<html>
<head>
<title>/SampleHTMLService</title></head>
<body>
<h3>/SampleHTMLService</h3>
<table border=1>
<tr class="header"><th><b>ret_i</b></th>
<th><b>ret_f</b></th>
<th><b>ret_s</b></th>
</tr>
<tr><td>9</td><td>3.1400001049041748</td><td>s varchar</td>
Date Wed, 09 Jun 2010 21:55:01 GMT
Connection close
Expires Wed, 09 Jun 2010 21:55:01 GMT
Content-Type text/html; charset=windows-1252
Server Sybase IQ/16.0.0