Difference between revisions of "SQLCOLUMNS()"

From Lianjapedia
Jump to: navigation, search
Line 13: Line 13:
 
The SQLCOLUMNS() function operates on the data source specified by <nStatementHandle>.
 
The SQLCOLUMNS() function operates on the data source specified by <nStatementHandle>.
  
{| class="wikitable"
+
{| class="wikitable" width=100%
 
!width=30%|Keywords||width=70%|Description
 
!width=30%|Keywords||width=70%|Description
 
|-
 
|-
Line 20: Line 20:
 
|cTableName||The table from which the column information should be returned
 
|cTableName||The table from which the column information should be returned
 
|-
 
|-
|valign="top"|"FOXPRO" | "NATIVE"||Used to specify the format for the column information.  "FOXPRO" is the default.  "NATIVE" uses the data source format.  The cursor column information is shown in the table below.  "NATIVE" many include additional columns.
+
|valign="top"|"FOXPRO" | "NATIVE"||Used to specify the format type for the column information.  "NATIVE" is ignored, format type is always "FOXPRO".
 
|-
 
|-
 
|cCursorName||The name of the cursor to use.  If cCursorName is not specified, the default name SQLRESULT is used.   
 
|cCursorName||The name of the cursor to use.  If cCursorName is not specified, the default name SQLRESULT is used.   
Line 26: Line 26:
 
|}
 
|}
  
"FOXPRO" Cursor Columns:
+
Cursor Columns:
  
{| class="wikitable"
+
{| class="wikitable" width=100%
 
!width=30%|Column||width=70%|Description
 
!width=30%|Column||width=70%|Description
 
|-
 
|-
Line 41: Line 41:
 
|}
 
|}
  
"NATIVE" Cursor Columns:
 
 
{| class="wikitable"
 
!width=30%|Column||width=70%|Description
 
|-
 
|Table_qualifier||Table qualifier id
 
|-
 
|Table_owner||Table owner id
 
|-
 
|Table_name||Table name
 
|-
 
|Table_type||Table type
 
|-
 
|Column_name||Column identifier
 
|-
 
|Data_type||Column data type
 
|-
 
|Type_name||Column data type name
 
|-
 
|Precision||Column precision
 
|-
 
|Length||Data transfer size
 
|-
 
|Scale||Column scale
 
|-
 
|Radix||Base for Numeric type
 
|-
 
|Nullable||Null value support
 
|-
 
|Remarks||Table description
 
|-
 
|}
 
  
 
====Return values:====
 
====Return values:====
  
{| class="wikitable"
+
{| class="wikitable" width=100%
 
!width=30%|Return Value||width=70%|Description
 
!width=30%|Return Value||width=70%|Description
 
|-
 
|-
|.T.||Format is "NATIVE" and cTableName does not exist
+
|.F.||cTableName does not exist
|-
+
|.F.||Format is "FOXPRO" and cTableName does not exist
+
 
|-
 
|-
 
|1||The table was created successfully
 
|1||The table was created successfully
Line 95: Line 61:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
nStatHand=SQLSTRINGCONNECT("mysql@linux1:user1/pass1-database1.tcpip",.T.)
+
nStatHand = sqlconnect("awhr")
 
if nStatHand < 1
 
if nStatHand < 1
  dialog box [Could not connect]
+
messagebox("Cannot make connection", 16, "SQL Connect Error")
 
else
 
else
  nColEnd = SQLCOLUMNS(nStatHand, "accounts", "NATIVE", "tabinfo")
+
messagebox("Connection made", 48, "SQL Connect Message")
  if nColEnd = 1
+
nColEnd = sqlcolumns(nStatHand, "sales.currency")
    select tabinfo
+
if nColEnd = 1
    browse
+
select tabinfo
  else
+
list
    dialog box [Table of Table Information could not be created]
+
else
  endif
+
messagebox("Table of Table Information could not be created")
 +
endif
 +
sqldisconnect(nStatHand)
 
endif
 
endif
 
</code>
 
</code>

Revision as of 10:10, 7 January 2013

Purpose

Store column information to a cursor

Syntax

SQLCOLUMNS(<nStatementHandle>, <cTableName> [, "FOXPRO" | "NATIVE"] [, <cCursorName>])

See Also

SQLCANCEL(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLERROR(), SQLEXEC(), SQLGETPROP(), SQLMORERESULTS(), SQLPREPARE(), SQLROLLBACK(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES()

Description

The SQLCOLUMNS() function is used to store column information for a specified data source table to a cursor.

The SQLCOLUMNS() function operates on the data source specified by <nStatementHandle>.

Keywords Description
nStatementHandle The workarea in which the gateway data source is open
cTableName The table from which the column information should be returned
"FOXPRO" | "NATIVE" Used to specify the format type for the column information. "NATIVE" is ignored, format type is always "FOXPRO".
cCursorName The name of the cursor to use. If cCursorName is not specified, the default name SQLRESULT is used.

Cursor Columns:

Column Description
Field_name Column name
Field_type Column data type
Field_len Column length
Field_dec Number of decimal places


Return values:

Return Value Description
.F. cTableName does not exist
1 The table was created successfully
0 SQLCOLUMNS() still executing
–1 Connection error
–2 Environment error

Example

nStatHand = sqlconnect("awhr")
if nStatHand < 1
	messagebox("Cannot make connection", 16, "SQL Connect Error")
else
	messagebox("Connection made", 48, "SQL Connect Message")
	nColEnd = sqlcolumns(nStatHand, "sales.currency")
	if nColEnd = 1
		select tabinfo
		list
	else
		messagebox("Table of Table Information could not be created")
	endif
	sqldisconnect(nStatHand)
endif