Insert records
Username:  
Password:
  > Home
v User Guide
    > Introduction
    > Hello World
    > Flow Control
    > Function Calls
    > Authentication
    v Database access
       o Decode and encode
       o Searching
       o Display paging
       v Modify records
          o The matrix
          o Update records
          o Insert records
          o Delete records
    > Content Management
    > Remote Calling
    > Object-Oriented
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Database access >> Modify records >> Insert records <=  =>      <  1  >  
Insert records

A database insert operation (under the comment text "Insert new records" in the previous example) would look like:

database phbook action="insert";

 

The operation loops through the "keys" variable, of which each element points to a record in the matrix (matrix%key).  An insert query will be generated for each record.  The field list of the insert query is obtained from the "fields" variable, and the value list is from the matrix record (indexed by the field name from the "fields" variable.)

The field specified in the "keyfield" variable will obtained from the database platform.  (If the key can be generated automatically, it will be omitted from the field list and value list.  If the key needs to be obtained explicitly, BEE will do so and include the field and value to the insert query accordingly.)

The query would look like "insert into table (field1, field2, ... ) values (value1, value2, ... )".

In the above example, the Birthday values will be encoded with the Conversion "strtotime" as specified in the phbook%encode:Birthday element.  This will automatically convert the date string (e.g. "10 Jan, 2003") into the timestamp format.

The operation will stop at the first error.  The error code and error message are contained in status%database and message%database respectively.  (For the integrity of the database object, you will have them in the database object as well.  In our example, they are phbook%status and phbook%message.)

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd