table.to_sql_expression Function

Syntax

c SQLExpression = To_SQL_Expression( expr as c )

Arguments

expr

Character

Description

If convertable to a SQL level expression, return than expression.

Discussion

Takes an Xbasic syntax expression and converts it to a SQL expression. If the expression cannot be converted, returns a null string.

Example

Field names from the current active-link table that are referenced in the XbaseExpression are converted to the corresponding SQL expression. Assume that you have an active-link table. The active link table might have (say) two fields: fname and lname. The 'fname' field in the active-link table maps to a field called 'firstname' in the remote table and the 'lname' field map to a field called 'lastname' in the remote table.

t = table.open("customers")
?t.to_sql_expression("fname+lname")
= "Firstname+Lastname"

In this next example, assume that the active-link table's SQL Select statement is:

SELECT firstname, lastname, concatenate(address, ' ', city, '  ', state,' ', zip) as address FROM customers.

The active-link table will have three fields: firstname, lastname and address

t = table.open("customers")
?t.to_sql_expression("address = '123 main st boston ma 02139'")
= concatenate(address, ' ', city, '  ', state,' ', zip)  = '123 main st boston ma 02130'

If the XbaseExpression cannot be converted to a SQL expression, a blank string is returned. Reasons why the conversion might fail include a reference to a function that has no SQL equivalent.