Sybase 12.4.2 manual Introduction to batches, 238

Models: 12.4.2

1 536
Download 536 pages 20.34 Kb
Page 258
Image 258

Introduction to batches

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.

238

Page 258
Image 258
Sybase 12.4.2 manual Introduction to batches, 238