Xbasic

SQL Helper Functions

Description

SQL connection helper functions.

Name
Description
SQL Events

SQL Event functions can be used when performing SQL operations, such Create, Update, and Delete operations and DatabaseSnapshots.

*like Function

SQL compatible like function.

*sql_where Function

If there is a backend table, specify a where clause to execute.

a5_ADO_ResolveConnectionString Function

Resolves a named ADO connection string to the actual connection string

a5_alphadao_export Function

Exports data from local .dbf tables to remote SQL databases using AlphaDAO. Use the AlphaDAO Export Operation builder to define the job to be executed by this command.

a5_alphadao_import Function

Runs an Import job that was defined by the AlphaDAO Import builder. Returns two properties 'HasError' (.t./.f.) and 'ErrorText'. The 'jobDefn' input array has status on each object in the following properties: .countRecordsImported, .hasError, .errorText, .userCancelled

a5_alphadao_search Function

Displays a Search form to search for records in a SQL Query. Returns a dbf table that contains all records matching the search (up to a max of 100 records) and the record numbers in the found set that the user selected.

a5_alphadaoexportgenie Function

Opens the AlphaDAO Export Genie builder

a5_alphadaoimportgenie Function

Opens the AlphaDAO Import Genie builder

a5_arguments_sqllist Function

Used to define a dynamic list of choices from a SQL data source when defining arguments. If MaxValues = 0 then all values are returned. 'Tablename' can optionally be a SQL SELECT statement.

A5_BatchPassiveLinkCreate Function

The A5_BatchPassiveLinkCreate() function creates multiple passive-link tables. If Flag_Import is .T. then the function may import the tables as standard tables, not passive-link tables.

a5_changealias_insql Function

Takes a SQL statement and changes a table alias from one value to another

a5_complete_import_task Function

Called by the ODBC Import Genie when an import is complete and needs to be added to the current database.

a5_connectionpropstostring Function

Takes a set of A5DataObjects connection properties and returns a connection string

A5_CONNECTIONSTRING Function

The A5_CONNECTIONSTRING() function allows you to create or edit an ADO connection string. The function displays the standard Windows Data Link Properties dialog box.

a5_connstrings_list Function

List named connection strings. Mode is AlphaDAO or ADO. If dictionary is blank, lists connection strings in current database library.

a5_convert_delete_to_sql_delete Function

Convert an Delete Operation to a SQL DELETE statement. Returns .failed (.t. if could not convert) and .sql (the DELETE statement)

a5_convert_deletedups_to_sql Function

Convert an Delete Duplicates Operation to a SQL DELTE statement. Returns .failed (.t. if could not convert) and .sql (the Update statement)

a5_convert_update_to_sql_update Function

Convert an Update Operation to a SQL UPDATE statement. Returns .failed (.t. if could not convert) and .sql (the Update statement)

A5_CreateLayoutFromDataSource Function

The A5_CreateLayoutFromDataSource() function creates a new layout based on a DataSource definition. 'ds' defines the DataSource which can either be 'named' or 'adhoc'

A5_CreatePassiveLinkTable Function

The A5_CreatePassiveLinkTable() function displays the Specify DataSource dialog. With this dialog you specify a SQL SELECT query that retrieves data from a SQL database.

a5_createsql_layout Function

Starts the process of creating a new layout based on a SQL data source. Prompts for the name/definition of the DataSource.

a5_createtable_sql_import Function

Displays a dialog box to import a single table from a SQL Data source

a5_csweb_syntaxnamefromado Function

Convert the ADO syntax name (SQL Server) to the CS syntax name (SQLServer)

a5_databaseexplorer Function

Opens the SQL Database Explorer. Modes are: "SavedSettings", "Empty", "NamedConnections", "Load". If you use "Load" specify "definition" (a crlf string of form connectionName|connectionstring)

a5_defineconnectionstring Function

Define a connection string to an ADO or AlphaDAO database. Let's user define an explicit string or a named connection.

A5_ExcelConnString Function

The A5_ExcelConnString() function returns an ADO connection string for a named Excel file.

a5_exportconnectionstrings Function

Export saved connection strings to a text file.

a5_getalphasqlfunction Function

Allows the user to select an AlphaSQL function. Can return the 'Name', 'Prototype', 'Description', or 'Prompt'

a5_getnamedconnectionstring Function

Returns the connection string for a named connection string

a5_getnamedsqldatasource Function

