|
of_assemble
|
|
Full name
|
pfc_n_cst_sql.of_assemble
|
Access
|
public
|
Extend of
|
string
|
Return value
|
string
|
Prototype
|
public function string of_assemble(n_cst_sqlattrib[])
|
Name
|
Datatype
|
li_Cnt
|
Integer
|
li_NumStats
|
Integer
|
ls_SQL
|
String
|
public function string of_assemble (n_cst_sqlattrib astr_sql[]);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_Assemble
//
// Access: public
//
// Arguments:
// astr_sql[] Array of sql attributes, each element containing a
// SQL statement that will be joined with an UNION.
//
// Returns: String
// The function returns an empty string if an error
// was encountered.
//
// Description: Build a SQL statement from its component parts.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_NumStats, li_Cnt
String ls_SQL
li_NumStats = UpperBound(astr_sql[])
For li_Cnt = 1 to li_NumStats
// Check for valid data
If Trim(astr_sql[li_Cnt].s_Verb) = "" Or &
Trim(astr_sql[li_Cnt].s_Tables) = "" Then
Return ""
End if
// If there is more than one statement in the array, they are SELECTs that
// should be joined by a UNION
If li_Cnt > 1 Then
ls_SQL = ls_SQL + " UNION "
End if
ls_SQL = ls_SQL + astr_sql[li_Cnt].s_Verb
If astr_sql[li_Cnt].s_Verb = "SELECT" Then
If Trim(astr_sql[li_Cnt].s_Columns) = "" Then
Return ""
Else
ls_SQL = ls_SQL + " " + astr_sql[li_Cnt].s_Columns + &
" FROM " + astr_sql[li_Cnt].s_Tables
End if
Else
ls_SQL = ls_SQL + " " + astr_sql[li_Cnt].s_Tables
If astr_sql[li_Cnt].s_Verb = "UPDATE" Then
ls_SQL = ls_SQL + " SET " + astr_sql[li_Cnt].s_Columns
Elseif Trim(astr_sql[li_Cnt].s_Columns) <> "" Then
ls_SQL = ls_SQL + " " + astr_sql[li_Cnt].s_Columns
End if
End if
If Trim(astr_sql[li_Cnt].s_Values) <> "" Then
ls_SQL = ls_SQL + " VALUES " + astr_sql[li_Cnt].s_Values
End if
If Trim(astr_sql[li_Cnt].s_Where) <> "" Then
ls_SQL = ls_SQL + " WHERE " + astr_sql[li_Cnt].s_Where
End if
If Trim(astr_sql[li_Cnt].s_Group) <> "" Then
ls_SQL = ls_SQL + " GROUP BY " + astr_sql[li_Cnt].s_Group
End if
If Trim(astr_sql[li_Cnt].s_Having) <> "" Then
ls_SQL = ls_SQL + " HAVING " + astr_sql[li_Cnt].s_Having
End if
If Trim(astr_sql[li_Cnt].s_Order) <> "" Then
ls_SQL = ls_SQL + " ORDER BY " + astr_sql[li_Cnt].s_Order
End if
Next
Return ls_SQL
end function
Name
|
Owner
|
systemfunctions.trim |
systemfunctions
|
systemfunctions.upperbound |
systemfunctions
|