10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Access a Database with Standard SQL StatementsUsing the where clause, you can update only selected rows. The followingexample updates only the customer who meets the criteria defined in thewhere clause:/* Update customer's account balance */update customerset cacctbal = cacctbal - :chargeswhere acctno = :checkout_form.acctno;There are also query object and cursor versions of the update statement. Bothof these update operations modify the values in the current row when thestatement is executed. For examples of query object and cursor updatestatements, see How You Can Use Query Objects (see page 177) and How YouCan Use Cursors to Access the Database (see page 157).How You Can Use the Delete StatementThe delete statement removes rows from a database table. You can delete allrows or, by using a where clause, only specified rows.For example, assume that you want to remove all customers from thecustomer table whose accounts are closed. (The value for a closed account isstored in the CLOSED constant.) The following statement performs this task:delete from customer where cstatus = CLOSED;There are also query object and cursor versions of the delete statement. Bothof these delete operations remove the current row when the statement isexecuted. For examples of query object and cursor delete statements, see HowYou Can Use Query Objects (see page 177) and How You Can Use Cursors toAccess the Database (see page 157).How You Can Use Other SQL StatementsThere are two types of SQL statements that you can code directly in a 4GLscript:• Data definition statementsThese include statements that create data structures, such as tables orviews, rules, and database events.All data definition statements participate in transactions. Using one ofthese statements initiates a transaction if none was open, and any workperformed by these statements is affected by the commit and rollbackstatements.For more information about transactions, see How You Can ManageTransactions (see page 182).154 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!