Returns properties of a saved DataSource. If DataSource not found, 'ConnectionString' property is set to 'Error"

a5_getprimarykeysfromdaosearchresult Function

Used in conjunction with a5_AlphaDAOSearch() to populate an SQL::Arguments objects with the primary key values of the selected record.

a5_getreportsqlfilter Function

Used in report writer to extract the SQL filter for a report that is based on a SQL Data source. The sql filter is passed in as options.filter in the optional 'Options' parameter.

a5_getreportsqlorder Function

Used in report writer to extract the SQL order for a report that is based on a SQL Data source. The sql filter is passed in as options.filter in the optional 'Options' parameter.

a5_getsavedadoconn_string Function

Get the ADO connection strings for a given saved connection name

a5_importconnectionstrings Function

Imports connection strings from a text file. Format of file is Type||Name||ConnectionString, where Type is 'ADO' or 'AlphaDAO'.

A5_ImportTablesDialog Function

The A5_ImportTablesDialog() function displays the Import Tables from Remote Database dialog, which allow you to import tables from remote databases or other data sources for which ODBC drivers are available.

a5_invertsqlorder Function

Inverts the OrderBy clause

a5_list_tables_with_types Function

Gets list of objects with their types in a SQL database. See also a5_list_tables()

a5_lookupsavedconnectionstring Function

Returns the Connection String corresponding to a saved Connection String name

A5_MDBConString Function

The A5_MDBConString() function returns the ADO connection string used to access a specific Microsoft Access database.

a5_mergeDataIntoTemplate Function

Merge data into a template.

a5_mergesqlarguments Function

Merges arguments in two sql::arguments object into a single object

a5_namedconnectioncreate Function

Create a named connection string. Type 'AlphaDAO'

a5_odbc_connection Function

Displays the Windows ODBC admin dialog

a5_odbc_import_genie Function

Opens the ODBC Import Genie

a5_paradoxconnstring Function

Returns a connection string for a Paradox database given the path to the database

A5_PassiveLinkTableDefine Function

The A5_PassiveLinkTableDefine() function defines a passive link table for a SQL data source. For syntax help specify "Help" as the first argument.

a5_preview_datasource Function

Preview the records in a SQL DataSource

A5_RefreshPassiveLinkTable Function

The A5_RefreshPassiveLinkTable() function deletes the data in a passive-linked table, then retrieves its records from the specified SQL data source.

A5_RefreshPassiveLinkTableDialog Function

The A5_RefreshPassiveLinkTableDialog() function displays a dialog that allows you to select whether to refresh the currently selected passive-link table or selected passive-link tables.

a5_sql_addcolumnstoselect Function

Add columns to a sql select statement.

a5_sql_addfilterorder Function

Adds a filter to the WHERE clause of an SQL statement, and sets the ORDER BY clause

a5_sql_arguments_dump Function

Dumps data in an sql::arguments object to a string. Can use a5_sql_arguments_load() to load arguments from this string.

a5_sql_arguments_load Function

Load sql::arguments from a string created by a5_sql_arguments_dump().

A5_SQL_BatchImportTables Function

The A5_SQL_BatchImportTables() function is a wrapper for A5_BatchPassiveLinkCreate()that imports standard Alpha Anywhere .DBF tables from a back-end database.

a5_sql_builder_simple Function

Displays a dialog allowing a user to create a SQL SELECT by checking a list of fields. User can switch to the full SQL Query Builder genie.

a5_sql_cache_datafilename Function

Returns the name of the cached data file for a SQL Datasource, based on the Datasource's GUID. Optionally returns .exists and .timestamp properties.

a5_sql_commandwindow Function

Opens the SQL command window

a5_sql_droptables Function

Displays a dialog allowing a user to select multiple tables from a database to be dropped.

a5_sql_extractorder Function

Extracts the ORDER BY clause from a SQL SELECT statement.

a5_sql_generate_select2 Function

Generate a syntax-specific Select statement. Wraps A5_SQLGenerate_Select() and adds the columns, filter, and order

A5_SQL_ImportDataSource Function

The A5_SQL_ImportDataSource() function imports the data specified by a Data Source name to an Alpha Anywhere table.

a5_sql_parsewhereclause Function

Populate an array from the WHERE -clause of a parsed SQL Query.

a5_sql_parsewhereclause_datatypes Function

