Index  Up  <<  >>  


Importing in a page

You might often want to add a data record to a database as a result of an order or other operation. Use MiniVend's [import ...] tag.

[import table type*] RECORD [/import]
Named attributes:

 [import table=table_name
         file=filename*
         type=(TAB|PIPE|CSV|%%|LINE)*
         continue=(NOTES|UNIX|DITTO)*
         separator=c*]

Import one or more records into a database. The type is any of the valid MiniVend delimiter types, with the default being TAB. The table must already be a defined MiniVend database table; it cannot be created on the fly. (If you need that, it is time to use SQL.)

The import type selected need not match the type the database was specified; different delimiters may be used.

The type of LINE and continue setting of NOTES is particularly useful, for it allows you to name your fields and not have to remember the order in which they appear in the database. The following two imports are identical in effect:

    [import table=orders]
             code: [value mv_order_number]
    shipping_mode: [shipping-description]
           status: pending
    [/import]
  
    [import table=orders]
    shipping_mode: [shipping-description]
    status:        pending
    code:          [value mv_order_number]
    [/import]

The code or key must always be present, and is always named code.

If you do not use NOTES mode, you must import the fields in the same order as they appear in the ASCII source file.

The file option overrides the container text and imports directly from a named file based in the catalog directory. Careful, if you want to import from products.txt you must specify file="products/products.txt". If the NoAbsolute directive is set to Yes in minivend.cfg, only relative path names will be allowed.

The [import ....] TEXT [/import] region may contain multiple records. If using NOTES mode, you must use a separator, which by default is a form-feed character (^L). See Import Attributes above for more information.


Index  Up  <<  >>