Difference between revisions of "DB Functions Library"

Line 1: Line 1:
 
A library of functions used to create, read, update, examine and delete database tables.
 
A library of functions used to create, read, update, examine and delete database tables.
  
<div style="column-count:2;-moz-column-count:2;-webkit-column-count:2">
 
 
__TOC__
 
__TOC__
</div>
 
  
 
:[[File:DB_Library_Top_Level.png|600px]]
 
:[[File:DB_Library_Top_Level.png|600px]]
  
You can download this library to here: [[media:DB Functions Library.ana|DB Functions Library.ana]]
+
You can download this library here: [[media:DB Functions Library.ana|DB Functions Library.ana]]
  
 
==Supported Database Platforms==
 
==Supported Database Platforms==
Line 54: Line 52:
  
  
 +
==Examples Module==
 +
To quickly try out this library with a live test database, you can download this example module here: [[media:DB_Library_Demo.ana|DB Library Demo.ana]].
  
 +
==Supporting Additional DB Platforms==
 +
Advanced users who want to add syntax to support an additional DB platform can do this through the '''DB Syntax Definitions''' module. Add your platform to the '''DB Platforms''' index, add your syntax to each of the provided syntax variables, switch the selected '''DB Platform''' at the top of the library and then test your syntax by making use of the debug parameter provided by each function.
  
  
Text:
 
 
:<code>Index K := ['A', 'B', 'C']</code>
 
:<code>Variable Xmean := [[Table]](K)(10, 11, 12)</code>
 
:<code>Variable X := [[Normal]](Xmean, 2)</code>
 
 
Text:
 
 
:<code>Variable Ysd := [[Table]](K)(2, 3, 4)</code>
 
:<code>Variable Y := [[Normal]](Xmean, Ysdeviation)</code>
 
 
:<code>[[Normal]](10, 2, over: K)</code>
 
 
Text:
 
 
:<code>[[Uniform]](0, 10, over: I, J, K)</code>
 
 
Text
 
 
Text
 
 
==Header==
 
  
 
'''Example:''' To generate a lognormal distribution with a 0.8 rank correlation with <code>Z</code>, use:
 
'''Example:''' To generate a lognormal distribution with a 0.8 rank correlation with <code>Z</code>, use:
  
 
'''''Note:''' If you have a non-default '''[[SampleWeighting]]''' of points, the weighted rank correlation might differ from «rc»''.
 
'''''Note:''' If you have a non-default '''[[SampleWeighting]]''' of points, the weighted rank correlation might differ from «rc»''.

Revision as of 16:20, 7 February 2024

A library of functions used to create, read, update, examine and delete database tables.

DB Library Top Level.png

You can download this library here: DB Functions Library.ana

Supported Database Platforms

  • SQL Server
  • MariaDB
  • PostgreSQL
  • MS Access

User Functions

The following functions are to view or modify the DB schema:

DB_Create_Table

Creates a new database table having column names of «field», data formats of «type», and optional null or non-null designation of «constraint».

DB_Delete_Table

Deletes an existing database table «tbl».

DB_Add_Column

Adds a new column «field» to an existing database table «tbl».

DB_Delete_Column

Deletes an existing column «field» from an existing database table «tbl».

DB_List_Tables

Lists all the table names from an existing database table referenced in the «connectStr».

DB_List_Columns

Lists all the column names in an existing database table «tbl».


These functions are to view or modify DB records:

DB_Add_Record

Adds a new record to database table «tbl». The field and value pairs of the new record are specified by the «field» and «value» parameters, respectively.

DB_Update_Record

Syntax to update the values in an existing record in database table «tbl». The field and updated value pairs are specified by the «updatedField» and «updatedValue» parameters, respectively. The existing record to be updated is found by searching for the field and value pairs specified by the «lookupField» and «lookupValue» parameters, respectively.

DB_Delete_Record

Deletes existing database records where column names «field» have entries of «value».

DB_Retrieve_Record

Retrieves columns «retrieveField» from an existing database table «tbl» for records where column names «lookupField» have entries of «lookupValue». Parameters «retrieveField», «lookupField» and «lookupValue» are optional. Omitting «retrieveField» will return all columns in the table. Omitting either «lookupField» or «lookupValue» will return all records in the table.


Examples Module

To quickly try out this library with a live test database, you can download this example module here: DB Library Demo.ana.

Supporting Additional DB Platforms

Advanced users who want to add syntax to support an additional DB platform can do this through the DB Syntax Definitions module. Add your platform to the DB Platforms index, add your syntax to each of the provided syntax variables, switch the selected DB Platform at the top of the library and then test your syntax by making use of the debug parameter provided by each function.


Example: To generate a lognormal distribution with a 0.8 rank correlation with Z, use:

Note: If you have a non-default SampleWeighting of points, the weighted rank correlation might differ from «rc».

Comments


You are not allowed to post comments.