Delete 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 >> Delete records <=  =>      <  1  >  
Delete records

A database delete operation (under the comment text "Delete existing records" in the previous example) would look like:

database phbook action="delete";

 

However, deleting multiple records from a database table in one operation is not always a good idea.  It is recommended NOT to use the "delete" action.  Instead, update the deleted records with a "flag" value in a particular field (e.g. 0 qty for a shopping cart item or false in the Active field), then either delete all flagged records afterwards via a query (optionally after user confirmation) or leave them there but skip them in subsequent processing.

As a protection from programming error, BEE will NOT delete multiple records based on a matrix, even if the "delete" action is used.  Instead, it will only select the first record from the matrix, extract its key value (the value of the field indicated by "keyfield"), delete just that record and stop.

The query would look like "delete from table where keyfield = keyvalue".

If you really want to delete multiple records, you can either specify the "query" parameter or to specify the "search" variable as in a "select" operation.  (The variable "keyfield" should be cleared in order to have the "delete" operation use the "search" variable to build the where-clause.  Otherwise, it will use the key field of the first matrix record as mentioned before.)

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