Pump

<< Click to Display Table of Contents >>

Navigation:  Understanding Streaming SQL Concepts > SQLstream Overview >

Pump

Previous pageReturn to chapter overviewNext page

A pump is a SQLstream s-Server Repository Object that provides a continuously running INSERT INTO stream SELECT ... FROM query functionality, thereby enabling the results of a query to enter a named stream.

A pump wraps around a standard SQL INSERT INTO or SELECT FROM query, but gives this query an execution context.

The example below first creates and sets the schema "Test," then creates two streams, "OrderDataWithCreateTime" and "OrderData, then creates a pump that selects from the first stream and inserts into the second stream.

CREATE OR REPLACE SCHEMA "Test";

SET SCHEMA '"Test"';

 

CREATE OR REPLACE STREAM "OrderDataWithCreateTime" (

"key_order" VARCHAR(20),

"key_user" VARCHAR(20),

"key_billing_country" VARCHAR(20),

"key_product" VARCHAR(20),

"quantity" VARCHAR(20),

"eur" VARCHAR(20),

"usd" VARCHAR(20))

DESCRIPTION 'Creates origin stream for pump';

 

CREATE OR REPLACE STREAM "OrderData" (

"key_order" VARCHAR(20),

"key_user" VARCHAR(20),

"country" VARCHAR(20),

"key_product" VARCHAR(20),

"quantity" VARCHAR(20),

"eur" INTEGER,

"usd" INTEGER)

DESCRIPTION 'Creates destination stream for pump';

 

CREATE OR REPLACE PUMP "200-ConditionedOrdersPump" STOPPED AS

INSERT INTO "OrderData" (

"key_order", "key_user", "country",

"key_product", "quantity", "eur", "usd")

SELECT STREAM

"key_order", "key_user", "key_billing_country",

"key_product", "quantity", "eur", "usd"

FROM "OrderDataWithCreateTime";