GetSQLPreview  GetStateStatus

Chapter 9: Methods for the DataWindow Control

GetSQLSelect

Description

Reports the SQL SELECT statement associated with a DataWindow if its data source is one that accesses a SQL database (such as SQL Select, Quick Select, or Query).

Syntax

string dwcontrol.GetSQLSelect ( )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow.

Returns

Returns the current SQL SELECT statement for dwcontrol. GetSQLSelect returns the empty string ("") if it cannot return the statement. If dwcontrol is NULL, the method returns NULL.

Usage

When you want to change the SQL SELECT statement for a DataWindow or DataStore during execution, you can use GetSQLSelect to save the current SELECT statement before making the change.

When you define a DataWindow, PocketBuilder stores a PocketBuilder SELECT statement (PBSELECT) with the DataWindow. If a database is connected and SetTransObject has been called for the DataWindow, then GetSQLSelect returns the SQL SELECT statement. Otherwise, GetSQLSelect returns the PBSELECT statement.

You can also use Describe to obtain the SQL SELECT statement. The DataWindow object’s Table.Select property holds the information.

Examples

Example 1

The code saves the SELECT statement for dw_emp in the variable old_select. Then it adds a WHERE clause. The example assumes the old SELECT statement did not have one already:

string old_select, new_select, where_clause

// Get old SELECT statement

old_select = dw_emp.GetSQLSelect()


// Specify new WHERE clause

where_clause = "WHERE ..."

// Add the new where clause to old_select

new_select = old_select + where_clause


// Set the SELECT statement for the DW

dw_emp.SetSQLSelect(new_select)

See also





Copyright © 2004. Sybase Inc. All rights reserved. GetStateStatus

View this book as PDF