Called by SQL Query Genie. After A5_SQL_ParseWhereClause() has created array, call this to get data types for entries in the array.

a5_sql_query_genie Function

SQL Query Genie

A5_SQL_QuerySaveAs Function

Saves a SQL query as a table, passivelink table etc. Used in the SQL Database Explorer

a5_sql_record_content_get Function

Given a table handle, do a SQL_records_get on the table

a5_sql_record_xbase_content_get Function

Given a table handle, do a SQL_records_get on the table

a5_sql_removeorder Function

Removes the ORDER BY clause from a SQL SELECT statement.

a5_sql_table_selector Function

Select a table/view from a SQL database

a5_sqlconnectionstring_unhidepassword Function

Shows an obfuscated password in a sql connection string in plain text.

a5_sqlexpressionbuilder Function

SQL Expression builder.

a5_sqlimport_execute Function

Takes a import definition and executes it

A5_SQLResultSetPreview Function

The A5_SQLResultSetPreview() function displays up to 100 rows of data stored in a SQL::ResultSet object.

a5_sqlToJSONExpandingMenu Function

Generates JSON to populate an Expanding Menu control from a SQL query.

a5cs_decomposeaggregateexpression Function

Takes an Aggregate SQL Expression and parses out the pieces.

a5cs_generatenativefilter Function

Takes a Portable AlphaSQL Filter expression and converts it to a native SQL expression

a5cs_generatenativeorder Function

Takes a Portable AlphaSQL Order expression and converts it to a native SQL expression

a5cs_getfunctionsinsqlexpression Function

Returns a list of functions in a Portable SQL Value Expression

a5cs_getprimarykeycolumns Function

Gets the primary key columns as a CR-LF delimited list for a SQL table.

a5cs_sql_add_filter_order Function

Adds a filter and order to a portable SQL Select statement.

a5cs_validateexpression Function

Validates a portable SQL expression. Table_name must not be qualified. E.g.: 'order details' not '"order details"'

a5gridhelper_dumpargumentstohtml Function

Turns sql::arguments into an HTML table,

a5Helper_findRecordInSQLTable Function

Returns records from a SQL table that contain any fields that match the search criteria.

a5SQLConnectionOpen Function

Opens a connection to a database. This method supports using dynamic connection syntax.

a5wcb_exportstaticdatatosql Function

Exports static data (in crlf delimited list or JSON) to a SQL table. SQL table is created from the 'fields' definition.

argval Function

Returns a value from a sql::arguments object by name, or item id. Is a shortcut for this pattern: args[args.argumentNumber(ArgumentName)].data

cn_open Function

Opens a connection to a data source.

combine_sql_arguments Function

Add arguments from args2 to args1. If flagPreserveValuesInArgs1 is .t. then a duplicate argument in args2 will not overwrite the existing value in args1.

create_table_sql Function

Create a table in a SQL database.

DataTransformExpression Example

The SQL::DataTypeInfo.DataTransformExpression property is an Xbasic expression to be evaluated when retrieving data values from a SQL::ResultSet or a SQL::Row. The data is transformed each time the column is referenced using the SQL::ResultSet::Data() function.

Portability Functions

SQL syntaxes vary widely between vendors. Function implementations vary even more so. The set of functions below are deemed "Portability" functions. If these functions are used in a SQL statement parsed by one of the Xbasic SQL objects, the appropriate target function for the selected syntax handler is generated automatically by the object when the query is executed. Any argument re-ordering is done by the syntax handler.

replace_arguments_in_string Function

Takes a string that contains SQL::Arguments in it and replaces the arguments with actual values. Used internally by Alpha Anywhere.

replace_placeholders_with_argument_values Function

Replaces placeholders (enclosed in curly parens, e.g. {arg1}, {arg2}) in a string with values in a SQL::Arguments object.

showresultset Function

Quick preview of records in an AlphaDAO resultset. (Shows a max of 100 records).

sql_argumentsdialog Function

Edit the primary key columns for a SQL table definition.

sql_avg Function

Returns the avg of 'expression' for a SQL table.

sql_cacheapplyupdates Function

Send cache changes to the backend SQL database.

sql_cacheevents Function

Define and assign the SQL cache event script.

sql_cachefetchpage Function

Fetch a block of data rows into the cache from the SQL database result set.

sql_cachefetchpageeventscript Function

Get the script for Events related to the ResultSet::FetchPage function.

sql_cacheopen Function

