Utilities
Table of Contents

Helper routines used by the library that may be useful


  • func blank_field( sequence record_struct )   
  • func blank_record( sequence db, sequence table )   
  • func flat_field_names( sequence db, sequence table )   
  • func flat_index( sequence struct, sequence index )   
  • func flat_record( sequence record, sequence struct )   
  • func get_field_datatype( sequence db, sequence table, sequence field )   
  • func get_next_autonumber( sequence db, sequence table, sequence field, sequence index )   
  • func get_record_struct( sequence db_name, sequence table_name )   
  • func get_sql_keyword( sequence word )   
  • func map_field( sequence field, sequence data, sequence index )   
  • func seq_fetch( object a, sequence b )   
  • func seq_remove( object a, sequence b )   
  • func seq_store(object a, object b, object c)   
  • func text_to_date_time( sequence text )   
  • func tokenize( sequence text, integer separator )   
  • func type_check( object o, integer datatype )   
  • func validate_field( sequence field, sequence struct )   
  • func validate_field2( sequence db_name, sequence table_name, sequence field_name )   

    Utilities
    Table of Contents

    [func]
    blank_field
    ( sequence record_struct )

    Category: Utilities

    Pass the result of get_record_struct() to blank_field, and it will return a sequence with the correct structure, but with all empty sequences.

    See Also: blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    blank_record
    ( sequence db, sequence table )

    Category: Utilities

    Returns an empty record for specified table where all fields are empty sequences. This wraps blank_field() and get_record_struct() into one call.

    See Also: blank_field, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    flat_field_names
    ( sequence db, sequence table )

    Returns: flattened version of column names

    Category: Utilities

    Names for fields with subfields are not returned.

    See Also: blank_field, blank_record, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    flat_index
    ( sequence struct, sequence index )

    Category: Utilities

    Returns a flattened version of indices for a record. Indices for fields with subfields are not returned. 'index' should be an empty sequence.

    See Also: blank_field, blank_record, flat_field_names, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    flat_record
    ( sequence record, sequence struct )

    Category: Utilities

    Returns the flattened version of the data of a record. Data for fields with subfields are not returned.

    See Also: blank_field, blank_record, flat_field_names, flat_index, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    get_field_datatype
    ( sequence db, sequence table, sequence field )

    Category: Utilities

    Returns the datatype for the field. field can be either tokenized or untokenized.

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    get_next_autonumber
    ( sequence db, sequence table, sequence field, sequence index )

    Category: Utilities

    Returns the value of the next AUTONUMBER that will be assigned for the specified field. You can either specify the name of the field in field, or the index of the field (as returned by validate_field()) in index.

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    get_record_struct
    ( sequence db_name, sequence table_name )

    Category: Utilities

    Returns the TABLEDEF definition of the structure of the tables records.

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    get_sql_keyword
    ( sequence word )

    Category: Utilities

    Returns the code for the specified keyword.

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    map_field
    ( sequence field, sequence data, sequence index )

    Category: Utilities

    This is used by EuSQL to put field values into a structured EuSQL record. For instance, if your table had the fields:

    And you wanted to insert data for John Smith, with phone number 555-1234, living at 123 Main St, USA:
      ok = map_field( {{ {}, {} }, {}, { {}, {}}},    -- the record structure without any data
                       { "John", "Smith", "555-1234", -- the data to be stored
                         "123 Main St", "USA" },
                       {{1,1},{1,2},{2},{3,1},{3,2}}) -- the respective field indices for each
                                                      -- field
    
      ok = { {"John", "Smith"},"555-1234",{"123 Main St","USA"}}
    

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    seq_fetch
    ( object a, sequence b )

    Category: Utilities

    return a[b...]

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    seq_remove
    ( object a, sequence b )

    Category: Utilities

    Removes element a[b[1]][...]

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_store, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    seq_store
    (object a, object b, object c)

    Category: Utilities

    Store a in b at subcript c

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, text_to_date_time, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    text_to_date_time
    ( sequence text )

    Category: Utilities

    Converts a date-time in text format (YYYY-MM-DD HH:MM:SS) to the native DATE_TIME format.

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, tokenize, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    tokenize
    ( sequence text, integer separator )

    Category: Utilities

    Tokenizes a sequence based on a separator. Used to tokenize a field to be passed to validate_field(). tokenize function by F Dowling (check the archives at www.rapideuphoria.com)

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, type_check, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    type_check
    ( object o, integer datatype )

    Category: Utilities

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, validate_field, validate_field2


    Utilities
    Table of Contents

    [func]
    validate_field
    ( sequence field, sequence struct )

    Category: Utilities

    Returns the index of the field if valid.
    ex:
      -- Assume a table "PERSON":
      --      NAME.FIRST
      --      NAME.LAST
      --      EMAIL
    
      field = tokenize( "NAME.FIRST", '.' )
      struct = get_record_struct( my_db, "PERSON" )
      field_index = validate_field( field, struct )
    
      --  field_index = {1,1}
    
    

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field2


    Utilities
    Table of Contents

    [func]
    validate_field2
    ( sequence db_name, sequence table_name, sequence field_name )

    Category: Utilities

    Returns the field index the field for field_name in table table_name in the open database db_name. This function calls get_record_struct(), tokenize() and validate_field() for you. If you need to call this multiple times, it will be faster to store a local copy of the results from get_record_struct() and tokenize() and pass them directly to validate_field().

    ex:
      -- Assume a table "PERSON":
      --      NAME.FIRST
      --      NAME.LAST
      --      EMAIL
    
      field_index = validate_field( my_db, "PERSON", "NAME.FIRST" )
    
      --  field_index = {1,1}
    
    

    See Also: blank_field, blank_record, flat_field_names, flat_index, flat_record, get_field_datatype, get_next_autonumber, get_record_struct, get_sql_keyword, map_field, seq_fetch, seq_remove, seq_store, text_to_date_time, tokenize, type_check, validate_field