12.4.37    SQLDIRECT

Description:   Execute SQL command line.  Executes an SQL command that is one line long.

Syntax:

Tcl:               SQLDIRECT "sql command line"

JScript:          SQLDIRECT("sql command line");

VB Script:       SQLDIRECT "sql command line"

                                     

Arguments:    one line SQL command

Returns:        none

See Also:       SQLPREPARE, SQLEXECUTE

 

Examples:     

 

# Tcl -  MYDATA is an ODBC DSN attached to an Access

# Database or SQL Server DB

SQLDIRECT "CONNECT SESSION 1 TO MYDATA"

SQLDIRECT "USE SESSION 1"

 

# Tcl Insert data into table

#For ODBC Databases that do not support level 2 commands (e.g. Access)

# break into two lines using SQL prepare

SQLPREPARE "INSERT INTO Table1 VALUES ('[GETVAL %TTMDATE]',"

SQLPREPARE "'[GETVAL %TTMTIME]', [GETVAL AMPLITUDE],"

SQLPREPARE " [GETVAL TIMER])"

SQLEXECUTE

 

# Tcl - Declare a pointer to newest data just entered

# break command into multiple lines

SQLPREPARE "DECLARE C1 CURSOR FOR SELECT '[GETVAL %TTMDATE]',"

SQLPREPARE "'[GETVAL %TTMTIME]', [GETVAL AMPLITUDE], "

SQLPREPARE "[GETVAL TIMER] FROM Table1"

SQLEXECUTE

SQLPREPARE "OPEN C1"

SQLEXECUTE

SQLDIRECT "FETCH NEXT C1 INTO text1, text2, text3, text4"

SQLDIRECT "CLOSE C1"

SQLDIRECT "DISCONNECT SESSION 1"

 

This command is used to execute an SQL command that is one line long and forms a complete SQL syntax.  SQLDIRECT has no line limit, although the editor effectively limits an SQLDIRECT command to 1000 characters.   For longer than 1000 characters in a single SQL command line, use SQLPREPARE and SQLEXECUTE. 

SQLDIRECT will interact with the related keymacro commands <SQLPREPARE and <SQLEXECUTE> allowing a script to initialize or open an SQL session and user keymacro commands to enter data.

SQLDIRECT is recommended for the following SQL commands:

                   CONNECT

                   USE

                   OPEN

                   CLOSE

                   DISCONNECT

WebAccess supports both Level 1 and Level 2 SQL statement.  SQL is an acronym for Structured Query Language.  Please refer to an SQL manual for complete syntax of the SQL language. These commands are used to interact with a Database file like Access or SQL Server through an ODBC DSN.

You can only FETCH and INSERT using IO Tags, Internal Tags and Local Screen Tags.  FETCH and INSERT do not support local Tcl variables.