Data
Table of Contents

Functions for manipulating records.


  • func delete_record( sequence db_name, sequence table_name, object key )   
  • func get_record( sequence db_name, sequence table_name, object key, sequence field, sequence index )   
  • func get_record2( sequence db_name, sequence table_name, sequence search_field, object search, sequence field, sequence field_index )   
  • func get_record_mult_fields( sequence db_name, sequence table_name, object key, sequence field, sequence index )   
  • func insert_record( sequence db_name, sequence table_name, object blank_record, sequence data, sequence index )   
  • func insert_record2( sequence db_name, sequence table_name, object blank_record, sequence data, sequence index )   
  • func update_record( sequence db_name, sequence table_name, object key, sequence index, sequence data )   
  • func update_record2( sequence db_name, sequence table_name, object key, sequence index, sequence data, integer key_changing )     
     
    Subtopics:
  • Datatypes
  • Dates

    Data
    Table of Contents

    [func]
    delete_record
    ( sequence db_name, sequence table_name, object key )

    Category: Data

    Delete record with primary key 'key' from specified db/table.

    See Also: get_record, get_record2, get_record_mult_fields, insert_record, insert_record2, update_record, update_record2


    Data
    Table of Contents

    [func]
    get_record
    ( sequence db_name, sequence table_name, object key, sequence field, sequence index )

    Category: Data

    Returns a field (or the whole field as a flat record) with primary key = key from table table_name. You may specify either the field name or the index (as returned by validate_field()). Data is returned as a sequence. To get the actual value, take the first element of the data returned. This is to allow error processing.

    See Also: delete_record, get_record2, get_record_mult_fields, insert_record, insert_record2, update_record, update_record2


    Data
    Table of Contents

    [func]
    get_record2
    ( sequence db_name, sequence table_name, sequence search_field, object search, sequence field, sequence field_index )

    Category: Data

    Allows record retrieval based on non-key field values. Returns only the first record found with the correct field value.

    See Also: delete_record, get_record, get_record_mult_fields, insert_record, insert_record2, update_record, update_record2


    Data
    Table of Contents

    [func]
    get_record_mult_fields
    ( sequence db_name, sequence table_name, object key, sequence field, sequence index )

    Category: Data

    Retrieves multiple fields from a record.

    See Also: delete_record, get_record, get_record2, insert_record, insert_record2, update_record, update_record2


    Data
    Table of Contents

    [func]
    insert_record
    ( sequence db_name, sequence table_name, object blank_record, sequence data, sequence index )

    Category: Data

    Inserts a record into specified table.

    See Also: delete_record, get_record, get_record2, get_record_mult_fields, insert_record2, update_record, update_record2


    Data
    Table of Contents

    [func]
    insert_record2
    ( sequence db_name, sequence table_name, object blank_record, sequence data, sequence index )

    Category: Data

    insert_record2() is for inserting multiple records at a time. It is much faster to do bulk inserts this way than using insert_record() or multiple INSERT statements.

    ex:
    EUSQLRESULT ok, void
    -- suppose that MY_TABLE and YOUR_TABLE are in myDB.edb and yourDB.edb
    -- both contain 2 fields: ID and NAME
    -- and we'd like to copy all the records from MY_TABLE to YOUR_TABLE
    
    -- get all the records from MY_TABLE
    void = open_db("myDB.edb")
    ok = run_sql("SELECT * FROM MY_TABLE")
    
    -- now insert them into YOUR_TABLE
    void = open_db("yourDB.edb")
    ok = insert_record2( "myDB.edb", "YOUR_TABLE", blank_record("myDB.edb","YOUR_TABLE"),
         ok[2], { {1}, {2} })
    
    insert_record2() now always returs a sequence containing the status for each of the records to be inserted. Each status indicator will be a two-element sequence. The first element will be a sequence if insertion worked, or an atom if insertion failed. If it failed, the second element will be a full error description as returned by get_sql_err().

    See Also: delete_record, get_record, get_record2, get_record_mult_fields, insert_record, update_record, update_record2


    Data
    Table of Contents

    [func]
    update_record
    ( sequence db_name, sequence table_name, object key, sequence index, sequence data )

    Category: Data

    Update a record. 'key' specifies which record is to be updated. 'index' specifies the field indices to update, and data is a sequence of field values to update.

    See Also: delete_record, get_record, get_record2, get_record_mult_fields, insert_record, insert_record2, update_record2


    Data
    Table of Contents

    [func]
    update_record2
    ( sequence db_name, sequence table_name, object key, sequence index, sequence data, integer key_changing )

    Category: Data

    Update a record.

    This can be quicker than update_record(), but the calling procedure must be aware of whether any element of the primary key is changing.

    See Also: delete_record, get_record, get_record2, get_record_mult_fields, insert_record, insert_record2, update_record