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 StatementsEach insert statement adds one row to the database. For example, thefollowing statement adds a single new customer record to the customerdatabase table:insert into customer (acctno, cphone, cname,addr, ccity, cstate, czip, cdistrict, cstatus,cacctbal)values (:acctno, :cphone, :cname, :caddr,:ccity, :cstate, :czip, :cdistrict,:cstatus,:cacctbal);You may insert several rows into a table using a loop. For example:i = 1for i = 1 to new_customers.lastrow doinsert into customer(acctno, cphone, cname)values(:new_customers[i].acctno,:new_customers[i].cphone,:new_customers[i].cname)endfor;For a discussion of processing arrays using the row state attribute, seeWorking with Arrays, Table Fields, and Collections (see page 205).How You Can Use the Update StatementThe update statement replaces values in specified columns of a database tablewith new values. These new values can come from any of the following places:• Variables associated with the current frame• Columns from another table• The result of an evaluated expression• Global variables• Constants• A subselectYou can update all the rows in a table. For example, assume that you want tochange to five-digit account numbers for customers. The following statementupdates all existing account numbers in the customer table by adding 10000 toeach number:update customer set acctno = acctno + 10000;Working with a Database 153

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

Saved successfully!

Ooh no, something went wrong!