Introduction to batches – Sybase 12.4.2 User Manual

Page 258

Advertising
background image

Introduction to batches

238

Introduction to batches

A simple batch consists of a set of SQL statements, separated by semicolons.
For example, the following set of statements form a batch that adds a new sales
representative to the Eastern Sales department, and adds two sales orders for
that sales rep.

INSERT INTO

employee (emp_id, emp_fname, emp_lname, dept_id,

start_date)

VALUES (2054, Edward, Baer, 220, 1998-08-15);

INSERT INTO

sales_order (id, cust_id, order_date, fin_code_id,

region, sales_rep)

VALUES (41880, 717, 1998-08-24, BU, PA, 2054) ;

INSERT INTO

sales_order (id, cust_id, order_date, fin_code_id,

region, sales_rep)

VALUES (418898, 021, 1998-08-25, BU, PA, 2054) ;

COMMIT ;

INSERT

INTO department ( dept_id, dept_name )

VALUES ( 220, ’Eastern Sales’ )

go

UPDATE employee

SET dept_id = 220

WHERE dept_id = 200

AND state = ’MA’

go

COMMIT

go

You can include this set of statements in an application and execute them
together.

Advertising