Open a local cache for a table linked to a SQL databases.

sql_cacherefresh Function

Refresh the whole cache.

sql_cacherefreshinsertedrow Function

Refresh a single row in the cache.

sql_cacherefreshrow Function

Refresh a single row in the cache.

sql_childrelationsadded Function

Initialization of Optimize set navigation by doing prefresh from the parent level.

sql_childrelationsclear Function

Clear all the child tables we manage (called when the parent is cleared due to a requery)

sql_childrelationspopulate Function

Populate child tables of set

SQL_ConnectionStringDialog Function

The SQL_ConnectionStringDialog() function displays the Create SQL Connection String dialog, which helps you define a connection string for a SQL database.

SQL_ConnectString Function

The SQL_ConnectString() method invokes an API specific dialog to create a connection string.

sql_count Function

Returns the count of 'expression' for a SQL table.

SQL_DatabaseExportDialog Function

Obsolete function for exporting .dbf table to sql server database

SQL_DATE Function

Takes a date or time value and returns a character date or date-time string using the format for Alpha Portable SQL - {yyyy-mm-dd}

sql_delete Function

Deletes a record in a SQL table.

Sql_get_Values Function

Returns a CRLF delimited string with data from a table in a remote database using AlphaDAO. Connection can be explicit, or a named connection (e.g. ::name::myconnection).

sql_import Function

Imports CSV or JSON data into an existing SQL table.

sql_insert Function

Inserts a record in a SQL table.

SQL_InstallOracleLiteFunctions Function

Install support for numeric portable functions in OracleLite

sql_linkcreate Function

Add a link to a SQL table to the current database.

sql_listoptionsdialog Function

Edit the primary key columns for a SQL table definition.

SQL_Lookup Function

Does a lookup into a table in a remote database using AlphaDAO. Returns a field value or expression from the remote table. Connection can be explicit, or a named connection (e.g. ::name::myconnection).

SQL_lookup_multi Function

Does a lookup into a SQL table to retrieve multiple values from a record.

sql_max Function

Returns the max of 'expression' for a SQL table.

sql_min Function

Returns the min of 'expression' for a SQL table.

sql_namedinstanceget Function

Start using a connection given a local file name...

sql_nameinstancegetsimple Function

From just a table name, get the context information

sql_primarykeydialog Function

Edit the primary key columns for a SQL table definition.

sql_query Function

Performs a SQL select query and returns the results as JSON data.

SQL_QUERY_BUILDER Function

Displays the SQL Genie. For use in Desktop Applications.

SQL_QueryImport Function

Import a SQL query into a DBF table. Optionally adds the table to the current database.

sql_queryrenamewhereclausearrayoperators2 Function

Called by Query Genie to give friendly names to the logical operators

sql_quote Function

Formats a value for use in a Portable SQL expression.

SQL_Records_Get Function

Returns a CRLF delimited string with data from a table or query in a remote database using AlphaDAO. Connection can be explicit, or a named connection (e.g. ::name::myconnection).

SQL_ResultSet_Preview Function

Displays an Xdialog showing the data in an SQL Result set

sql_safeexecute Function

Version of SQL execute that assumes portable syntax string literals are UTF8 encoded

sql_sum Function

Returns the sum of 'expression' for a SQL table.

SQL_TableExport Function

Export a local table to a backend SQL database.

SQL_TableExportDialog Function

Display a dialog to export a local table to a SQL database.

SQL_TableImport Function

Import a SQL table into a DBF table. Optionally adds the table to the current database.

SQL_TableImportDialog Function

Display a dialog to import a SQL database to a local table.

SQL_TableInfoOfDBF Function

Create a SQL table definition from a DBF file, or an open table pointer.

sql_tableinfotodbf Function

Create an empty database from a SQL::TableInfo.

SQL_TableInfoToOpenTable Function

The SQL_TableInfoToOpenTable() functions creates a new Alpha Anywhere .DBF table based on the specifications in a SQL::TableInfo object.

sql_tableinfotostring Function

Convert a SQL::TableInfo structure to a string.

sql_time Function

Converts a shor-time value in a format for SQL.

sql_update Function

Updates a record in a SQL table.

sql_upsert Function

Updates or Inserts a record in a SQL table.

SYS_REMOVE Function

The SYS_REMOVE() function removes a file using the file manager shell, which by default moves the file to the recycle bin. If you desire to remove permanently, use file.remove().