Dates
[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
[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
[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
[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
[func]
insert_record ( sequence db_name, sequence table_name, object blank_record, sequence data, sequence index )
Category: Data
Inserts a record into specified table.
- db_name
- table_name
- blank_record tells insert_record() what the structure of the record is.
You can call blank_record() to generate the record yourself. This is recommended
if you will be calling insert_record() multiple times. If blank_record is an
atom, insert_record() will call blank_record() for you.
- data is a sequence of field values
- index is a sequence of field indices, or the equivalent subscript that would be
used if the record were a sequence.
If the structure of the table were:
- ID
- NAME.FIRST
- NAME.LAST
- EMAIL
Then the record as a sequence would be:
{ ID, { NAME.FIRST, NAME.LAST }, EMAIL }
So the corresponding indices would be:
Field | Index |
ID | {1} |
NAME | {2} |
NAME.FIRST | {2,1} |
NAME.LAST | {2,2} |
EMAIL | {3} |
See Also:
delete_record,
get_record,
get_record2,
get_record_mult_fields,
insert_record2,
update_record,
update_record2
[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.
- db_name
- table_name
- blank_record tells insert_record() what the structure of the record is.
You can call blank_record() to generate the record yourself. This is recommended
if you will be calling insert_record() multiple times. If blank_record is an
atom, insert_record() will call blank_record() for you.
- data is a sequence of field values, where each top level element of data
is a sequence of field values for each record that is to be inserted.
data = { { "Joe", 1, 6 },
{ "Bob", 4, 2 },
...etc...
}
- index is a sequence of field indices, or the equivalent subscript that would be
used if the record were a sequence.
If the structure of the table were:
- ID
- NAME.FIRST
- NAME.LAST
- EMAIL
Then the record as a sequence would be:
{ ID, { NAME.FIRST, NAME.LAST }, EMAIL }
So the corresponding indices would be:
Field | Index |
ID | {1} |
NAME | {2} |
NAME.FIRST | {2,1} |
NAME.LAST | {2,2} |
EMAIL | {3} |
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
[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
[func]
update_record2 ( sequence db_name, sequence table_name, object key, sequence index, sequence data, integer key_changing )
Category: Data
Update a record.
- key specifies which record is to be updated
- index specifies the field indices to update
- data is a sequence of field values to update
- key_changing should be 1 if the record key is to be changed, 0 otherwise
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