Copyright: Copyright (c) 1990-1998 ESRI, Inc.


Error message displayed when a topic is not found
Topic not available

Sorry, the topic you chose to display is not available in ArcView's help system.

To see ArcView's Help Contents, Index, and Find tabs, please click the Help Topics button.


Connection

 A Connection object controls network communication between ArcView and a remote database. This is an abstract class that defines the general properties and methods of working with database connections.

You can access many databases at the same time during an ArcView session. You need to create a separate Connection object for each database you want to access. Before using the Connection object, you need to verify that the network connection was successfully established. The HasError request will return TRUE if there were problems connecting.

All objects created with the Database Access extension have an associated Connection object. If the connection associated with an object is closed, all requests sent to these objects will fail. The operations you can perform on an object are limited by the privileges assigned to the user who made the connection. For example, you can have two different connections to the same database where you login to each connection as a different user. You might be able to edit the source data with one connection, but not the other.

You can have one transaction for each Connection object. However, it is possible to have more than one connection to the same database with the same UserName and Password combination; therefore, you can create a situation where you can have many transactions on the same database at the same time.

Attributes

ConnectionString.The ConnectionString is a string object containing the information ArcView needs to locate the database you want to use on the network.

DataReferenceName.The DataReferenceName is an extra parameter required by some relational databases to access your data.

UserName.The login name used to establish a connection to a remote database.

Password.The login password used to establish a connection to a remote database.

Connected.A Connection is connected if ArcView has established network communication with the remote database. You can disconnect an active connection with the Close request, and activate it again later with the Open request.

SavePassword.By default, the passwords used to connect ArcView to remote databases aren't saved with the project file; therefore, you have to login to the database when you open a saved ArcView project. Users can change this behaviour using the SavePassword request.

HasErr.If an error has ocurred in the Connection, HasErr is TRUE, otherwise it is FALSE.

Inherits From

Obj

Inherited By

SDEConnection

Enumerations

TablePrivilegeEnum

Required Extension

     Database Access

Class Requests

Making a Connection

GetAllConnections  :  List

Instance Requests

Getting and Setting Attributes

GetAllTableNames ( aTablePrivilegeEnum, OwnerName ) :  List

GetConnectionString  :  String

GetDatabaseName  :  String

GetErrorCode  :  Number

GetErrorMsg  :  String

GetUserName  :  String

HasError  :  Boolean

IsConnected  :  Boolean

SavePassword ( isSaved )

Manipulating Transactions

BeginTrans  :  Boolean

CommitTrans  :  Boolean

Rollback  :  Boolean

Manipulating a Connection

Close

Open  :  Boolean

General Object Management

= anotherConnection :  Boolean

__________

See also

QueryDef
RecordSet
SColumn
DBTheme
DBTable


GetAllConnections (Connection)
GetAllConnections

Return a list of all the Connection objects that are open.

Syntax

Connection.GetAllConnections

Returns

List


GetAllTableNames (Connection)
GetAllTableNames

 This request returns a list of names for all the tables, owned by the user OwnerName, that you can access using aConnection, and for which you have the privileges defined by aTablePrivilegeEnum. Returns an empty list if you don't have the defined privileges for any tables owned by OwnerName. You can query all the tables owned by all the users by providing the OwnerName "*".

Each user may have different privileges for each table in the database; one user may be able to select data only from some tables, while another user can select data from all tables and edit some of them.

Syntax

aConnection.GetAllTableNames (aTablePrivilegeEnum, OwnerName)

Returns

List


GetConnectionString (Connection)
GetConnectionString

Returns the string ArcView used to locate your remote database across the network.

Syntax

aConnection.GetConnectionString

Returns

String


GetDatabaseName (Connection)
GetDatabaseName

Returns the name of the database whose tables you can access with aConnection for relational databases like Sybase and SQL Server. The database name is a null string if the relational database doesn't organize associated tables into databases, like Oracle.

Syntax

aConnection.GetDatabaseName

Returns

String


GetErrorCode (Connection)
GetErrorCode

Returns an error code generated by the connection identifying why the last request failed.

Most requests return a value indicating whether or not they were successful. You should always check this value first, and IF the request failed, THEN use the GetErrorCode request to find out why. aConnection only generates an error code if a request fails; aConnection does nothing if a request is successful. If a request succeeds but you use the GetErrorCode request anyway, the the resulting error is meaningless; it is an old error generated by the last failed request.

Syntax

aConnection.GetErrorCode

Returns

Number


GetErrorMsg (Connection)
GetErrorMsg

Returns the error message associated with the error code generated by aConnection when the previous request failed. The error message should briefly explain what the error code means.

Syntax

aConnection.GetErrorMsg

Returns

String


GetUserName (Connection)
GetUserName

Returns the UserName used to establish aConnection. All operations performed with aConnection are limited by this user's privileges in the database.

Syntax

aConnection.GetUserName

Returns

String


HasError (Connection)
HasError

Returns TRUE if an error occurred while establishing the connection between ArcView and the database represented by aConnection; otherwise returns FALSE.

If HasError returns TRUE, all subsequent requests requiring aConnection will fail. You can find out what's wrong by using the GetErrorCode request to retrieve the error generated on the server when the connection attempt failed.

Syntax

aConnection.HasError

Returns

Boolean


IsConnected (Connection)
IsConnected
Example

Gets the current status of the connection. Returns TRUE if the Connection is open; otherwise returns FALSE.

Syntax

aConnection.IsConnected

Returns

Boolean


SavePassword (Connection)
SavePassword

Sets whether or not the password for aConnection will be saved in the project file. By default, isSaved is FALSE, and passwords are NOT saved, and you login to aConnection every time you open the project. If isSaved is TRUE, the password for aConnection will be encrypted, then saved; ArcView automatically attempts to login to aConnection for you when you open the project.

Syntax

aConnection.SavePassword (isSaved)


BeginTrans (Connection)
BeginTrans

Starts a transaction on aConnection, and returns TRUE; otherwise returns FALSE. You can only have one transaction on aConnection at a time. Transactions that are still active at the end of an ArcView session will be closed, and changes made to the database will be committed.

Syntax

aConnection.BeginTrans

Returns

Boolean


CommitTrans (Connection)
CommitTrans

Commits all changes made to the database since the transaction was started, then closes the transaction. If all changes are committed successfully, returns TRUE; otherwise returns FALSE.

Syntax

aConnection.CommitTrans

Returns

Boolean


Rollback (Connection)
Rollback

Returns the database to the state it was in when you started the transaction. All changes made to the database since the transaction was started are eliminated, then the transaction is closed. If all changes are rolled back successfully, returns TRUE; otherwise returns FALSE.

Syntax

aConnection.Rollback

Returns

Boolean


Close (Connection)
Close

Closes the network connection between ArcView and the remote database.

Syntax

aConnection.Close


Open (Connection)
Open

Re-establishes a network connection between ArcView and the remote database. Returns TRUE if the connection is successfully established; otherwise returns FALSE.

Use this request on an existing connection object that was closed with the Close request, or on connections that were not successfully activated when you opened a project.

Syntax

aConnection.Open

Returns

Boolean


= (Connection)
=

Returns true if aConnection and anotherConnection are equal. Equal connections must have the same server, instance, dataReferenceName (if appropriate), username, and password.

Syntax

aConnection = anotherConnection

Returns

Boolean


TablePrivilegeEnum

 The following enumeration defines the table privileges you can have in the database. This enumeration is used with the GetAllTableNames request, where you are retrieving a list of all the tables for which you have one of the following privileges:

#TABLEPRIVILEGE_SELECT

You can select records from these tables.

#TABLEPRIVILEGE_UPDATE

You can update these tables.

#TABLEPRIVILEGE_INSERT

You can add data to these tables.

#TABLEPRIVILEGE_DELETE

You can delete these tables.


DBAccessProjectProperties

 The DBAccessProjectProperties contains the number of rows to be displayed when creating or updating a DBTable. It also contains a flag which controls if the "Add Database Table" process uses a wizard interface or a dialog.

Inherits From

DocumentExtension

Required Extension

     Database Access

Class Requests

DBAccessProjectProperties

GetNumRows  :  Number

Make  :  DBAccessProjectProperties

SetNumRows ( aNumber )

ShowProp

__________

See also

DocumentExtension
Project


GetNumRows (DBAccessProjectProperties)
GetNumRows

Gets the number of rows to display when creating or updating a DBTable.

Syntax

DBAccessProjectProperties.GetNumRows

Returns

Number


Make (DBAccessProjectProperties)
Make

 Makes a new DBAccessProjectProperties object.

Syntax

DBAccessProjectProperties.Make

Returns

DBAccessProjectProperties


SetNumRows (DBAccessProjectProperties)
SetNumRows

Sets the number of rows to display when creating or updating a DBTable.

Syntax

DBAccessProjectProperties.SetNumRows (aNumber)


ShowProp (DBAccessProjectProperties)
ShowProp

Shows properties dialog.

Syntax

DBAccessProjectProperties.ShowProp


DBTable

 The DBTable class, a subclass of Table, lets you create database tables to see tabular data stored in relational databases.

A DBTable represents the rows and columns selected from the database by its query. The query is generally an SQL Select statement, but can be structured to retrieve spatial data from the database; either way, if it it selects a spatial column, the table won't contain shape values. Instead, the database table will contain the shapes' internal ID number or the word Shape to indicate that the row does have a shape value.

Because queries against a relational database can select a large number of records, database tables only display some of the records retrieved by the query. ArcView creates a temporary VTab so you can scroll up and down through those records. The number of records displayed in the table is determined by the NRows property, which applies to all DBTables in your project. If you want to see more records, you can add the next set of NRows to the DBTable. You control the size of the local file.

DBTables don't support some functions available with regular ArcView tables, like selections. A DBTable IS a selected set of records from the database; you can change aDBTable's query to alter that selection. You can join a DBTable to a regular ArcView Table, but you can't join two DBTables together; you join different tables in the database together using a DBTable's query.

The records you can see in a DBTable can be identified by an index number, or row number; if a DBTable contains 10 rows, then each row has a row number between 0 and 9. These numbers are internal to ArcView and are unrelated to numbers used by the relational database to distinguish between records.

Attributes

QueryDef.The query that retrieves a DBTable's values from the database is a QueryDef object.

ActiveField.A DBTable has an active field to get statistics about its values and to join DBTables to regular ArcView tables. The active field is inverted at the top of the table.

NRows.NRows is the number of rows retrieved from the database with each read operation. When you first create a DBTable, it will contain NRows. When you add more records to a DBTable, you add NRows at a time. The property NRows applies to all DBTables in a project. The default value for NRows is 100, but you can change it to any number between 1 and 3500 using the SetNRows request.

Inherits From

Table

Required Extension

     Database Access

Class Requests

Making Database Tables

GetNRows  :  Number

Make ( aQueryDef ) :  DBTable

MakeWithGUI ( aQueryDef, aGUIName ) :  DBTable

SetNRows ( aNumber )

ShowAddDialog

ShowPrefDialog

Instance Requests

Getting and Setting Attributes

CanAddFields  :  Boolean

CanAddRecord  :  Boolean

CanRemoveFields  :  Boolean

CanRemoveRecords  :  Boolean

FindField ( aFieldName ) :  Field

GetFields  :  List

GetNumRecords  :  Number

GetQueryDef  :  QueryDef

GetVisibleVTab  :  VTab

GetVTab  :  VTab

HasError  :  Boolean

IsEditable  :  Boolean

IsEOF  :  Boolean

User Interaction (Apply Events Only)

ReturnUserField  :  Field

ReturnUserRow  :  Number

Manipulating a DBTable

Deactivate

EditProperties

Export ( aFileName, aClass ) :  VTab

GetNext  :  Boolean

JoinToVTab ( aFromField, aVTab, aToField )

Refresh

__________

See also

Connection
QueryDef
RecordSet
DBTheme
VTab


GetNRows (DBTable)
GetNRows

Returns the current value of the NRows property. NRows is the same for all DBTables in an ArcView project.

Syntax

DBTable.GetNRows

Returns

Number


Make (DBTable)
Make
Example

Creates a database table representing the rows and columns identified by the query definition aQueryDef. Use the new DBTable only if the HasError request returns FALSE.

Syntax

DBTable.Make (aQueryDef)

Returns

DBTable


MakeWithGUI (DBTable)
MakeWithGUI

Creates a database table representing the rows and columns identified by the query definition aQueryDef. This DBTable will be associated with the DocGUI named aGUIName.

Syntax

DBTable.MakeWithGUI (aQueryDef, aGUIName)

Returns

DBTable


SetNRows (DBTable)
SetNRows

Sets the value of the DBTable property NRows to aNumber.

Syntax

DBTable.SetNRows (aNumber)


ShowAddDialog (DBTable)
ShowAddDialog

Opens a dialog that lets you create database tables from the user interface. By default, this request opens the Add Database Table dialog, but you can use the SQL Query Wizard instead by choosing it in the Database Table Preferences dialog. Open the Preferences dialog with the ShowPrefDialog request.

Syntax

DBTable.ShowAddDialog


ShowPrefDialog (DBTable)
ShowPrefDialog

Opens the Database Table Preferences dialog. This dialog lets you choose the interface you use to create database tables and set the property NRows.

You can use either the SQL Query Wizard or the Add Database Table dialog to create database tables from the user interface. The SQL Query wizard is useful for beginners, but it doesn't let you create complex SQL queries. The Add Database Table dialog is the default interface for creating database tables.

Syntax

DBTable.ShowPrefDialog


CanAddFields (DBTable)
CanAddFields

Returns FALSE because you can't add fields to aDBTable. You change aDBTable's contents by changing its query. To change the source data, use methods provided by the relational database.

Syntax

aDBTable.CanAddFields

Returns

Boolean


CanAddRecord (DBTable)
CanAddRecord

Returns FALSE because you can't add a record to aDBTable. You change aDBTable's contents by changing its query. To change the source data in the database, use methods provided by the relational database or RecordSet requests.

Syntax

aDBTable.CanAddRecord

Returns

Boolean


CanRemoveFields (DBTable)
CanRemoveFields

Returns FALSE because you can't remove fields from aDBTable. You change aDBTable's contents by changing its query. To change the source data, use methods provided by the relational database.

Syntax

aDBTable.CanRemoveFields

Returns

Boolean


CanRemoveRecords (DBTable)
CanRemoveRecords

Returns FALSE because you can't remove records from aDBTable. You change aDBTable's contents by changing its query. To change the source data in the database, use methods provided by the relational database or RecordSet requests.

Syntax

aDBTable.CanRemoveRecords

Returns

Boolean


FindField (DBTable)
FindField

Returns the first field named aFieldName in aDBTable. FindField checks field aliases first, then field names. Returns nil if aFieldName isn't found.

Syntax

aDBTable.FindField (aFieldName)

Returns

Field


GetFields (DBTable)
GetFields

Gets the list of field objects representing the columns in aDBTable.

Syntax

aDBTable.GetFields

Returns

List


GetNumRecords (DBTable)
GetNumRecords

Gets the total number of records that are visible in aDBTable.

Syntax

aDBTable.GetNumRecords

Returns

Number


GetQueryDef (DBTable)
GetQueryDef

Returns the query definition that defines the rows and columns aDBTable represents.

Syntax

aDBTable.GetQueryDef

Returns

QueryDef


GetVisibleVTab (DBTable)
GetVisibleVTab

Gets the VTab containing the visible records in aDBTable. The visible VTab doesn't contain all the records selected by aDBTable's query unless the IsEOF request returns TRUE.

Syntax

aDBTable.GetVisibleVTab

Returns

VTab


GetVTab (DBTable)
GetVTab

Gets a VTab containing all the records selected by aDBTable's query. All records are copied locally to a temporary VTab file.

Syntax

aDBTable.GetVTab

Returns

VTab


HasError (DBTable)
HasError

Returns TRUE if an error occurred when creating aDBTable; otherwise returns FALSE.

Syntax

aDBTable.HasError

Returns

Boolean


IsEditable (DBTable)
IsEditable

Returns FALSE because you can't edit the source data in the database using aDBTable. You change aDBTable's contents by changing its query. To change the source data, use methods provided by the relational database or RecordSet requests.

Syntax

aDBTable.IsEditable

Returns

Boolean


IsEOF (DBTable)
IsEOF

Returns TRUE if all the rows selected by aDBTable's query are visible in aDBTable; otherwise returns FALSE.

Syntax

aDBTable.IsEOF

Returns

Boolean


ReturnUserField (DBTable)
ReturnUserField

Returns the field the user clicked on. Issue this request only in scripts that execute from Apply events; this request expects interaction with a DBTable document.

Syntax

aDBTable.ReturnUserField

Returns

Field


ReturnUserRow (DBTable)
ReturnUserRow

Returns the row number for the row that the user clicked on. The row number is an index number internal to ArcView for the visible records. Issue this request only in scripts that execute from Apply events; this request expects interaction with a DBTable document.

Syntax

aDBTable.ReturnUserRow

Returns

Number


Deactivate (DBTable)
Deactivate

Deactivates aDBTable, making it unavailable for additional reading. This request is useful if you want to delete the the source table, whose data is referenced by aDBTable, from a SYBASE or DB2 relational database.

Syntax

aDBTable.Deactivate


EditProperties (DBTable)
EditProperties

Opens the Database Table Properties dialog, which lets you change a database table's query from the user interface.

Syntax

aDBTable.EditProperties


Export (DBTable)
Export

Exports the visible records in aDBTable to a permanent VTab. The file, named aFileName, will have the type aClass, which must be dBASE, INFO, or DText. The exported table uses aDBTable's field aliases for its field names. Characters are replaced and field names truncated if the aliases contain invalid characters or are too long. Search using the limits keyword to find the field name limitations for dBASE and INFO files. aDBTable must have at least one column. Returns the new VTab.

Syntax

aDBTable.Export (aFileName, aClass)

Returns

VTab


GetNext (DBTable)
GetNext

Gets the next set of records from the database, adds them to aDBTable, and returns TRUE. Returns FALSE if all the records selected by aDBTable's query have been retrieved or aDBTable.Deactivate has been called. The number of records in the set is determined by the NRows property.

Syntax

aDBTable.GetNext

Returns

Boolean


JoinToVTab (DBTable)
JoinToVTab

Joins aDBTable to aVTab by matching the values in aFromField (in aDBTable) to the values in aToField (in aVTab). After joining the tables together, aVTab.IsBase returns FALSE. aDBTable doesn't change as a result of this request.

Syntax

aDBTable.JoinToVTab (aFromField, aVTab, aToField)


Refresh (DBTable)
Refresh

Updates the values you see in aDBTable to reflect their current status of the database. If the source data changed since aDBTable was created or last refreshed, you'll see those changes in the table. The number of visible records won't change.

Syntax

aDBTable.Refresh


DBTableDef

 An DBTableDef represents a table in a relational database. The DBTableDef has field objects representing the columns in the table.

You can open a RecordSet directly from an DBTableDef that will represent all the columns in the table and all the rows selected by the OpenRecordSet request's Where clause. Opening a RecordSet this way, rather than using a query definition, is useful when you're adding records to or deleting records from the table; you can only modify the database when the RecordSet's columns come from one table. When editing records in a table, use a RecordSet opened from a QueryDef that chooses only the columns you want to change.

Attributes

TableName.TableName is the string that represents the name of the table in the database.

Fields.Fields is the list of Field objects representing the columns in an DBTableDef. Together, the fields describe the table's definition in the database; that is, the column names and their data types.

Connection.The Connection identifies the database containing an DBTableDef.

Inherits From

Obj

Inherited By

SDETable

Required Extension

     Database Access

Class Requests

Making a DBTableDef

Make ( aConnection, aTableName ) :  DBTableDef

Instance Requests

Getting Attributes

GetConnection  :  Connection

GetFieldNames  :  List

GetFields  :  List

GetName  :  String

Running a Query

OpenRecordSet ( anSQLWhereClause ) :  RecordSet

__________

See also

Connection
QueryDef
RecordSet
SColumn


Make (DBTableDef)
Make
Example

Returns anDBTableDef object representing the table named aTableName in the database identified by aConnection; otherwise returns a nil object.

Syntax

DBTableDef.Make (aConnection, aTableName)

Returns

DBTableDef


GetConnection (DBTableDef)
GetConnection

Gets the Connection object associated with anDBTableDef.

Syntax

anDBTableDef.GetConnection

Returns

Connection


GetFieldNames (DBTableDef)
GetFieldNames

Gets a list of names for all the columns in anDBTableDef.

Syntax

anDBTableDef.GetFieldNames

Returns

List


GetFields (DBTableDef)
GetFields

Gets a list of the field objects that describe the data contained in anDBTableDef. You can't use these field objects in a RecordSet opened from anDBTableDef; the RecordSet has its own field objects.

Syntax

anDBTableDef.GetFields

Returns

List


GetName (DBTableDef)
GetName

Gets the table's name.

Syntax

anDBTableDef.GetName

Returns

String


OpenRecordSet (DBTableDef)
OpenRecordSet
Example

Returns a RecordSet representing all the columns in anDBTableDef, and all the records satisfying the attribute criteria specified with anSQLWhereClause. If anSQLWhereClause is a null string, "", the RecordSet will represent all the records in anDBTableDef. You can retrieve, edit, and store columns with a RecordSet created with this request.

Syntax

anDBTableDef.OpenRecordSet (anSQLWhereClause)

Returns

RecordSet


AddDBWizardDialog

 AddDBWizardDialog is used to show a modal dialog on the screen in which the user can enter a server name, dataset name, and choose a layer. This information is used to create a DBTheme, or a DBTable.

Inherits From

ModalDialog

Required Extension

     Database Access

Class Requests

Showing the AddDBWizardDialog

Show  :  List


Show (AddDBWizardDialog)
Show

Shows the Add DBWizard dialog box. Returns a list of new DBTheme based on the server name, dataset name, and layer names chosen by the user. If the user cancels, returns empty list.

Syntax

AddDBWizardDialog.Show

Returns

List


DBTheme

 The DBTheme class, a subclass of Theme, lets you create database themes.

A DBTheme represents the rows and columns selected from the database by its query. One of the selected columns must be a spatial column, and the query must be able to retrieve shapes from it. When you draw a database theme in a view it displays the shape in the spatial column for each row retreived by the theme's query. A DBTheme's attributes are the non-spatial columns retrieved by its query.

DBThemes support a multi-user database access model because they directly reference the database. None of the data associated with a database theme is stored locally. For example, the theme's query is re-evaluated by the database every time it draws in the view.

A DBTheme has an associated Connection object linking ArcView to the database. If the Connection is closed, the theme is disconnected from the database. If a view contains visible, disconnected DBThemes, you will see an error message for each theme indicating that ArcView is unable to retrieve the data. All requests sent to disconnected DBThemes will fail.

Attributes

QueryDef.The query that retrieves a DBTheme's values from the database is a QueryDef object. QueryDef is an abstract class; you create a DBTheme from a subclass of QueryDef that can retrieve shapes.

Selection.The Selection is a set of records whose shapes are highlighted in the view. From the user interface, you can change the Selection with the Select tool, the Clear Selection and Select By Graphics buttons, and with the SQL Query Builder. DBTheme selections are created using SDELogs.

HotField.The HotField is the DBTheme's attribute containing Hot Link values.

HotScriptName.The HotScriptName is the name of the script executed on a Hot Link.

LabelField.The LabelField is the DBTheme's attribute used to label features.

TextPositioner.The TextPositioner is used to position labels around features.

FixedSizeText.TRUE when graphic text attached to this theme should remain at the scale that it was created. FALSE when graphic text attached to this theme should change scale as the theme changes scale. The default is FALSE.

This property is applied whenever a graphic text object is created. Individual graphic text objects can override this default. Existing graphic text objects retain whatever behavior they had when they were created.

Inherits From

Theme

Required Extension

     Database Access

Class Requests

Making DBThemes

Make ( aQueryDef, anSColumn, aClass ) :  DBTheme

Instance Requests

Checking Capabilities of a DBTheme

CanEdit  :  Boolean

CanHotLink  :  Boolean

CanProject  :  Boolean

CanSelect  :  Boolean

HasAttributes  :  Boolean

Displaying Dialog Boxes

BuildQuery

EditLegend

Setting and Changing the Selection

ClearSelection

SelectByAttributes ( anSQLWhereClause, aSelType )

SelectByPoint ( aPoint, aSelType )

SelectByPolygon ( aPolygon, aSelType )

SelectByRect ( aRect, aSelType )

SelectByShapes ( ShapeList, aSelType )

SelectByTheme ( aTheme, aRelType, aDistance, aSelType )

Getting and Setting Attributes

GetHotField  :  Field

GetHotScriptName  :  String

GetLastSelection  :  SDELog

GetQueryDef  :  QueryDef

GetSColumn  :  SColumn

GetSelectedExtent  :  Rect

GetSelection  :  SDELog

GetShapeClass  :  Classes

GetSrcName  :  SrcName

RememberSelection

ReturnExtent  :  Rect

SetHotField ( aField )

SetHotScriptName ( aScriptName )

SetQueryDef ( aQueryDef )

SetSelection ( anObj )

Exporting Features and Values

CanExportToFTab  :  Boolean

ExportToFTab ( aFileName ) :  FTab

ExportToVTab ( aFileName, aClass ) :  VTab

Managing Connections

UseConnectionFrom ( anotherDBTheme ) :  Boolean

Labeling a DBTheme

CanLabel  :  Boolean

GetFixedSizeText  :  Boolean

GetLabelField  :  Field

GetLabelTextSym  :  Symbol

GetTextPositioner  :  TextPositioner

ReturnLabel ( aDisplay, aPoint ) :  GraphicText

ReturnSymbolSize ( aShapeID ) :  Number

SetFixedSizeText ( isScaled )

SetLabelField ( aField )

SetLabelTextSym ( aSymbol )

Supporting Identify

BlinkRecord ( aShapeID )

FindByPoint ( aPoint ) :  List

Identify ( aShapeID, aString )

Supporting the Legend Editor

CanReturnClassCounts  :  Boolean

ReturnClassCounts  :  List

ReturnDefaultLegend  :  Legend

SetDefaultLegend

UpdateLegend

Generic Object Management

Clone  :  DBTheme

SetName ( aName )

__________

See also

SDEConnection
SDEQueryDef
SDESColumn
SDELog
DBTable
ThemeOnThemeDialog
View
FTheme
FTab


Make (DBTheme)
Make
Example

 Creates a DBTheme from aQueryDef and anSColumn; otherwise, returns a nil object. The DBTheme represents all the columns and records identified by the query definition aQueryDef, and draws the shapes stored in the spatial column anSColumn for each record retrieved. aQueryDef must be able to retrieve shapes from the database.

A spatial column can contain many feature types, but a theme can only display area, linear, or point features, or the annotation associated with the features in this spatial column. aClass identifies the feature types your theme will represent; it must be one of Polygon, PolyLine, Point, or Annotation.

Syntax

DBTheme.Make (aQueryDef, anSColumn, aClass)

Returns

DBTheme


CanEdit (DBTheme)
CanEdit

Returns FALSE because DBThemes can't be edited from ArcView's user interface.

Syntax

aDBTheme.CanEdit

Returns

Boolean


CanHotLink (DBTheme)
CanHotLink

Returns TRUE because DBThemes support Hot Links.

Syntax

aDBTheme.CanHotLink

Returns

Boolean


CanProject (DBTheme)
CanProject

Returns TRUE because DBThemes can be projected if the shapes in the database have decimal degrees coordinates.

Syntax

aDBTheme.CanProject

Returns

Boolean


CanSelect (DBTheme)
CanSelect

Returns TRUE because you can select a DBTheme's features.

Syntax

aDBTheme.CanSelect

Returns

Boolean


HasAttributes (DBTheme)
HasAttributes

Returns TRUE because DBThemes can have attributes.

Syntax

aDBTheme.HasAttributes

Returns

Boolean


BuildQuery (DBTheme)
BuildQuery

Displays the SQL Query Builder dialog box. The dialog lets you build an SQL Where clause, then select the features whose attributes satisfy both the selection Where clause and aDBTheme's query definition.

Syntax

aDBTheme.BuildQuery


EditLegend (DBTheme)
EditLegend

Opens the Legend Editor for aDBTheme.

Syntax

aDBTheme.EditLegend


ClearSelection (DBTheme)
ClearSelection
Example

Clears the selected features of aDBTheme.

Syntax

aDBTheme.ClearSelection


SelectByAttributes (DBTheme)
SelectByAttributes
Example

Selects the features of aDBTheme whose attributes satisfy anSQLWhereClause, and affects the current selection according to aSelType. AnSQLWhereClause is a string like you would create with the SQL Query Builder; it must be a valid SQL Where clause for your relational database. See the help topic Selecting database theme features by their attributes for information about building an SQL Where clause.

Syntax

aDBTheme.SelectByAttributes (anSQLWhereClause, aSelType)


SelectByPoint (DBTheme)
SelectByPoint
Example

Selects the features of aDBTheme intersecting aPoint, and affects the current selection according to aSelType. SelectByPoint uses a fixed distance tolerance equivalent to 3 screen pixels.

Syntax

aDBTheme.SelectByPoint (aPoint, aSelType)


SelectByPolygon (DBTheme)
SelectByPolygon

Selects the features of aDBTheme intersecting aPolygon, and affects the current selection according to aSelType. aPolygon can be a multi-part polygon shape.

Syntax

aDBTheme.SelectByPolygon (aPolygon, aSelType)


SelectByRect (DBTheme)
SelectByRect

Selects the features of aDBTheme intersecting aRect, and affects the current selection according to aSelType.

Syntax

aDBTheme.SelectByRect (aRect, aSelType)


SelectByShapes (DBTheme)
SelectByShapes
Example

Selects the features of aDBTheme intersecting at least one of the shapes in the list ShapeList, and affects the current selection according to aSelType. PolyLine shapes in the list can have many parts.

Syntax

aDBTheme.SelectByShapes (ShapeList, aSelType)


SelectByTheme (DBTheme)
SelectByTheme
Example

 Selects the features of aDBTheme if they have the relationship aRelType with the selected features of aTheme (a DBTheme or an FTheme). The current selection changes according to aSelType. aDistance is used with some RelTypes. The units for its distance measurement must be the same as the coordinates of the shapes in the view, e.g. decimal degrees.

If aTheme is a DBTheme, it must have selected features. Unlike FThemes, ArcView does not assume all features in a DBTheme are selected if there are no selected features.

Syntax

aDBTheme.SelectByTheme (aTheme, aRelType, aDistance, aSelType)


GetHotField (DBTheme)
GetHotField

Gets the Hot Link field of aDBTheme.

Syntax

aDBTheme.GetHotField

Returns

Field


GetHotScriptName (DBTheme)
GetHotScriptName

Gets the name of the Hot Link script of aDBTheme.

Syntax

aDBTheme.GetHotScriptName

Returns

String


GetLastSelection (DBTheme)
GetLastSelection

Gets the saved selection of aDBTheme.

Syntax

aDBTheme.GetLastSelection

Returns

SDELog


GetQueryDef (DBTheme)
GetQueryDef
Example

Returns the query definition that defines aDBTheme.

The QueryDef returned is aDBTheme's actual QueryDef, not a copy. Changes you make to it will affect aDBTheme without having to use the SetQueryDef request. You can maintain the original QueryDef by cloning it, making changes to the copy, then posting changes back to the DBTheme with the SetQueryDef request.

Syntax

aDBTheme.GetQueryDef

Returns

QueryDef


GetSColumn (DBTheme)
GetSColumn
Example

Returns the spatial column that defines aDBTheme.

Syntax

aDBTheme.GetSColumn

Returns

SColumn


GetSelectedExtent (DBTheme)
GetSelectedExtent

Returns the smallest rectangle containing the selected features in aDBTheme.

Syntax

aDBTheme.GetSelectedExtent

Returns

Rect


GetSelection (DBTheme)
GetSelection
Example

Returns aDBTheme's selection SDELog. If no features are selected in aDBTheme, returns a nil.

Syntax

aDBTheme.GetSelection

Returns

SDELog


GetShapeClass (DBTheme)
GetShapeClass

Gets the class of the shapes in aDBTheme. You can make a string from the class with the GetClassName request. The returned value is Annotation, or one of the Point, MultiPoint, PolyLine, or Polygon classes. For example, aDBTheme that displays lines could have the class PolyLine, PolyLineM, or PolyLineZ.

The class of a spatial column will be Point if it can have point features and if it can't have multi-part features; if the spatial column can have multi-part features, the class will be MultiPoint even if it has single-part points only. The class determines the type of shapefile ArcView creates if you export features from aDBTheme; however, you can't export annotation from aDBTheme.

Syntax

aDBTheme.GetShapeClass

Returns

Class


GetSrcName (DBTheme)
GetSrcName

Returns nil for aDBTheme.

Syntax

aDBTheme.GetSrcName

Returns

SrcName


RememberSelection (DBTheme)
RememberSelection
Example

Saves the current selection. You can retrieve this selection SDELog later with GetLastSelection.

Syntax

aDBTheme.RememberSelection


ReturnExtent (DBTheme)
ReturnExtent

Returns a rectangle representing the maximum extent of aDBTheme's spatial column, not the smallest rectangle containing the shapes in aDBTheme. The rectangle's coordinates are in the view's map units.

Syntax

aDBTheme.ReturnExtent

Returns

Rect


SetHotField (DBTheme)
SetHotField

Sets the Hot Link field of aDBTheme to aField.

Syntax

aDBTheme.SetHotField (aField)


SetHotScriptName (DBTheme)
SetHotScriptName

Sets the name of the Hot Link script of aDBTheme to aScriptName.

Syntax

aDBTheme.SetHotScriptName (aScriptName)


SetQueryDef (DBTheme)
SetQueryDef
Example

Changes aDBTheme's query definition to aQueryDef.

Syntax

aDBTheme.SetQueryDef (aQueryDef)


SetSelection (DBTheme)
SetSelection
Example

Sets the selection of aDBTheme to the appropriate selection object. If your spatial data is stored in an SDE database the appropriate selection object is an SDELog.

Syntax

aDBTheme.SetSelection (anObj)


CanExportToFTab (DBTheme)
CanExportToFTab
Example

Returns TRUE if aDBTheme has selected features, otherwise returns FALSE.

Syntax

aDBTheme.CanExportToFTab

Returns

Boolean


ExportToFTab (DBTheme)
ExportToFTab
Example

Exports the selected features in aDBTheme to anFTab called aFileName of type Shape. The projection of the new FTab matches that of the spatial objects in the spatial column. Nil is returned on error.

You should only use the ExportToFTab request if CanExportToFTab returns true. If aDBTheme doesn't have selected features, the returned FTab will have fields but no records. Unlike FThemes, ArcView does not assume all features in a DBTheme are selected if there are no selected features.

If aDBTheme doesn't have any attributes, the FTab will have one attribute column, named SE_ROW_ID, and will contain internal ID numbers of the selected features.

Syntax

aDBTheme.ExportToFTab (aFileName)

Returns

FTab


ExportToVTab (DBTheme)
ExportToVTab
Example

Exports the attribute values of the selected features in aDBTheme to a VTab called aFileName of type aClass, where aClass must be dBASE, INFO, or dText. Only aDBTheme's attributes are exported; the exported table uses column aliases for field names in the new table. Nil is returned on error.

You should only use the ExportToVTab request if CanExportToFTab returns true. If aDBTheme doesn't have selected features, the returned VTab will have fields but no records. Unlike FThemes, ArcView does not assume all features in a DBTheme are selected if there are no selected features.

aDBTheme must have at least one attribute to export attributes from the user interface; from Avenue, if aDBTheme has no attriutes the VTab will have one column, named SE_ROW_ID, and will contain internal ID numbers of the selected features.

Syntax

aDBTheme.ExportToVTab (aFileName, aClass)

Returns

VTab


UseConnectionFrom (DBTheme)
UseConnectionFrom

Applies the connection from anotherDBTheme to aDBTheme. aDBTheme will then share the same connection as anotherDBTheme. If successful, UseConnectionFrom will return true. The request will only be successful if the original connections are the same: server, instance, dataReferenceName (if appropriate), username, and password.

Syntax

aDBTheme.UseConnectionFrom (anotherDBTheme)

Returns

Boolean


CanLabel (DBTheme)
CanLabel

Returns TRUE because you can label DBThemes.

Syntax

aDBTheme.CanLabel

Returns

Boolean


GetFixedSizeText (DBTheme)
GetFixedSizeText

Returns the current value of aDBTheme's FixedSizeText attribute. See the discussion for SetFixedSizeText.

Syntax

aDBTheme.GetFixedSizeText

Returns

Boolean


GetLabelField (DBTheme)
GetLabelField

Gets the Label Field of aDBTheme.

Syntax

aDBTheme.GetLabelField

Returns

Field


GetLabelTextSym (DBTheme)
GetLabelTextSym

Gets the label text symbol of aDBTheme.

Syntax

aDBTheme.GetLabelTextSym

Returns

Symbol


GetTextPositioner (DBTheme)
GetTextPositioner

Gets the TextPositioner of aDBTheme.

Syntax

aDBTheme.GetTextPositioner

Returns

TextPositioner


ReturnLabel (DBTheme)
ReturnLabel

Returns a GraphicText label on aDisplay for a feature of aDBTheme found at aPoint.

Syntax

aDBTheme.ReturnLabel (aDisplay, aPoint)

Returns

GraphicText


ReturnSymbolSize (DBTheme)
ReturnSymbolSize

Returns the size of the font used to label the feature in aDBTheme whose internal ID number is aShapeID.

Syntax

aDBTheme.ReturnSymbolSize (aShapeID)

Returns

Number


SetFixedSizeText (DBTheme)
SetFixedSizeText

Sets default behavior for graphic objects created after this request. When isScaled is TRUE, graphic text objects won't change size as aDBTheme's display scale changes. When isScaled is FALSE, graphic text objects will change size proportionately to aDBTheme's change in scale.

Syntax

aDBTheme.SetFixedSizeText (isScaled)


SetLabelField (DBTheme)
SetLabelField

Sets the Label Field of aDBTheme to aField.

Syntax

aDBTheme.SetLabelField (aField)


SetLabelTextSym (DBTheme)
SetLabelTextSym

Sets the label text symbol of aDBTheme to aSymbol.

Syntax

aDBTheme.SetLabelTextSym (aSymbol)


BlinkRecord (DBTheme)
BlinkRecord
Example

Flashes in the view the feature in aDBTheme whose internal ID number is aShapeID.

Syntax

aDBTheme.BlinkRecord (aShapeID)


FindByPoint (DBTheme)
FindByPoint
Example

Finds a set of features containing aPoint in aDBTheme. Returns an empty list if no features are found. If it finds features, FindByPoint returns a list containing their internal ID numbers. FindByPoint uses a fixed distance tolerance equivalent to 3 screen pixels. Use FindByPoint to get features without making a selection.

Syntax

aDBTheme.FindByPoint (aPoint)

Returns

List


Identify (DBTheme)
Identify

Puts attribute values for the feature in aDBTheme whose internal ID number is aShapeID into the identify window, and blinks the feature in the view. In the Identify window, the entry for this feature will be labeled with aString.

Syntax

aDBTheme.Identify (aShapeID, aString)


CanReturnClassCounts (DBTheme)
CanReturnClassCounts

Returns a boolean indicating whether the number of features in each class in the legend can be computed for aDBTheme.

Syntax

aDBTheme.CanReturnClassCounts

Returns

Boolean


ReturnClassCounts (DBTheme)
ReturnClassCounts

Returns a list containing the number of features in each class in the legend.

Syntax

aDBTheme.ReturnClassCounts

Returns

List


ReturnDefaultLegend (DBTheme)
ReturnDefaultLegend

Returns a default legend appropriate to the type of aDBTheme. For aDBTheme this is a single symbol legend.

Syntax

aDBTheme.ReturnDefaultLegend

Returns

Legend


SetDefaultLegend (DBTheme)
SetDefaultLegend

Sets the legend of aDBTheme to a default legend appropriate to the type of theme. For aDBTheme this is a single symbol legend.

Syntax

aDBTheme.SetDefaultLegend


UpdateLegend (DBTheme)
UpdateLegend

Updates aDBTheme to reflect changes to its legend. UpdateLegend invalidates both the theme and its legend.

Syntax

aDBTheme.UpdateLegend


Clone (DBTheme)
Clone

Clones aDBTheme.

Syntax

aDBTheme.Clone

Returns

DBTheme


SetName (DBTheme)
SetName

Sets the name of aDBTheme to aName.

Syntax

aDBTheme.SetName (aName)


DBTQueryWin

 A DBTQueryWin is a window which displays the fields of a database theme to assist the user in building an query for that theme.

Inherits From

Window

Required Extension

     Database Access

Class Requests

Making a DBTQueryWin and Showing a modal DBTQueryWin

Make ( aDBTheme ) :  DBTQueryWin

ReturnQuery ( aDBTheme, aQueryDef ) :  QueryDef

Instance Requests

Manipulating a QueryWin

Close

Open

__________

See also

QueryWin
DBTheme


Make (DBTQueryWin)
Make

Opens a modeless query dialog associated with aDBTheme. The dialog is the SQL Query Builder that you get when the active theme is a database theme and you click the Query Builder button in the View user interface.

Syntax

DBTQueryWin.Make (aDBTheme)

Returns

DBTQueryWin


ReturnQuery (DBTQueryWin)
ReturnQuery

Creates a modal window that lets the user edit aQueryDef until selecting OK or Cancel. aQueryDef must be a spatial query, such as an SDEQueryDef created with the SetSelectColumns, SetFromTables, and SetWhereClause requests.

If the user selects Cancel, aQueryDef remains unchanged; otherwise, it returns the modified QueryDef. This dialog is the SQL Query Wizard with the same panels as when you click the QueryBuilder button in the Theme Properties dialog. The panels let you change which tables are joined together, which rows are selected, and which columns are selected.

Syntax

DBTQueryWin.ReturnQuery (aDBTheme, aQueryDef)

Returns

QueryDef


Close (DBTQueryWin)
Close

Closes aDBTQueryWin created with the Make request.

Syntax

aDBTQueryWin.Close


Open (DBTQueryWin)
Open

Opens aDBTQueryWin created with the Make request.

Syntax

aDBTQueryWin.Open


QueryDef

 A QueryDef object is a query that you can send to a relational database. The connection object identifies which database the query is sent to. QueryDef is the abstract class that defines general properties and methods for querying a relational database.

Specify a query by writing an SQL statement, whose syntax is valid for your relational database. If the SQL statement doesn't return data (e.g. a CreateTable statement), send it to the database using the Execute request. If the SQL statement returns data (a Select statement), send it to the database with the OpenRecordSet request. Use the resulting RecordSet object to work with the retrieved values.

Attributes

SQL.A QueryDef's SQL statement.

Connection.A QueryDef's Connection object identifies the database the query is sent to. It also controls network communication between ArcView and the remote database. If the Connection isn't active, no queries will succeed.

SelectColumns.SelectColumns is a list of names for the columns you want to retrieve from the database. You can choose these from all the columns in the source tables identified by FromTables. To retrieve shapes, this list must include the name of one spatial column.

FromTables.FromTables is a list of names defining which tables you want to retrieve data from. To retrieve shapes with this query, this list must include a table that contains a spatial column.

WhereClause.WhereClause is a string with the same format as the Where clause of an SQL Select statement. It defines attribute criteria to select the records you want to retrieve, and if FromTables lists more than one table, it must define a join statement, indicating how those tables are joined together. If the WhereClause doesn't include attribute criteria, the query will retreive all records in the FromTables.

Inherits From

Obj

Inherited By

SDEQueryDef

Required Extension

     Database Access

Class Requests

Making a QueryDef

Make ( aConnection ) :  QueryDef

Instance Requests

Getting and Setting Attributes

Clone  :  QueryDef

GetConnection  :  Connection

GetFromTables  :  List

GetSelectColumns  :  List

GetSQL  :  String

GetWhereClause  :  String

ReturnStatistics ( aColumnName ) :  List

SetFromTables ( tableNamesList )

SetSelectColumns ( columnNamesList )

SetSQL ( anSQLStatement )

SetWhereClause ( anSQLWhereClause )

Sending a Query to the database

Execute  :  Boolean

OpenRecordSet  :  RecordSet

__________

See also

Connection
RecordSet
DBTableDef
SColumn
DBTheme
DBTable


Make (QueryDef)
Make

Creates a query definition object that is associated with the connection object aConnection. Use this request only if aConnection.HasError returns FALSE.

Syntax

QueryDef.Make (aConnection)

Returns

QueryDef


Clone (QueryDef)
Clone

Creates a new query definition object that has the same SQL statement and is associated with the same database connection as aQueryDef.

Clone a QueryDef object when you want to modify an existing query, but you don't want to alter the original. This is important when you retrieve a QueryDef from a database theme or a database table, then you want to modify the query and use it to analyze data, but you don't want to change the theme or table.

Syntax

aQueryDef.Clone

Returns

QueryDef


GetConnection (QueryDef)
GetConnection

Gets the Connection object associated with a query definition.

Syntax

aQueryDef.GetConnection

Returns

Connection


GetFromTables (QueryDef)
GetFromTables

Returns a list of names indicating which tables in the database aQueryDef gets its values from when you open a RecordSet. Otherwise, returns an empty list; if the list doesn't contain at least one table name, you can't open a RecordSet.

Syntax

aQueryDef.GetFromTables

Returns

List


GetSelectColumns (QueryDef)
GetSelectColumns
Example

Returns a list of names indicating which columns of values anQueryDef retrieves from the database when you open a RecordSet. Otherwise, returns an empty list; if the list doesn't contain at least one column name, you can't open a RecordSet.

Syntax

anQueryDef.GetSelectColumns

Returns

List


GetSQL (QueryDef)
GetSQL
Example

Returns a string containing aQueryDef's SQL statement.

If aQueryDef is a spatial query, returns an SQL Select statement created by combining the words "Select", "From", and "Where" with SelectColumns, FromTables, and WhereClause in the appropriate order. Spatial criteria aren't included.

Syntax

aQueryDef.GetSQL

Returns

String


GetWhereClause (QueryDef)
GetWhereClause
Example

Returns a string containing the query's attribute criteria and join statements. Returns a null string if aQueryDef doesn't have a WhereClause; without a Where clause, aQueryDef selects all records from the one table listed in FromTables.

Syntax

aQueryDef.GetWhereClause

Returns

String


ReturnStatistics (QueryDef)
ReturnStatistics

Returns a list of statistics for the column named aColumnName. These statistics apply to all the values in the column, excluding NULL values. To use this request you must have created your query using the SetSelectColumns, SetFromTables, and SetWhereClause requests.

If you created your query using the SetSQL request, you can retrieve statistics for the column by creating a new query whose SQL statement contains the SUM, COUNT, AVG, MAX, MIN, and STDDEV functions.

Syntax

aQueryDef.ReturnStatistics (aColumnName)

Returns

List


SetFromTables (QueryDef)
SetFromTables
Example

 aQueryDef will retreive values from the tables named in tableNamesList, which is a list of string objects. This is equivalent to the "From" portion of an SQL Select statement. You can't use this request in combination with the SetSQL request.

tableNamesList must contain at least one table name. If you don't own a table, its name must be provided in the format "<ownerName>.<tableName>". The fields in SelectColumns and WhereClause must be contained by the table(s) in this list. If tableNamesList contains more than one table name, WhereClause must contain a join statement specifying how the tables are joined together.

Syntax

aQueryDef.SetFromTables (tableNamesList)


SetSelectColumns (QueryDef)
SetSelectColumns
Example

 When you retrieve records using aQueryDef, you will get values from the columns named in columnNamesList, which is a list of string objects. This is equivalent to the "Select" portion of an SQL Select statement. You can't use this request in combination with the SetSQL request.

columnNamesList must contain at least one field name. To retrieve shapes, the list must contain the spatial column's name. If you don't own the table containing a column, its name must be provided in the format "<ownerName>.<tableName>.<columnName>".

Syntax

aQueryDef.SetSelectColumns (columnNamesList)


SetSQL (QueryDef)
SetSQL

aQueryDef will represent anSQLStatement, which can be any valid SQL statement for your relational database; for example, it could be an Insert or an Update statement.

Syntax

aQueryDef.SetSQL (anSQLStatement)


SetWhereClause (QueryDef)
SetWhereClause
Example

 The FromTables are joined together using the join statements in anSQLWhereClause, and aQueryDef will retrieve records from the result that are selected by the attribute criteria in anSQLWhereClause. This is the equivalent of the "Where" portion of an SQL Select statement. You can't use this request in combination with the SetSQL request.

The SetWhereClause request is optional if the tableNamesList in the SetFromTables request contains only one table name; otherwise, you must use the SetWhereClause request to specify how the tables are joined together; for example, "States.Fips_code = Stdemog.Fips_code". In this example the two tables States and Stdemog, which contains attributes describing the shapes in the States table, are joined together by the common field Fips_code.

anSQLWhereClause can also contain attribute criteria selecting the records you want to retrieve; for example, "state_name = 'California'". Criteria must be specified according to the SQL syntax requirements of your relational database.

Syntax

aQueryDef.SetWhereClause (anSQLWhereClause)


Execute (QueryDef)
Execute

Sends aQueryDef's SQL statement to the database, and returns TRUE if the database was able to successfully execute the statement; otherwise, returns FALSE (e.g. because the syntax was incorrect). Use this request for statements that don't generate output; for example, Update or Insert statements.

Syntax

aQueryDef.Execute

Returns

Boolean


OpenRecordSet (QueryDef)
OpenRecordSet
Example

Sends aQueryDef's SQL statement to the database, and returns a RecordSet if the database was able to successfully execute the statement; otherwise, returns a nil object (e.g., because the syntax was incorrect or a column name was spelled wrong). Use this request with statements that retrieve data, like Select statements. You work with the retrieved records using the RecordSet. If aQueryDef selects no records, the RecordSet will be empty and the Next request will return FALSE.

Syntax

aQueryDef.OpenRecordSet

Returns

RecordSet


RecordSet

 A RecordSet object represents the set of columns and rows retrieved by a query definition. RecordSet is an abstract class that defines the general properties and methods for working with the rows retrieved by a query.

When you open a RecordSet, ArcView creates a set of Field objects representing the columns. The RecordSet also has a current row, consisting of one value object of the appropriate datatype for each field: a Shape, a String, a Number, a Date, or a FileName (for BLOB fields).

When you first open a RecordSet, the current row is positioned above the first record in the set; that is, all of the value objects contain null values. The first time you use the Next request, the current row is positioned at the first record in the set, and the current row's values change to reflect the first record's values. The GetRow and GetValue requests return value objects that point to the current row's values.

To step through all records in a RecordSet, place the Next request in a While loop. You can't move backwards through a RecordSet.

You can update the source data in the database using a RecordSet if the CanUpdate request returns TRUE. Your user name must have been granted permission in the database to update, insert, or delete records.

To maintain integrity in the database while you are editing the source data, lock the shape whose values you want to change, or in the area you want to add new shapes to; then, before you start changing the database, start a transaction on the RecordSet's connection. No one else will be able to change the records you're changing, and they won't be able to see your changes until your transaction has been committed.

Attributes

Fields.Fields is a list of field objects representing the columns of data retrieved from the database. These fields are created from the RecordSet's QueryDef; changing them won't affect the contents or properties of the RecordSet.

CurrentRow.The CurrentRow is the row in the record set that you can retrieve data from. You can change the CurrentRow to the next row in the RecordSet using the Next request.

CanUpdate.Indicates whether or not editing operations can be performed using a RecordSet.

IsBeingEdited.Indicates whether or not changes are in progress in a RecordSet. Changes are in progress if the AddNew or Edit request has been issued, but the Update request has not.

IsEOF.Indicates whether or not all the records selected by the RecordSet's query have been retrieved from the database.

Inherits From

Obj

Inherited By

SDERecordSet

Required Extension

     Database Access

Instance Requests

Getting and Setting Attributes

CanUpdate  :  Boolean

FindField ( aFieldName ) :  Field

GetFields  :  List

IsBeingEdited  :  Boolean

IsEOF  :  Boolean

Running a Query

Close  :  Boolean

Next  :  Boolean

Getting and Setting Values

GetRow  :  List

GetValue ( aField ) :  Obj

GetValueByIndex ( anIndexNumber ) :  Obj

SetRow ( aListofValues ) :  Boolean

SetValue ( aField, anObj ) :  Boolean

SetValueByIndex ( anIndexNumber, anObj ) :  Boolean

Editing a RecordSet

AddNew  :  Boolean

Delete ( anSQLWhereClause ) :  Boolean

Edit ( anSQLWhereClause ) :  Boolean

EndUpdate  :  Boolean

Update  :  Boolean

__________

See also

Connection
QueryDef
DBTableDef
SColumn
DBTheme
DBTable


CanUpdate (RecordSet)
CanUpdate

Returns TRUE if you can change the source data in the database using aRecordSet; otherwise, returns FALSE.

Syntax

aRecordSet.CanUpdate

Returns

Boolean


FindField (RecordSet)
FindField

Returns the field object named aFieldName from the fields in aRecordSet; otherwise, returns a nil object.

Syntax

aRecordSet.FindField (aFieldName)

Returns

Field


GetFields (RecordSet)
GetFields

Gets aRecordSet's field objects. Use them to Get and Set values.

Syntax

aRecordSet.GetFields

Returns

List


IsBeingEdited (RecordSet)
IsBeingEdited

Returns TRUE if the AddNew or Edit request has been issued on aRecordSet and the changes have not been finalized using the Update request; otherwise, returns FALSE.

Syntax

aRecordSet.IsBeingEdited

Returns

Boolean


IsEOF (RecordSet)
IsEOF

Returns TRUE if all records selected by aRecordSet's query have been retrieved from the database; otherwise, returns FALSE.

Syntax

aRecordSet.IsEOF

Returns

Boolean


Close (RecordSet)
Close

Closes aRecordSet and returns TRUE. After closing aRecordSet you can't use it again to access data. You must close aRecordSet when you're finished stepping through its records to remove its objects from memory.

Syntax

aRecordSet.Close

Returns

Boolean


Next (RecordSet)
Next

Moves the current row to the next row in aRecordSet, and returns TRUE. If the current row is the last row in the set, returns FALSE.

Any value objects that reference the current row's values, e.g. values returned with GetRow or GetValue, change to reflect the next row's values.

Syntax

aRecordSet.Next

Returns

Boolean


GetRow (RecordSet)
GetRow

Gets a list of the current row's value objects. After using Next, the values for these objects will change to reflect the next row's values.

To keep values from the current row after using the Next request (for example, in a list that you will use later) you must clone the value objects before adding them to the list.

Syntax

aRecordSet.GetRow

Returns

List


GetValue (RecordSet)
GetValue
Example

Gets the current row's value object for the column specified by aField. After using Next, the object's value will change to represent the next row's value for this column.

To keep this row's value after using the Next request (for example, in a list that you will use later) you must clone the RecordSet's value object before adding it to that list.

Syntax

aRecordSet.GetValue (aField)

Returns

Obj


GetValueByIndex (RecordSet)
GetValueByIndex

Gets the current row's value object for the column specified by anIndexNumber. After using Next, the object's value will change to represent the next row's value for this column.

anIndexNumber is the index of a column's field in the RecordSet's fields list; for example, if anIndexNumber is two, this request retrieves the current row's value for aRecordSet's third field.

To keep this row's value after using the Next request (for example, in a list that you will use later) you must clone the RecordSet's value object before adding it to that list.

Syntax

aRecordSet.GetValueByIndex (anIndexNumber)

Returns

Obj


SetRow (RecordSet)
SetRow

Sets the current row's values to the objects in aListofValues. aListofValues is a List of Value objects. The object at each index position in the list must be appropriate for the datatype of the corresponding field in aRecordSet's list of fields. Use this request after using the AddNew or Edit request and before using the Update request.

Syntax

aRecordSet.SetRow (aListofValues)

Returns

Boolean


SetValue (RecordSet)
SetValue

Sets the current row's value for the column specified by aField to the value of anObj. anObj must be an appropriate Value object for aField's datatype. Use this request after using the AddNew or Edit request and before using the Update request.

Syntax

aRecordSet.SetValue (aField, anObj)

Returns

Boolean


SetValueByIndex (RecordSet)
SetValueByIndex

Sets the current row's value for the column specified by anIndexNumber to the value of anObj. anObj must be an appropriate Value object for aField's datatype. Use this request after using the AddNew or Edit request and before using the Update request.

anIndexNumber is the index of a column's field in the RecordSet's fields list; for example, if anIndexNumber is two, this request sets the value object for aRecordSet's third field.

Syntax

aRecordSet.SetValueByIndex (anIndexNumber, anObj)

Returns

Boolean


AddNew (RecordSet)
AddNew

Prepares aRecordSet to add a new row to the source table in the database, and returns TRUE; otherwise, returns FALSE. Preparing to insert data takes time and memory, so don't place this request inside a loop - you only need to use it once in aRecordSet. Putting this request inside a loop decreases performance significantly.

After issuing this request, you can assign values to the new row with the SetRow and SetValue requests. Use the Update request to send each new row to the database after you've finished setting its values. You must use the EndUpdate request after all new records have been added to complete the AddNew process and release the objects used from memory.

Syntax

aRecordSet.AddNew

Returns

Boolean


Delete (RecordSet)
Delete

Deletes the row(s) identified by anSQLWhereClause from the database and returns TRUE; otherwise returns FALSE. You don't need to use the Update request to send this change to the database.

Syntax

aRecordSet.Delete (anSQLWhereClause)

Returns

Boolean


Edit (RecordSet)
Edit

Prepares aRecordSet for editing the row(s) identified by anSQLWhereClause, and returns TRUE; otherwise, returns FALSE. If you only want to edit one row, anSQLWhereClause must use a column name and a value that uniquely identify that record in the source table.

After issuing this request, you can change values in the identified row(s) with the SetRow or SetValue requests. Use the Update request to send the changes to the database after changing the values. You must use the EndUpdate request after all edits are finished to complete the editing process.

Syntax

aRecordSet.Edit (anSQLWhereClause)

Returns

Boolean


EndUpdate (RecordSet)
EndUpdate

Ensures that updates made to the source data with AddNew or Edit have been sent to the database, and clears the objects used for editing data from memory. Returns TRUE if all records in the update batch are stored successfully in the database; otherwise, returns FALSE.

Syntax

aRecordSet.EndUpdate

Returns

Boolean


Update (RecordSet)
Update

Sends the current row's values to the database. These values are stored in a new record in the database if you used the AddNew request. If you used the Edit request, for each column in the RecordSet, the stored value is changed to represent the current row's values in each row identified by the Where clause.

You must use EndUpdate when you're finished updating the database with either the AddNew or Edit requests to complete the editing process.

Syntax

aRecordSet.Update

Returns

Boolean


SColumn

 A spatial column represents a column in a table that stores shapes. One spatial column can have many types of shapes: points, lines, polygons, and annotation. Those shapes must share a thematic subject, like land parcels. SColumn is an abstract class that defines genearl properties and methods of working with spatial columns.

To work with database data in ArcView, you create a query definition, then open a RecordSet to retrieve the records selected by the query. Then, you step through the records, working with their values as you go. If your query selects a spatial column, if the query can retrieve shapes, then using the GetValue request on the spatial column returns an ArcView Shape object.

The general methods let you spatially lock records in the spatial column's table. You can either lock all the records in the table, or only the records whose shapes intersect a rectangle. Locking records helps you maintain integrity in a multi-user database when you're modifying the source data.

Attributes

Connection.A SColumn's Connection object identifies the database containing this spatial column. You can only work with an SColumn if its Connection is active.

TableName.The TableName identifies which table contains the spatial column. TableName includes the user name of the table's owner, separated from the table's name by a dot, if you don't own the table.

SColumnName.The SColumnName identifies which column in the table contains the spatial data you want to access.

Extent.The maximum extent of a spatial column is a rectangle representing the its coordinate boundary; all coordinates in all shapes in the spatial column must fall inside this boundary. When you get a spatial column's extent you define an SQL Where clause. If the Where clause is a null string, you'll get the spatial column's maximum extent; otherwise, the extent represents the smallest rectangle containing the shapes selected by the Where clause.

Inherits From

Obj

Inherited By

SDESColumn

Required Extension

     Database Access

Class Requests

Making an SColumn

Make ( aConnection, aTableName, aFieldName ) :  SColumn

Instance Requests

Getting Attributes

GetConnection  :  Connection

GetSColumnName  :  String

GetTableName  :  String

ReturnExtent ( anSQLWhereClause ) :  Rect

ReturnStatistics  :  List

Managing Locks

FreeLock  :  Boolean

LockAll ( canModify ) :  Boolean

LockArea ( aRectangle, canModify ) :  Boolean

Managing Objects

Clone  :  SColumn

__________

See also

Connection
QueryDef
RecordSet
DBTableDef
DBTheme


Make (SColumn)
Make

Returns anSColumn object representing the spatial column named aFieldName in the table named aTableName in the database identified by the connection object aConnection; otherwise returns a nil object. aTableName must have the format "<ownerName>.<tableName>" if you don't own the table.

Syntax

SColumn.Make (aConnection, aTableName, aFieldName)

Returns

SColumn


GetConnection (SColumn)
GetConnection

Gets the Connection object associated with anSColumn.

Syntax

anSColumn.GetConnection

Returns

Connection


GetSColumnName (SColumn)
GetSColumnName

Gets the name of the column anSColumn represents; the spatial column's name doesn't include the table name.

Syntax

anSColumn.GetSColumnName

Returns

String


GetTableName (SColumn)
GetTableName

Gets the name of the table containing the column anSColumn represents. The table's name has the format "<ownerName>.<tableName>" if you don't own the table.

Syntax

anSColumn.GetTableName

Returns

String


ReturnExtent (SColumn)
ReturnExtent

If anSQLWhereClause is a null string, it selects all the shapes in anSColumn, and the rectangle returned represents the coordinate boundary of anSColumn; all coordinates in all shapes in anSColumn must fall inside this rectangle. If anSQLWhereClause selects specific shapes by their attribute values, the rectangle returned represents the smallest rectangle containing all the selected shapes. Otherwise, returns a nil object.

Syntax

anSColumn.ReturnExtent (anSQLWhereClause)

Returns

Rect


ReturnStatistics (SColumn)
ReturnStatistics

Returns a list of statistics for the shapes in anSColumn.

Syntax

anSColumn.ReturnStatistics

Returns

List


FreeLock (SColumn)
FreeLock

Removes your locks on anSColumn, and returns TRUE; otherwise, returns FALSE.

Syntax

anSColumn.FreeLock

Returns

Boolean


LockAll (SColumn)
LockAll

Locks all records in anSColumn's table that have shape values, and returns TRUE; otherwise, returns FALSE.

If canModify is TRUE, you can change the data in the locked records, but no one else can. Can-Modify locks can't overlap other locks. If canModify is FALSE, no one can change the data in the locked records. Can't-modify locks can overlap other can't-modify locks. Locks don't prevent others from reading data.

Syntax

anSColumn.LockAll (canModify)

Returns

Boolean


LockArea (SColumn)
LockArea

Locks all records in anSColumn's table whose shapes intersect aRectangle, and returns TRUE; otherwise, returns FALSE.

If canModify is TRUE, you can change the data in the locked records, but no one else can. Can-Modify locks can't overlap other locks. If canModify is FALSE, no one can change the data in the locked records. Can't-modify locks can overlap with other can't-modify locks. Locks don't prevent others from reading data.

Syntax

anSColumn.LockArea (aRectangle, canModify)

Returns

Boolean


Clone (SColumn)
Clone

Creates a new aSColumn object representing the same spatial column in the database; it is associated with the same Connection object as anSColumn.

Syntax

anSColumn.Clone

Returns

SColumn


AddSDEDBThemeDialog

 AddSDEDBThemeDialog is used to show a modal dialog on the screen in which the user can enter a server name, dataset name, and choose a layer. This information is used to create a DBTheme.

Inherits From

ModalDialog

Required Extension

     Database Access

Class Requests

Showing the AddDBThemeDialog

Show  :  List

__________

See also

DBTheme


Show (AddSDEDBThemeDialog)
Show

Shows the Add SDE DBTheme dialog box. Returns a list of new DBTheme based on the server name, dataset name, and layer names chosen by the user. If the user cancels, returns empty list.

Syntax

AddSDEDBThemeDialog.Show

Returns

List


SDEConnection

 An SDEConnection object controls network communication between ArcView and an SDE database. SDE lets you store spatial data in a relational database.

Using an SDEConnection you can add and delete tables from the database; you can check errors generated by SDE or the relational database while using SDE-based objects; and in addition to general transaction support, you can set your transactions to commit changes at regular intervals without having to start a new transaction.

Attributes

DataReferenceName.The DataReferenceName is an parameter required when making a Connection to SDE servers using RDBMSs which organize associated tables into a database. When connecting to an SDE server that uses an Oracle or DB2 RDBMS, the DataReferenceName is a null string, "".

When connecting to an SDE server that uses SYBASE, the DataReferenceName is the name of the database containing the tables you want to access. When connecting to an SDE server that uses SQL Server, the DataReferenceName is a Data Source Name created by the SDE administrator in the database. The difference exists because SDE communicates with SQL Server using ODBC. Each Data Source Name must have a default database; after making an SDEConnection, you can access the the tables stored in the default database.

For SYBASE and SQL Server, you can also Make an SDEConnection by specifying a null string for the DataReferenceName. Before creating other objects, set the connection's database with the SetDatabase request. This gives you an opportunity to choose a database name from a list created with GetAllDatabaseNames, or to connect to an SQL Server database that isn't associated with a Data Source Name.

You can only set a connection's database once either when you Make an SDEConnection or using the SetDatabase request after you Make an SDEConnection with an empty DataReferenceName. To access a second database of tables, you must make a second SDEConnection.

Inherits From

Connection

Enumerations

SDERdbmsEnum

SDEErrorEnum

Required Extension

     Database Access

Class Requests

Making an SDEConnection

GetAllConnections  :  List

Make ( aConnectionString, aDataReferenceName, aUserName, aPassword ) :  SDEConnection

MakeWithDialog  :  SDEConnection

ReturnConnectionType  :  String

Instance Requests

Getting Attributes

GetAllDatabaseNames  :  List

GetAllSColumnNames  :  List

GetAllTableNames ( aTablePrivilegeEnum, OwnerName ) :  List

GetRDBMS  :  SDERdbmsEnum

GetVersion  :  String

SetDatabase ( aDatabaseName ) :  Boolean

Manipulating Transactions

BeginTrans  :  Boolean

CommitContinue  :  Boolean

CommitTrans  :  Boolean

FreeAllLocks  :  Boolean

Rollback  :  Boolean

SetAutoCommitFreq ( aNumber ) :  Boolean

Manipulating a Connection

Close

Open  :  Boolean

Manipulating the Database

CreateTable ( aNewSDETable ) :  Boolean

DeleteTable ( anSDETable ) :  Boolean

TruncateTable ( anSDETable ) :  Boolean

Error Handling

GetDBErrorCode  :  Number

GetDBErrorMsg  :  String

GetErrorCode  :  SDEErrorEnum

GetErrorMsg  :  String

__________

See also

SDEQueryDef
SDERecordSet
SDESColumn
SDESFilter
SDETable
SDELog
DBTheme
DBTable


GetAllConnections (SDEConnection)
GetAllConnections

Return a list of all the SDEConnection objects that are open.

Syntax

SDEConnect.GetAllConnections

Returns

List


Make (SDEConnection)
Make
Example

 Establishes a network connection between ArcView and the remote database specified by aConnectionString. aUserName and aPassword are your user name and password for logging into the SDE database.

aConnectionString is a string identifying which SDE server, and which SDE database instance on that server you want to connect to. The format is <server>:<instance>. The ":<instance>" portion of the string is optional if you are connecting to an instance that uses the default name, "esri_sde", or if you've set the environment variable SDEINSTANCE to contain the instance name.

The value of aDataReferenceName depends on which Relational Database Management System is being used to store your data. For Oracle and DB2, aDataReferenceName is a null string, "". For Sybase, aDataReferenceName is the name of the database containing the tables you want to access. For SQL Server, aDataReferenceName is a Data Source Name. For more discussion about the value of aDataReferenceName, see the discussion under the SDEConnection class description.

Syntax

SDEConnection.Make (aConnectionString, aDataReferenceName, aUserName, aPassword)

Returns

SDEConnection


MakeWithDialog (SDEConnection)
MakeWithDialog

Establishes a network connection between ArcView and the remote database specified by parameters entered by the user on a dialog box.

Syntax

SDEConnection.MakeWithDialog

Returns

SDEConnection


ReturnConnectionType (SDEConnection)
ReturnConnectionType

Returns a string containing the name of the connection type, i.e. "SDE".

Syntax

SDEConnection.ReturnConnectionType

Returns

String


GetAllDatabaseNames (SDEConnection)
GetAllDatabaseNames

Returns a list of names for all the databases you can access with anSDEConnection.

Syntax

anSDEConnection.GetAllDatabaseNames

Returns

List


GetAllSColumnNames (SDEConnection)
GetAllSColumnNames

Each spatial column is owned by a user. This request returns a list of names for all the spatial columns, owned by all the users, that you can select shapes from using anSDEConnection. Returns an empty list if you can't select shapes from any spatial columns with anSDEConnection.

If you own a spatial column, its name is returned as "<tableName>.<scolumnName>". If you don't own a spatial column, its name is returned as "<ownerName>.<tableName>.<scolumnName>".

Syntax

anSDEConnection.GetAllSColumnNames

Returns

List


GetAllTableNames (SDEConnection)
GetAllTableNames

 Each table is owned by a user. This request returns a list of names for all the tables, owned by the user OwnerName, that you can access using anSDEConnection, and for which you have the privileges defined by aTablePrivilegeEnum. Returns an empty list if you don't have the defined privileges for any tables owned by OwnerName. You can query all the tables owned by all the users by providing the OwnerName "*".

Table names are returned in the format "<ownerName>.<tableName>". Each user can have different privileges for each table in the database; one user may be able to select data only from some tables, while another user can select data from all tables and edit some of them.

Syntax

anSDEConnection.GetAllTableNames (aTablePrivilegeEnum, OwnerName)

Returns

List


GetRDBMS (SDEConnection)
GetRDBMS

Returns an enumeration indicating which Relational Database Managment System (RDBMS) is being used to store your SDE data.

Syntax

anSDEConnection.GetRDBMS

Returns

SDERdbmsEnum


GetVersion (SDEConnection)
GetVersion

Returns the SDE version string, in Major.Minor format, for example, "3.0"; otherwise, returns an empty string.

Syntax

anSDEConnection.GetVersion

Returns

String


SetDatabase (SDEConnection)
SetDatabase

Sets the database of tables which can be accessed with this connection to aDatabaseName. This request is only appropriate for connections to SDE servers that use SYBASE or SQL Server relational databases.

Setting a connection's database can only be performed once on a connection either when you Make anSDEConnection or using the SetDatabase request after you Make anSDEConnection with an empty DataReferenceName. See the description for DataReferenceName in the SDEConnection class help' for more details.

Syntax

anSDEConnection.SetDatabase (aDatabaseName)

Returns

Boolean


BeginTrans (SDEConnection)
BeginTrans
Example

Starts a transaction on anSDEConnection, and returns TRUE; otherwise returns FALSE. You can only have one transaction on anSDEConnection at a time. Transactions that are still active at the end of an ArcView session will be closed, and changes made to the database will be committed.

Syntax

anSDEConnection.BeginTrans

Returns

Boolean


CommitContinue (SDEConnection)
CommitContinue

Commits all outstanding changes made to the database, but doesn't close the transaction. If all changes are committed successfully, returns TRUE; otherwise returns FALSE.

Syntax

anSDEConnection.CommitContinue

Returns

Boolean


CommitTrans (SDEConnection)
CommitTrans
Example

Commits all changes made to the database since the transaction was started, then closes the transaction. If all changes are committed successfully, returns TRUE; otherwise returns FALSE.

Syntax

anSDEConnection.CommitTrans

Returns

Boolean


FreeAllLocks (SDEConnection)
FreeAllLocks

Removes all of your locks from all the spatial columns in anSDEConnection, and returns TRUE; otherwise returns FALSE.

Syntax

anSDEConnection.FreeAllLocks

Returns

Boolean


Rollback (SDEConnection)
Rollback
Example

Returns the database to the state it was in when you started the transaction. All changes made to the database since the transaction was started are eliminated, then the transaction is closed. If all changes are rolled back successfully, returns TRUE; otherwise returns FALSE.

Syntax

anSDEConnection.Rollback

Returns

Boolean


SetAutoCommitFreq (SDEConnection)
SetAutoCommitFreq

Automatically commits all outstanding changes made to the database after using the Update request aNumber of times, but doesn't close the transaction. Use this request when adding or updating a large number of records in the database. Use this request BEFORE starting a transaction.

Syntax

anSDEConnection.SetAutoCommitFreq (aNumber)

Returns

Boolean


Close (SDEConnection)
Close

Closes the network connection between ArcView and a remote database. Closing anSDEConnection frees the SDE client license used to create it.

Syntax

anSDEConnection.Close


Open (SDEConnection)
Open

Re-establishes a network connection between ArcView and the remote database identified by anSDEConnection. Returns TRUE if the network connection is successfully established; otherwise returns FALSE.

Use this request on an existing SDEConnection object that was closed with the Close request, or on connections that were not successfully activated when you opened a project.

Syntax

anSDEConnection.Open

Returns

Boolean


CreateTable (SDEConnection)
CreateTable
Example

Creates a new table in the database representing aNewSDETable, an SDETable object created with the MakeNew request, and returns TRUE; otherwise returns FALSE.

After using this request you won't be able to use the aNewSDETable object to perform operations; it isn't associated with a connection object. You need to create another SDETable object with the SDETable.Make request that references the table as it exists in the database.

To store spatial data in this table, you need to use the SDESColumn.MakeNew and SDETable.CreateSColumn requests after successfully storing this table in the database.

Syntax

anSDEConnection.CreateTable (aNewSDETable)

Returns

Boolean


DeleteTable (SDEConnection)
DeleteTable
Example

Deletes the table in the database represented by anSDETable object and returns TRUE; otherwise returns FALSE. Deleting a table removes all of its records and its definition from the database; any spatial columns associated with this table will also be deleted.

Syntax

anSDEConnection.DeleteTable (anSDETable)

Returns

Boolean


TruncateTable (SDEConnection)
TruncateTable

Truncates the table in the database represented by anSDETable object and returns TRUE; otherwise returns FALSE. Truncating a table removes all of its records from the database, but the table's definition remains intact; any spatial columns associated with this table will remain, but any shapes in it will be deleted.

Syntax

anSDEConnection.TruncateTable (anSDETable)

Returns

Boolean


GetDBErrorCode (SDEConnection)
GetDBErrorCode

Returns the error code generated by the relational database when the previous request failed. Only retrieve the database's error code when the SDE error code is #SDEERR_DB_IOERROR.

Syntax

anSDEConnection.GetDBErrorCode

Returns

Number


GetDBErrorMsg (SDEConnection)
GetDBErrorMsg

Returns a brief error message associated with the error generated by the relational database when the previous request failed. Only retrieve the database's error message when the SDE error message is "Database I/O error". The error message should briefly explain what the error code means; it won't be the full message you receive when working directly with the database.

Syntax

anSDEConnection.GetDBErrorMsg

Returns

String


GetErrorCode (SDEConnection)
GetErrorCode
Example

Returns an error enumeration generated by SDE identifying why the last request failed.

Most requests return a value indicating whether or not they were successful. You should always check this value first, and IF the request failed, THEN use the GetErrorCode request to find out why. SDE only generates an error code if a request fails; SDE does nothing if a request is successful. If a request succeeds but you use the GetErrorCode request anyway, the the resulting error is meaningless; it is an old error generated by the last failed request.

Syntax

anSDEConnection.GetErrorCode

Returns

SDEErrorEnum


GetErrorMsg (SDEConnection)
GetErrorMsg
Example

Returns the error message associated with the error code generated by SDE when the previous request failed. The error message should briefly explain what the error code means.

Syntax

anSDEConnection.GetErrorMsg

Returns

String


SDERdbmsEnum

 The following enumeration defines which Relational Database Management System (RDMBS) is being used to store your SDE data.

#SDE_RDBMS_ORACLE

The underlying DBMS is Oracle.

#SDE_RDBMS_INFORMIX

The underlying DBMS is Informix.

#SDE_RDBMS_SYBASE

The underlying DBMS is Sybase.

#SDE_RDBMS_DB2

The underlying DBMS is DB2.

#SDE_RDBMS_SQLSERVER

The underlying DBMS is SQL Server.

#SDE_RDBMS_ARCINFO

The underlying DBMS is ARC/INFO.

#SDE_RDBMS_IUS

The underlying DBMS is Informix Universal Server.

#SDE_RDBMS_DB2EXTENDER

The underlying DBMS is DB2 Spatial Extender.

#SDE_RDBMS_UNKNOWN

The underlying DBMS is unknown.


SDEErrorEnum

 The following enumeration lists SDE's error codes.

#SDEERR_SUCCESS

This error message doesn't mean that the request was successful, it means that an error message hasn't yet been generated on the SDE server during this ArcView session.

#SDEERR_FAILURE

A general SDE system failure. Returned whenever the error is not trapped by a more specific indicator.

#SDEERR_INVALID_LAYERINFO

The pointer to SE_LAYERINFO is not initialized.

#SDEERR_NO_ANNO

The given shape has no annotation.

#SDEERR_QUERY_DONE

The current shape stream has finished successfully. If this code is returned from a shape stream initiation call, no shapes were found.

#SDEERR_SDE_NOTSTARTED

The call to start the SDE was not executed or did not complete successfully. The SDE must be started before calling the function that returned this code.

#SDEERR_FEATURE_UNCHANGED

The specified shape was unchanged. If a shape modification function cannot correctly modify a shape, for whatever reason, it returns this code.

#SDEERR_TOOMANY_TASKS

The number of allowed server tasks was exceeded and no more logins to the SDE are allowed until a task completes. Returned by the SE_connection_create call only.

#SDEERR_LOGIN_REFUSED

The SDE I/O connection manager task has discontinued logins. No more logins to the SDE are allowed until an administrator changes the login mode. Returned by the SE_connection_create call only.

#SDEERR_INVALID_USER

The user attempting to access the SDE does not have a valid login account on the SDE host machine. Returned by the SE_connection_create call only.

#SDEERR_NET_FAILURE

A catastrophic error occurred during a client/server round-trip request and the connection between the client task and the server was severed. Almost any call that makes a round-trip request to the SDE server task can return this code.

#SDEERR_NET_TIMEOUT

Returned when the application that made the call cannot bind itself to the associated server task. Returned by the SE_connection_create call only.

#SDEERR_OUTOF_SERVERMEM

The function failed to complete because the server process was unable to allocate the memory needed to perform the function.

#SDEERR_OUTOF_CLIENTMEM

The function failed to complete because the client could not allocate enough dynamic memory to complete the task.

#SDEERR_OUTOF_CONTEXT

The call is somehow out of context or inappropriate. Under certain circumstances, some functions are illegal and are not allowed.

#SDEERR_NO_ACCESS

The caller does not have access to the specified object.

#SDEERR_TOOMANY_LAYERS

Exceeded the maximum number of allowed layers as defined in giomgr.defs.

#SDEERR_NO_LAYER_SPECIFIED

The required layer specification is missing.

#SDEERR_LAYER_LOCKED

Returned from the layer-locking routines when the specified layer is already locked.

#SDEERR_LAYER_EXISTS

Returned from the layer creation function when the specified map layer already exists.

#SDEERR_LAYER_NOTEXIST

The user-specified map layer does not exist.

#SDEERR_LAYER_INUSE

The function was prevented from performing its task because another user is using the layer.

#SDEERR_ID_NOTEXIST

The shape identifier does not exist in the specified map layer. Returned by shape retrieval functions.

#SDEERR_ID_EXISTS

An operation attempted to insert a shape with a previously existing identifier.

#SDEERR_LAYER_MISMATCH

For this operation, both layers must be the same.

#SDEERR_NO_PRIVILEGES

The caller does not have database permissions to perform the operation or function.

#SDEERR_INVALID_NOTNULL

The specified column has a 'NOT NULL' constraint.

#SDEERR_INVALID_SHAPE

Returned when a shape cannot be verified as valid.

#SDEERR_INVALID_LAYERID

The map layer number is outside the allowable range.

#SDEERR_INVALID_ENTITY

A shape entity type is invalid or not allowed for the operation or function.

#SDEERR_INVALID_SEARCHMETHOD

The specified search method is not one of those defined.

#SDEERR_INVALID_ENTITY_MASK

The entity types or combinations in the entity type mask are invalid. Returned from the map layer creation routine.

#SDEERR_BIND_CONFLICT

A mismatch occurred in one of the bind/set/get functions.

#SDEERR_INVALID_GRIDSIZE

One of the specified grid sizes is either too small or too large. Returned from the map layer creation routine.

#SDEERR_INVALID_LOCKMODE

The lock mode specified is not one of those supported.

#SDEERR_ENTITY_NOTALLOWED

The entity type of the shape is not one of the types allowed by the map layer definition. Returned from the store and replace shape routines.

#SDEERR_TOOMANY_POINTS

There are more points than allowed by the specified maximum points.

#SDEERR_TABLE_NOTEXIST

The specified DBMS table does not exist.

#SDEERR_ATTRIB_NOTEXIST

Returned from functions that attempt to access a column that does not exist. Sometimes returned after misspelling the name of the column.

#SDEERR_LICENSE_FAIL

A problem exists with the license manager.

#SDEERR_OUTOF_LICENSE

All SDE licenses are in use.

#SDEERR_INVALID_COLUMN_VALUE

The specified value exceeds the valid range for the column.

#SDEERR_INVALID_SQL

The user-specified SQL where clause is invalid. In most cases, returned because of syntax problems in the SQL string.

#SDEERR_LOG_NOTEXIST

The named logfile does not exist.

#SDEERR_LOG_NOACCESS

The caller does not have permission to access the specified logfile.

#SDEERR_LOG_NOTOPEN

Returned from logfile I/O functions when the specified logfile handle is not open.

#SDEERR_LOG_IOERROR

A logfile I/O operation resulted in an error. The caller can check the extended error code to get the 'errno' value.

#SDEERR_NO_SHAPES

The function found no shapes to process. Usually returned because an empty logfile was specified.

#SDEERR_NO_LOCKS

No locks were found for the specified map layer. The caller may have specified lock modifications for a layer that does not have any locks defined.

#SDEERR_LOCK_CONFLICT

The lock request was not granted because the request conflicted with another user's lock.

#SDEERR_OUTOF_LOCKS

No more locks can be granted because all system lock resources are being used. Also returned from functions that automatically impose locks to complete their tasks.

#SDEERR_DB_IOERROR

A database-level I/O error occurred. You can call the extended error code immediately after this code is returned to inquire about the specific database error code.

#SDEERR_QUERY_IN_PROGRESS

The function cannot be executed during a stream shape retrieval. Close the stream before calling this function.

#SDEERR_INVALID_COLUMN_TYPE

The user specified an invalid data type for a column definition.

#SDEERR_TOPO_ERROR

At least one of the shapes processed by the function violated one of the topological integrity rules. Returned from functions that to complete successfully require the topological integrity of shapes.

#SDEERR_ATTRIB_CONVERT_ERROR

Returned from the attribute mask function when an unsupported DBMS data type is encountered.

#SDEERR_INVALID_COLUMN_DEFINITION

The user specified an invalid column definition. For example, the user specifies a size of -1 for a column.

#SDEERR_INVALID_EXTENT

An invalid envelope was specified. Returned when the envelope is NULL, has negative values, or a minimum value is larger than a maximum value.

#SDEERR_TEMP_IOERROR

Returned from functions that use temporary system files to perform their tasks. Indicates temporary file permission problems, inadequate disk space, or general temporary file I/O error conditions.

#SDEERR_GRIDSIZE_TOOSMALL

Storing the shape would create too many grid records which suggests that the grid size for the target map layer is too small. Returned from functions that store or replace shapes.

#SDEERR_LICENSE_EXPIRED

The run-time license for the SDE on the specified server has expired. See the system administrator to update the SDE license. Returned from the SE_connection_create function only.

#SDEERR_TABLE_EXISTS

Returned from the table creation function when the specified database table already exists.

#SDEERR_INDEX_EXISTS

Returned from the attribute index creation functions when an attribute index already exists.

#SDEERR_INDEX_NOTEXIST

The specified index does not exist.

#SDEERR_INVALID_POINTER

Returned by functions that are passed pointers to data that are either NULL or invalid.

#SDEERR_INVALID_PARAMETER

Returned from a function that was given an invalid parameter value. The function is unable to continue.

#SDEERR_ALL_SLIVERS

Returned by an overlay function that reduces all shapes to slivers, yielding no results. In most cases, you can adjust the sliver factor to fix this problem.

#SDEERR_TRANS_IN_PROGRESS

A user-initiated transaction is currently in progress. The operation cannot be performed until the transaction is committed or rolled back.

#SDEERR_SDE_LOST_RDBMS

The iomgr has lost its connection to the underlying DBMS.

#SDEERR_DUP_ARC

An attempt was made to store or replace a shape where the arc (startpt, midpt, endpt) already exists.

#SDEERR_INVALID_ANNO

The given annotation object handle is invalid.

#SDEERR_POINT_NOTEXIST

The user-specified point does not exist in the associated map shape.

#SDEERR_POINTS_NOT_ADJACENT

The two given points are not adjacent in the associated map shape.

#SDEERR_INVALID_MID_POINT

The point given as a midpoint along a path is invalid or does not exist.

#SDEERR_INVALID_END_POINT

The specified endpoint is invalid or cannot be located within the associated shape.

#SDEERR_INVALID_RADIUS

The given radius was too small to perform the operation.

#SDEERR_LOADONLY_LAYER

The operation cannot be performed because the specified map layer is in LOAD_ONLY mode.

#SDEERR_LAYERS_NOTFOUND

The LAYERS table does not exist.

#SDEERR_FILE_IOERROR

An error occurred when creating or writing to an output file.

#SDEERR_BLOBSIZE_TOOBIG

An attempt is made to store a BLOB that exceeds the maximum allowable size of the SDE server as specified by the MAXBLOBSIZE parameter of the giomgr.defs file.

#SDEERR_BUFFER_OUTOF_RANGE

The specified source shape and corridor distance would result in a corridor with coordinates that exceed the valid coordinate range.

#SDEERR_SHAPE_INTEGRITY_ERROR

Returned by low-level code indicating an error in the integrity of a shape.

#SDEERR_NOT_IMPLEMENTED

The specified function is not implemented yet but is intended for a future release.

#SDEERR_INVALID_TRANSID

The specified internal SDE Transaction ID is invalid.

#SDEERR_INVALID_LAYERNAME

The table name entered for the layer definition is invalid. Valid table names must not be NULL.

#SDEERR_INVALID_LAYERKEYWORD

The specified layer configuration keyword does not exist in the dbtune.sde configuration parameter file.

#SDEERR_INVALID_RELEASE

The release/version of the client application does not match the installed release/version of the SDE server, or the installed release/version of the SDE software does not match the release/version of the SDE datasets. If the datasets are older than the SDE server, you can update them with the admversion administration tool.

#SDEERR_VERSIONTABLE_EXISTS

The VERSION table exists when it should not. This error occurs when you attempt to upgrade a server and the VERSION table already exists.

#SDEERR_COLUMN_NOT_BOUND

A column was specified for an insert/update operation but was not bound (by calling SE_stream_bind_input_column), or the value was not set at the time of execution.

#SDEERR_INVALID_INDICATOR

Returned during the execution of an insert or update operation for a column that was bound by reference (by calling SE_stream_bind_input_column) and the value of the indicator variable was neither IS_NOT_NULL_VALUE nor IS_NULL_VALUE.

#SDEERR_INVALID_CONNECTION

An invalid or NULL SE_CONNECT connection handle was passed to an SDE function.

#SDEERR_INVALID_DBA_PASSWORD

An invalid DBA password was passed to an SDE function.

#SDEERR_PATH_NOTFOUND

The specified path was not found.

#SDEERR_SDEHOME_NOTSET

The SDEHOME variable is not set and is needed for this operation.

#SDEERR_NOT_TABLE_OWNER

The user must be the owner of the table.

#SDEERR_PROCESS_NOT_FOUND

The specified process ID does not correspond to an SDE server.

#SDEERR_INVALID_DBMS_LOGIN

The DBMS did not accept the username or password that was passed to an SDE function.

#SDEERR_PASSWORD_TIMEOUT

The timestamp of the password received was sent more than MAXTIMEDIFF seconds earlier.

#SDEERR_INVALID_SERVER

The server machine was not found.

#SDEERR_IOMANAGER_NOTAVAILABLE

The I/O manager is not started. Log in as the SDE administrator and use the sdemon administration tool to determine the status of the I/O manager.

#SDEERR_SERVICE_NOTFOUND

SDE was unable to locate the appropriate entry in the /etc/services file. See your SDE system administrator.

#SDEERR_INVALID_STATISTICS

Tried statistics on a nonnumeric column.

#SDEERR_INVALID_UNIQUE_TYPE

Tried distinct statistics on an invalid type.

#SDEERR_INVALID_GRANT_REVOKE

Invalid use of the grant/revoke functions.

#SDEERR_INVALID_SDEHOME

The supplied SDEHOME path is invalid or NULL.

#SDEERR_INVALID_STREAM

An invalid stream (SE_STREAM) handle was detected.

#SDEERR_TOOMANY_STREAMS

An attempt was made to create a stream, but the connection already has the maximum number of streams specified by the giomgr.defs parameter MAXSTREAMS.

#SDEERR_OUTOF_MUTEXES

Exceeded system's maximum number of mutexes. Involved in concurrency issues.

#SDEERR_CONNECTION_LOCKED

The connection is locked to a different thread.

#SDEERR_CONNECTION_INUSE

This connection is being used currently by another thread.

#SDEERR_NOT_SELECT_STATEMENT

Returned when trying to describe a prepared SQL statement that was not a query.

#SDEERR_FUNCTION_SEQ_ERROR

A function was called out of sequence. For example, SE_stream_fetch was called before executing the stream with SE_stream_execute.

#SDEERR_WRONG_COL_TYPE

Returned when trying to set or get the value of a column in a stream using the wrong column type. For example, calling SE_stream_get_integer on a column that is an SE_FLOAT.

#SDEERR_PTABLE_LOCKED

The specified point table is locked to a different thread.

#SDEERR_PTABLE_INUSE

The point table is being used at the moment by another thread.

#SDEERR_STABLE_LOCKED

The specified shape table is locked to a different thread.

#SDEERR_STABLE_INUSE

The shape table is being used at the moment by another thread.

#SDEERR_INVALID_FILTER_TYPE

An invalid value is specified in the filter_type field of the SE_FILTER structure.

#SDEERR_INSTANCE_NOTAVAILABLE

No instance is running on the specified server.

#SDEERR_INSTANCE_TOO_EARLY

The specified instance is a version older than 2.0.

#SDEERR_INVALID_RESOLUTION

The specified systems units were < 1 or > 2147483647.

#SDEERR_INVALID_UNITS

The specified units were not feet, meters, decimal_degrees or other.

#SDEERR_INVALID_NUM_POINTS

The SE_CAD pointer is not initialized.

#SDEERR_INVALID_SPATIAL_CONSTRAINT

A set of spatial filters is supplied to SE_stream_set_spatial_constraints with an SE_SPATIAL_FIRST search order, but all the filters have their truth set to FALSE. This prevents SDE from using its spatial index.

#SDEERR_INVALID_STREAM_TYPE

A stream function is called that is not applicable to the given stream. For example, a call to SE_stream_set_integer on a query_layer stream.

#SDEERR_INVALID_SPATIAL_COLUMN

The specified column contained NOT NULL values during SE_layer_create.

#SDEERR_NO_SPATIAL_CONSTRAINTS

SE_stream_get_spatial_masks was called on a query stream with no spatial masks.

#SDEERR_IOMGR_NOT_FOUND

The iomgr program was not found.

#SDEERR_SYSTEM_CLIENT_ONLY

The specified operation must be run on the server.

#SDEERR_MULTIPLE_SPATIAL_COLUMNS

Only one spatial column is allowed for this operation.

#SDEERR_INVALID_SHAPE_OBJECT

The given shape object handle is invalid.

#SDEERR_INVALID_PART_NUMBER

The specified shape part number does not exist.

#SDEERR_INCOMPATABLE_SHAPES

The given shapes are of incompatible types.

#SDEERR_INVALID_PART_OFFSET

The specified part offset is invalid.

#SDEERR_INCOMPATABLE_COORDREF

The given coordinate reference systems are incompatible.

#SDEERR_COORD_OUTOF_BOUNDS

The specified coordinate exceeds the valid coordinate range.

#SDEERR_LAYER_CACHE_FULL

The maximum number of layers was exceeded in the cache.

#SDEERR_INVALID_COORDREF

The given coordinate reference object handle is invalid.

#SDEERR_INVALID_COORDSYS_ID

The coordinate system identifier is invalid.

#SDEERR_INVALID_COORDSYS_DESC

The coordinate system description is invalid.

#SDEERR_INVALID_ROWID_LAYER

The SE_ROW_ID owner.table does not match the specified layer.

#SDEERR_PROJECTION_ERROR

An error occurred while projecting the shape.

#SDEERR_ARRAY_EXCEEDED

The value of the max_array_size set in SE_STREAM_SPEC is larger than the MAXARRAYBYTES value in the giomgr.defs file.

#SDEERR_POLY_SHELLS_OVERLAP

Two donuts or two outer shells of a polygon overlap.

#SDEERR_SHAPE_TOO_FEW_POINTS

The number of points is less than the number required for a shape.

#SDEERR_INVALID_PART_SEPARATOR

A part separator is in the wrong position.

#SDEERR_INVALID_POLYGON_CLOSURE

The polygon does not close properly.

#SDEERR_INVALID_OUTER_SHELL

The polygon outer shell does not completely enclose all the donuts in a part of the shape.

#SDEERR_POLYGON_ZERO_AREA

The polygon shell has no area.

#SDEERR_POLYGON_HAS_VERTICAL_LINE

The area shape contains a vertical line.

#SDEERR_OUTER_SHELLS_OVERLAP

The multipart area shape has overlapping parts.

#SDEERR_SELF_INTERSECT

A simple line or polygon boundary intersects itself.

#SDEERR_INVALID_EXPORT_FILE

The specified export file is invalid.

#SDEERR_SHAPE_READ_ONLY

Attempted to modify or free a read-only shape from a shape table.

#SDEERR_INVALID_DATA_SOURCE

The specified data source is invalid.

#SDEERR_INVALID_STREAM_SPEC

A stream specification parameter exceeds the giomgr.defs defaults.

#SDEERR_INVALID_OPERATION

An attemp was made to alter a layer in an illegal manner. For example, if a layer allows annotations, you can't change the layer to disallow them.

#SDEERR_INVALID_SPATIAL_COL_NAME

The specified spatial column name is the same as the table name. Returned by SE_layerinfo_set_spatial_column.

#SDEERR_INVALID_DATABASE

The specified database (or data source) is invalid. Returned by SE_connection_create.

#SDEERR_SPATIAL_SQL_NOT_INSTALLED

Spatial SQL extension is not present in the underlying DBMS.

#SDEERR_NORM_DIM_INFO_NOT_FOUND

The dimension parameters for an SDO table were not found in the dbtune.sde file. Add the parameters to the ##DEFAULTS or another keyword's section before trying to recreate the SDO layer.

#SDEERR_NORM_DIM_TAB_VALUE_NOT_FOUND

The dimension parameters in the SDODIM table for an SDO table were not found or are corrupted.

#SDEERR_UNSUPPORTED_NORMALIZED_OPERATION

Current operation is not supported for NORMALIZED LAYERS.

#SDEERR_INVALID_REGISTERED_LAYER_OPTION

Returned if an SDO layer is registered in the SDE LAYERS table, but wasn't created by the SDE software. Usually returned when trying to change a layer between n ormal and load-only modes.

#SDEERR_SDE_WARNING

Returned by functions that completed successfully but made changes of which the caller needs to be aware. This return code should not be considered a fatal error by the application.

#SDEERR_NULL_VALUE

Returned by the SE_stream_get_<data_type> functions when the given column has a NULL value in the current row.

#SDEERR_NO_ROWS_UPDATED

Returned during an updata operation when no rows satisfied the user's where clause.

#SDEERR_NO_CPGCVT

No codepage conversion.

#SDEERR_NO_CPGHOME

Cannot find the codepage directory.

#SDEERR_DBMS_NOT_SUPPORTED

The DBMS doesn't support this function.

#SDEERR_NOT_APPLICABLE

Request cannot be performed on the current object. Request is being ignored.

#SDEERR_WRONG_LOGNAME

Logfile name already exists or a non empty string should be provided.

#SDEERR_WRONG_SHAPETYPE

The feature object that the user is trying to write is of the wrong type or invalid.

#SDEERR_WRONG_DATATYPE

The data object that the user is trying to write to the database is of the wrong type.

#SDEERR_UPDATE_STREAM_CLOSED

The update stream for this record set has been closed.

#SDEERR_CANT_READ_BLOB

The filename specified for the blob cannot be opened or read.


SDEConnectionWindow

 SDEConnectionWindow is used to show a modal dialog on the screen in which the user can create or pick a SDE connection.

Inherits From

ModalDialog

Required Extension

     Database Access


SDELog

 An SDELog is a collection of shapes from a single spatial column. For example, a database theme's selected set of features. An SDELog actually represents an SDE logfile stored on the SDE server. The logfile contains SDE's internal ID number for each shape in the collection.

You can retrieve the records whose shapes are stored in an SDELog by an SDEQueryDef's source to an SDELog. Similarly, if you set an SDEQueryDef's destination, you can record the shape in each record retrieved by the query. You must build the SDEQueryDef using the SetSelectColumns, SetFromTables, and SetWhereClause requests.

Attributes

Extent.The Extent is the smallest rectangle containing all the features in an SDELog.

Temporary.An SDELog's logfile can be either a permanent or a temporary file on the SDE server. By default, the logfiles created by you and by ArcView are temporary.

Inherits From

Obj

Enumerations

SDELogModeEnum

SDELogCombineTypeEnum

Required Extension

     Database Access

Class Requests

Creating and Deleting an SDELog

Copy ( anSDEConnection, aSourceLogName, anOutputLogName ) :  Boolean

Delete ( anSDECOnnection, aLogName ) :  Boolean

Make ( anSDEConnection, aLogName, aTableName, theOpenModeEnum ) :  SDELog

MakeLogName ( anSDEConnection ) :  String

Instance Requests

Getting and Setting Attributes

Count  :  Number

GetName  :  String

GetTableName  :  String

ReturnExtent  :  Rect

Manipulating an SDELog

AddFeature ( aShapeID ) :  Boolean

AddFeatures ( shapeIDList ) :  Boolean

ChangeType ( isTemporary ) :  Boolean

Close  :  Boolean

Combine ( aLogName, aCombineType ) :  Boolean

Sort  :  Number

__________

See also

SDEConnection
SDEQueryDef
SDERecordSet
SDESColumn
SDESFilter
SDETable
DBTheme


Copy (SDELog)
Copy

Creates a new logfile named anOutputLogName that is a copy of the logfile named aSourceLogName, and returns TRUE; otherwise returns FALSE.

Syntax

SDELog.Copy (anSDEConnection, aSourceLogName, anOutputLogName)

Returns

Boolean


Delete (SDELog)
Delete

Deletes the logfile named aLogName from the SDE server, and returns TRUE; otherwise returns FALSE. If you do not explicitly close a logfile before deleting it, an SDELog object referencing the deleted file could still exist after executing this request.

Syntax

SDELog.Delete (anSDECOnnection, aLogName)

Returns

Boolean


Make (SDELog)
Make
Example

 Makes an SDELog object representing the logfile named aLogName; otherwise returns a nil object. If a logfile does not already exist with the name aLogName, a new logfile will be created. By default, new logfiles are temporary. theOpenModeEnum defines whether you can read shapes from or write shapes to the logfile represented by the SDELog object, and how existing data in an old logfile is handled if you can write to it.

Syntax

SDELog.Make (anSDEConnection, aLogName, aTableName, theOpenModeEnum)

Returns

SDELog


MakeLogName (SDELog)
MakeLogName
Example

Returns a string that is guaranteed to be a unique logfile name. Use this request to create names for new, temporary logfiles.

Syntax

SDELog.MakeLogName (anSDEConnection)

Returns

String


Count (SDELog)
Count

Returns the number of shapes in anSDELog; otherwise returns a negative number. If a shape has been added to anSDELog more than once, the shape will have duplicate entries in the logfile, and this request will not return an accurate number; use the Sort request instead.

Syntax

anSDELog.Count

Returns

Number


GetName (SDELog)
GetName

Gets the name of the logfile.

Syntax

anSDELog.GetName

Returns

String


GetTableName (SDELog)
GetTableName

Returns the name of the table containing the spatial column that contains the shapes that are or can be recorded in anSDELog. The table name has the format "<ownerName>.<tableName>".

Syntax

anSDELog.GetTableName

Returns

String


ReturnExtent (SDELog)
ReturnExtent
Example

Returns the smallest rectangle enclosing all the shapes in anSDELog; otherwise returns a nil object. The rectangle's coordinates always have the same units as the source data.

Syntax

anSDELog.ReturnExtent

Returns

Rect


AddFeature (SDELog)
AddFeature

You can add a shape to anSDELog by providing SDE's internal ID number for it. One way to get a shape's ID number is using the FindByPoint request.

Syntax

anSDELog.AddFeature (aShapeID)

Returns

Boolean


AddFeatures (SDELog)
AddFeatures

You can add many shapes to anSDELog at once by adding SDE's internal ID number for each shape to the list shapeIDList. You can get a list of shape ID numbers using the FindByPoint request.

Syntax

anSDELog.AddFeatures (shapeIDList)

Returns

Boolean


ChangeType (SDELog)
ChangeType

Changes whether the logfile referenced by anSDELog is a temporary or persistent file on the SDE server, and returns TRUE; otherwise returns FALSE. If isTemporary is TRUE, the logfile becomes a temporary; if isTemporary is FALSE, the logfile becomes persistent.

Syntax

anSDELog.ChangeType (isTemporary)

Returns

Boolean


Close (SDELog)
Close

Closes the logfile referenced by anSDELog, and returns TRUE; otherwise returns FALSE. Requests that read data from or write data to anSDELog open the logfile, perform the read or write operation, then close the logfile. If a request that reads or writes fails during execution, the logfile can remain open; close anSDELog before the next read or write operation, or your results will be incorrect.

Syntax

anSDELog.Close

Returns

Boolean


Combine (SDELog)
Combine
Example

Combines the collection of features in anSDELog with the collection of features in the logfile named aLogName according to the set operation aCombineType. Changes the collection of features in anSDELog as a result, and returns TRUE; otherwise returns FALSE.

Syntax

anSDELog.Combine (aLogName, aCombineType)

Returns

Boolean


Sort (SDELog)
Sort

Eliminates duplicate shape entries from anSDELog's logfile, and sorts the remaining entries by their shape ID numbers. Returns the total number of unique entries in the logfile; otherwise returns a negative number.

Syntax

anSDELog.Sort

Returns

Number


SDELogModeEnum

 The following enumeration defines how requests will handle the source SDE logfile after an SDELog is created.

#SDELOG_MODE_READ

 Opens an existing logfile with aLogName for reading SDEFeatures. Requests that try to write SDEFeatures to a read-only SDELog will fail.

#SDELOG_MODE_WRITE

 Opens a new or an existing logfile with aLogName for reading and writing SDEFeatures. If a logfile with aLogName already exists, writing new SDEFeatures to it will delete the previous collection of SDEFeatures.

#SDELOG_MODE_APPEND

 Opens a new or an existing logfile with aLogName for reading and writing SDEFeatures. If a logfile with aLogName already exists, any new SDEFeatures added will be appended to the previous collection of SDEFeatures.

#SDELOG_MODE_CREATE

 Opens a new logfile for reading and writing SDEFeatures. If a logfile with aLogName already exists, the request will fail.


SDELogCombineTypeEnum

 The following enumeration defines the set operations used to combine the collection of SDEFeatures in anSDELog and anotherSDELog, where anotherSDELog is the logfile referenced by aLogName.

#SDELOG_COMBINETYPE_INTERSECT

 Intersects the SDEFeatures in anSDELog and anotherSDELog. This is the logical operation AND.

#SDELOG_COMBINETYPE_UNION

 Unites the SDEFeatures in anSDELog and anotherSDELog. This is the logical operation OR.

#SDELOG_COMBINETYPE_DIFFERENCE

 Subtracts the SDEFeatures in anotherSDELog from anSDELog. This is the logical operation anSDELog AND (NOT anotherSDELog).

#SDELOG_COMBINETYPE_SYMDIFF

 Merges the SDEFeatures in anSDELog and anotherSDELog. This is the logical operation XOR.


SDEQueryDef

 An SDEQueryDef is a stored query that you can send to the database using an SDEConnection object.

You can send SQL statements to the database using methods described for the QueryDef class; however, you can't retrieve shapes from an SDE database using an SQL Select statement. To retrieve shapes, SDE requires that you build a query using a specific format that is similar to, but not the same as, a Select statment; you use the SetSelectColumns, SetFromTables, and SetWhereClause requests. You can't use these requests in combination with the SetSQL request. You can only create a database theme from an SDEQueryDef that can retrieve shapes.

If your query can retrieve shapes, it can use spatial criteria to select records from the database, and it can record the shapes retrieved in an SDE logfile; these functions use SDESFilter and SDELog objects, respectively.

Attributes

SFilters.SFilters is a list of SDESFilter objects defining spatial criteria for the query. The query will only retrieve records whose shapes satisfy the spatial criteria.

QueryOrder.QueryOrder defines the order your query's attribute and spatial criteria are evaluated in; the order can affect your query's performance. The criteria evaluated first should select the smallest percentage of records from the source tables. By default, the query order is optimized, where an SDE algorithm determines which order results in the best performance. Choose Attribute first or Spatial first instead if those criteria will consistently select approximately ten percent of the records in the source tables.

Inherits From

QueryDef

Enumerations

SDEQueryOrderEnum

Required Extension

     Database Access

Class Requests

Making an SDEQueryDef

Make ( anSDEConnection ) :  SDEQueryDef

Instance Requests

Getting and Setting Attributes

GetQueryOrder  :  SDEQueryOrderEnum

GetSFilters  :  List

ReturnStatistics ( aColumnName ) :  List

SetQueryOrder ( anSDEQueryOrderEnum )

SetSFilters ( aListOfFilters )

SetSrcDest ( theSource, theDestination, AVandLog )

Running a Query

Execute  :  Boolean

__________

See also

SDEConnection
SDERecordSet
SDESColumn
SDESFilter
SDETable
SDELog
DBTheme


Make (SDEQueryDef)
Make
Example

Creates an SDEQueryDef object that is associated with anSDEConnection; otherwise returns a nil object. Use this request only if anSDEConnection.HasError returns FALSE.

With the new QueryDef you can either create an SQL query using the SetSQL request, or you can create a spatial query using the SetSelectColumns, SetFromTables, and SetWhereClause requests. SQL queries are sent directly to the relational database; they aren't processed by SDE. Use the Execute request to send the database a query that doesn't select records; use the OpenRecordSet request to select records from the database.

Syntax

SDEQueryDef.Make (anSDEConnection)

Returns

SDEQueryDef


GetQueryOrder (SDEQueryDef)
GetQueryOrder

Returns one of the SDEQueryOrder enumerations, which define the order in which anSDEQueryDef's attribute and spatial criteria are evaluated in.

Syntax

anSDEQueryDef.GetQueryOrder

Returns

SDEQueryOrderEnum


GetSFilters (SDEQueryDef)
GetSFilters

Returns a list of SDESFilter objects, representing spatial criteria selecting the records you want to retrieve from the database. Otherwise, returns an empty list.

Syntax

anSDEQueryDef.GetSFilters

Returns

List


ReturnStatistics (SDEQueryDef)
ReturnStatistics

Returns a list of statistics for the column named aColumnName. These statistics apply to all the values in the column, excluding NULL values. To use this request you must have created your query using the SetSelectColumns, SetFromTables, and SetWhereClause requests.

If you created your query using the SetSQL request, you can retrieve statistics for the column by creating a new query whose SQL statement contains the SUM, COUNT, AVG, MAX, MIN, and STDDEV functions.

Syntax

anSDEQueryDef.ReturnStatistics (aColumnName)

Returns

List


SetQueryOrder (SDEQueryDef)
SetQueryOrder

anSDEQueryDef's attribute and spatial constraints will be evaluated in the order specified by anOrderEnum, one of the SDEQueryOrder enumerations.

The default order is OPTIMIZE, where the database determines if it will be more efficient to evaluate the attribute or spatial criteria first. You should change the order of evaluation for your query to ATTRIBUTEFIRST or SPATIALFIRST if the query's attribute or spatial criteria identify a very small percentage of the records in the query's source tables.

Syntax

anSDEQueryDef.SetQueryOrder (anSDEQueryOrderEnum)


SetSFilters (SDEQueryDef)
SetSFilters
Example

 anSDEQueryDef will retrieve records that are selected by the spatial criteria defined by aListOfFilters, which is a list of SDESFilter objects. You can only assign spatial criteria to an SDEQueryDef created with the SetSelectColumns, SetFromTables, and SetWhereClause requests.

One of the FromTables must contain the spatial column used by the spatial filters. If aListOfFilters contains more than one SDESFilter, their criteria are combined with the logical operator AND; for example, two circles overlap, and anSDEQueryDef has two SDESFilters (one for each circle). Each filter selects the records whose shapes intersect its circle. anSDEQueryDef will only retrieve records whose shapes satify one spatial filter AND another spatial filter, or the records whose shapes intersect the overlapping area.

Syntax

anSDEQueryDef.SetSFilters (aListOfFilters)


SetSrcDest (SDEQueryDef)
SetSrcDest
Example

 Sets the source and destination of anSDEQueryDef; you can only change these properties if the query was created with the SetSelectColumns, SetFromTables, and SetWhereClause requests, and if it retrieves shapes from a spatial column.

By default, when you create anSDEQueryDef theSource and theDestination are both set to nil objects. If this request sets theSource to anSDELog, anSDEQueryDef retrieves the records whose shapes are recorded in anSDELog's logfile. If this request sets theDestination to anotherSDELog, the shapes in the records retrieved by anSDEQueryDef will be recorded in anotherSDELog's logfile. You can remove anSDEQueryDef's association with any logfiles by setting theSource and theDestination back to nil objects afterwards. The value of AVandLog only matters when theDestination is an SDELog object.

If AVandLog is TRUE, when you use the Next request to retreive a record in a RecordSet opened from anSDEQueryDef, SDE stores that record's shape in the destination logfile. If AVandLog is FALSE, when you open a RecordSet from anSDEQueryDef, SDE stores all the selected shapes in the destination logfile and doesn't send any records to Arcview; you can't step through the selected records with the Next request. Storing shapes in a logfile is faster when AVandLog is FALSE.

Syntax

anSDEQueryDef.SetSrcDest (theSource, theDestination, AVandLog)


Execute (SDEQueryDef)
Execute

Executes anSDEQueryDef's SQL statement and returns TRUE if the statement was executed successfully in the database; otherwise returns FALSE. The query definition must be created using the SetSQL request, and it must not generate output; for example, an Insert, Delete, or CreateTable statement.

Syntax

anSDEQueryDef.Execute

Returns

Boolean


SDEQueryOrderEnum

 The following enumeration defines which of the query's criteria are evaluated first.

#SDE_QUERYORDER_ATTRIBUTEFIRST

The attribute criteria, defined by the WhereClause, are evaluated first. Use this order if the Where clause selects a small number of features spread across a large map area.

#SDE_QUERYORDER_SPATIALFIRST

The spatial criteria, defined by the list of SDESFilter objects, are evaluated first. Use this order if the spatial filters select features in a very small area.

#SDE_QUERYORDER_OPTIMIZE

SDE evaluates the constraints that select the least number of records first.


SDERecordSet

 An SDERecordSet object represents the set of columns and rows identified by an SDE query definition.

By default, SDE limits you to eight open RecordSets per connection. Each DBTable has an open RecordSet; the ninth DBTable opened from the same connection will be empty until another DBTable is removed from the project. Because ArcView uses RecordSets to draw DBThemes, themes using the same connection won't redraw unitl a DBTable is removed from the project.

In scripts, you must close RecordSets to avoid this problem. When using RecordSets in a loop, a script may act as if the limit has been reached though you've closed the RecordSet. You may have to force garbage collection with the PurgeObjects request before the next pass through the loop to remove the RecordSet and its associated objects from memory.

You can modify the source data with an SDERecordSet if you have the correct permissions in the database, and if the CanUpdate request returns TRUE. For SDERecordSets, CanUpdate only returns TRUE if opened from an SDETable, or from an SDEQueryDef created with the SetSelectColumns, SetFromTables, and SetWhereClause requests where FromTables has one table only.

When adding new records, or editing existing records, the RecordSet should represent only the columns whose values you are going to set. Columns used in the Edit request's Where clause don't need to be represented in the RecordSet.

Scenarios for changing the databaseIf you will be adding new records to or editing existing records in the database, consider the following two scenarios.

Scenario 1.The SDERecordSet has two fields, Color and Num. You're adding two new rows to the database.

You use AddNew, then SetRow to set the current row's values to {"Apple",1}. Update adds a row to the database with these values. For the next row you use SetValue on Color only, changing its value to "Orange". Update adds a second new row to the database with the values {"Orange", 1}.

This behaviour is correct; misunderstanding how these requests work together can cause problems. The Update request doesn't reset the current row's values. If you intended for Num to be a null number, you need to use SetValue a second time to set its value to a null number. When adding new rows, the SetRow request is safer because it forces you define each value in the new row, for example, {"Orange",Number.MakeNull}.

If the table in the database has other columns besides Color and Num, the new rows will have no values in those columns.

Scenario 2.the SDERecordSet has two fields, Color and Num. You're editng an existing record in the database.

You use the Edit request to change the record in the database where "ID = 53". Its original values are Shape=<aShape>, ID=53, Color="Blue", Num=649, and Name="Trade Area 53". The RecordSet's current row has null values for Color and Num. You use SetValue to change Color to "Plum". Update sends the current row's values, {"Plum",<Null Number>}, to the database. In the database, Num's value 649 is replaced by a null number.

This behaviour is correct; misunderstanding how these requests work together can cause problems. The value in each column represented in the RecordSet is changed to the current row's value for that column for each record identified by the Edit request. If you intended for Num's original value to stay the same, there are two possible solutions. First, you can redefine the RecordSet to represent Color only. This is the only solution if the Edit request's Where clause identifies more than one row in the database.

The second solution is to set the current row's values to the original values in the record where ID=53. How? There are two methods. If the RecordSet selects many records, loop through them with the Next request until you find the row you plan to edit. If the GetRow request hasn't been used already, use it to set the current row's values to the original values in the database.

For the second method, redefine the RecordSet's query to select only the row you want to edit with the SDEQueryDef.SetWhereClause("ID=53"). Use Next, then GetRow to set the current row's values to the original values in the database.

Regardless of the method you choose, now use SetValue to change Color to "Plum". Now, Update sends the row {"Plum",649} to the database. In the database, Color is changed to "Plum", and Num is changed to 649. The value for Num changes, but it also stays the same.

Inherits From

RecordSet

Required Extension

     Database Access

Instance Requests

Running a Query

Close  :  Boolean

Next  :  Boolean

Getting and Setting Values

SetRow ( aListofValues ) :  Boolean

SetValue ( aField, anObj ) :  Boolean

SetValueByIndex ( anIndexNumber, anObj ) :  Boolean

Editing an SDERecordSet

AddNew  :  Boolean

Delete ( anSQLWhereClause ) :  Boolean

Edit ( anSQLWhereClause ) :  Boolean

EndUpdate  :  Boolean

Update  :  Boolean

__________

See also

SDEConnection
SDEQueryDef
SDESColumn
SDESFilter
SDETable
SDELog
DBTheme
DBTable


Close (SDERecordSet)
Close

Closes anSDERecordSet and returns TRUE. After closing anSDERecordSet you can't use it again to access data. You must close anSDERecordSet when you're finished stepping through its records to remove its objects from memory and to avoid reaching SDE's eight RecordSet limit (see the class description for more details).

Syntax

anSDERecordSet.Close

Returns

Boolean


Next (SDERecordSet)
Next
Example

Moves the current row to the next row in anSDERecordSet, and returns TRUE. If the current row is the last row in the set, returns FALSE.

Any value objects that reference the current row's values, e.g. values returned with GetRow or GetValue, change to reflect the next row's values.

Syntax

anSDERecordSet.Next

Returns

Boolean


SetRow (SDERecordSet)
SetRow
Example

Sets the current row's values to the objects in aListofValues. aListofValues is a List of Value objects. The object at each index position in the list must be appropriate for the corresponding field in aRecordSet's list of fields.

Use this request after using the AddNew or Edit request and before using the Update request.

Syntax

anSDERecordSet.SetRow (aListofValues)

Returns

Boolean


SetValue (SDERecordSet)
SetValue
Example

Sets the current row's value for the column specified by aField to the value of anObj. anObj must be an appropriate Value object for aField's datatype. Use this request after using the AddNew or Edit request and before using the Update request.

Syntax

anSDERecordSet.SetValue (aField, anObj)

Returns

Boolean


SetValueByIndex (SDERecordSet)
SetValueByIndex

Sets the current row's value for the column specified by anIndexNumber to the value of anObj. anObj must be appropriate Value object for aField's datatype. Use this request after using the AddNew or Edit request and before using the Update request.

anIndexNumber is the index of a column's field in the RecordSet's fields list; for example, if anIndexNumber is two, this request sets the value object for anSDERecordSet's third field.

Syntax

anSDERecordSet.SetValueByIndex (anIndexNumber, anObj)

Returns

Boolean


AddNew (SDERecordSet)
AddNew
Example

Prepares anSDERecordSet to add a new row to the source table in the database, and returns TRUE; otherwise, returns FALSE. Preparing to insert data takes time and memory, so don't place this request inside a loop - you only need to use it once in anSDERecordSet. Putting this request inside a loop decreases performance significantly.

After issuing this request, you can assign values to the new row with the SetRow and SetValue requests. Use the Update request to send each new row to the database after you've finished setting its values. You must use the EndUpdate request after all new records have been added to complete the AddNew process and release the objects used from memory.

Syntax

anSDERecordSet.AddNew

Returns

Boolean


Delete (SDERecordSet)
Delete
Example

Deletes the row(s) identified by anSQLWhereClause from the database and returns TRUE; otherwise returns FALSE. You don't need to use the Update request to send this change to the database.

Syntax

anSDERecordSet.Delete (anSQLWhereClause)

Returns

Boolean


Edit (SDERecordSet)
Edit
Example

Prepares anSDERecordSet for editing the row(s) identified by anSQLWhereClause, and returns TRUE; otherwise, returns FALSE. If you only want to edit one row, anSQLWhereClause must use a column name and a value that uniquely identify that record in the source table.

After issuing this request, you change values in the identified row(s) with the SetRow or SetValue requests. Use the Update request to send the changes to the database after changing the values. You must use the EndUpdate request after all edits are finished to complete the editing process.

Syntax

anSDERecordSet.Edit (anSQLWhereClause)

Returns

Boolean


EndUpdate (SDERecordSet)
EndUpdate

Ensures that updates made to the source data with AddNew or Edit have been sent from SDE to the database, and clears the objects used from memory. Returns TRUE if all records in the update batch are stored successfully in the database; otherwise, returns FALSE.

Syntax

anSDERecordSet.EndUpdate

Returns

Boolean


Update (SDERecordSet)
Update
Example

Sends the current row's values to the database. These values are stored in a new record in the database if you used the AddNew request. If you used the Edit request, for each column in the RecordSet, the stored value is changed to represent the current row's values in each row identified by the Where clause.

New and changed records are sent from SDE to the database in batches. Update returns TRUE when records are successfully added to a batch from Avenue. When the batch is full, SDE updates the database and clears the batch. If all records are stored successfully, the next Update request after the batch has been cleared will return TRUE. If a record in the batch was not successfully stored in the database, the next Udpate request will return FALSE.

You must use EndUpdate when you're finished updating the database with either the AddNew or Edit requests to complete the editing process.

Syntax

anSDERecordSet.Update

Returns

Boolean


SDESColumn

 An SDE spatial column represents a column in a table in an SDE database that stores shapes.

You can define a new spatial column with the MakeNew request, then add it to an existing table in the database with the SDETable.CreateSColumn request. When you create a new spatial column you need to define all of its attributes before adding it to the database: number of shapes, average points, coordinate reference, and grid sizes. You may also want to define the SColumn so it can contain measured and 3D shapes. After creating a spatial column, setting these attributes won't change its properties.

Attributes

CoordinateReference.CoordinateReference is a rectangle defining a new SDESColumn's coordinate boundary; all vertices in all shapes must fall within this rectangle. The shapes that you use for spatial filters against this SDESColumn must also fall within the coordinate boundary; otherwise, the shape is invalid in SDE. The coordinates of this rectangle must have the same units as the shapes' coordinates.

GridSizes.GridSizes is a list of three numbers that are the spatial index grid sizes for an SDESColumn. SDE uses spatial index grids to find features quickly. Each layer must have one index grid, but can have up to three grids with increasing resolution from one to three. You define a grid's size by specifying a distance in the same units as the shapes' coordinates.

NumShapes.When creating a new SDESColumn, you need to estimate the total number of shapes your spatial column will contain. That number is represented by NumShapes.

AveragePoints.When creating a new SDESColumn, you need to estimate the number of vertices each shape will have. That number is represented by AveragePoints. If the SDESColumn will only contain single-point features, AveragePoints should be one.

Measured.When creating a new SDESColumn, you can specify that all of the shapes stored in the spatial column will have measure values as part of the vertex coordinates.

Z.When creating a new SDESColumn, you can specify that all of the shapes stored in the spatial column will have Z values as part of the vertex coordinates.

CreationDate.The CreationDate is a Date object representing the date the spatial column was created.

Inherits From

SColumn

Enumerations

SDESColumnTypeEnum

SDESColumnStorageTypeEnum

Required Extension

     Database Access

Class Requests

Making an SDESColumn

Make ( anSDEConnection, aTableName, aFieldName ) :  SDESColumn

MakeNew ( aColumnName, anSDESColumnTypeList ) :  SDESColumn

Instance Requests

Getting and Setting Attributes

GetCreationDate  :  Date

GetGridSizes  :  List

GetSColumnName  :  String

GetStorageType  :  SDESColumnStorageTypeEnum

GetTableName  :  String

HasAnnotation  :  Boolean

HasStorageType ( anSDESColumnStorageType ) :  Boolean

HasType ( anSDESColumnType ) :  Boolean

HasZ  :  Boolean

IsMeasured  :  Boolean

ReturnExtent ( anSQLWhereClause ) :  Rect

ReturnStatistics  :  List

SetAveragePoints ( aNumber ) :  Boolean

SetCoordRefByRect ( aRect ) :  Boolean

SetCreationKeyword ( anSDEKeyword ) :  Boolean

SetGridSizes ( aListOfGridSizes ) :  Boolean

SetMeasured ( isMeasured ) :  Boolean

SetNumShapes ( aNumber ) :  Boolean

SetSColumnName ( anSColumnName ) :  Boolean

SetStorageType ( anSDESColumnStorageType ) :  Boolean

SetZ ( HasZ ) :  Boolean

Managing Locks

FreeLock  :  Boolean

LockAll ( canModify ) :  Boolean

LockArea ( aRectangle, canModify ) :  Boolean

__________

See also

SDEConnection
SDEQueryDef
SDERecordSet
SDESFilter
SDETable
SDELog
DBTheme


Make (SDESColumn)
Make
Example

Returns anSDESColumn object representing the spatial column named aFieldName in the table named aTableName in the database identified by the connection object anSDEConnection; otherwise returns a nil object. aTableName must have the format "<ownerName>.<tableName>" if you don't own the table.

Syntax

SDESColumn.Make (anSDEConnection, aTableName, aFieldName)

Returns

SDESColumn


MakeNew (SDESColumn)
MakeNew
Example

Returns a new SDESColumn object named aColumnName; otherwise, returns a nil object. This spatial column will be able to contain the type of shapes listed in anSDESColumnTypeList, which can contain any combination of the SDE feature types described by the SDESColumnType enumeration.

This SDESColumn represents a new spatial column definition; add this spatial column to the SDE database with the SDETable.CreateSColumn request. You can't use this SDESColumn object to store spatial data even after using the CreateSColumn request because it isn't associated with an SDEConnection object. Create another SDESColumn with the Make request.

Syntax

SDESColumn.MakeNew (aColumnName, anSDESColumnTypeList)

Returns

SDESColumn


GetCreationDate (SDESColumn)
GetCreationDate

Returns a Date object representing the date the spatial column was created.

Syntax

anSDESColumn.GetCreationDate

Returns

Date


GetGridSizes (SDESColumn)
GetGridSizes

Returns a list of anSDESColumn's three grid sizes; otherwise, returns a nil object. Each number represents the size of the spatial index grid boxes in the same units as the shapes' coordinates.

Syntax

anSDESColumn.GetGridSizes

Returns

List


GetSColumnName (SDESColumn)
GetSColumnName
Example

Gets the name of the column anSDESColumn represents; the spatial column's name doesn't include the table name.

Syntax

anSDESColumn.GetSColumnName

Returns

String


GetStorageType (SDESColumn)
GetStorageType

Gets storage type of anSDESColumn.

Syntax

anSDESColumn.GetStorageType

Returns

SDESColumnStorageTypeEnum


GetTableName (SDESColumn)
GetTableName
Example

Gets the name of the table containing the column anSDESColumn represents. The table's name has the format "<ownerName>.<tableName>" if you don't own the table.

Syntax

anSDESColumn.GetTableName

Returns

String


HasAnnotation (SDESColumn)
HasAnnotation

Returns TRUE if anSDESColumn has annotations; otherwise, returns FALSE.

Syntax

anSDESColumn.HasAnnotation

Returns

Boolean


HasStorageType (SDESColumn)
HasStorageType

Returns TRUE if anSDESColumn has storage type described by anSDESColumnStorageType; otherwise, returns FALSE.

Syntax

anSDESColumn.HasStorageType (anSDESColumnStorageType)

Returns

Boolean


HasType (SDESColumn)
HasType

Returns TRUE if anSDESColumn can have shapes in it of the type described by the enumeration anSDESColumnType; otherwise, returns FALSE.

Syntax

anSDESColumn.HasType (anSDESColumnType)

Returns

Boolean


HasZ (SDESColumn)
HasZ

Returns TRUE if the verticies in anSDESColumn's shapes will have coordinates with Z values; otherwise, returns FALSE.

Syntax

anSDESColumn.HasZ

Returns

Boolean


IsMeasured (SDESColumn)
IsMeasured

Returns TRUE if the verticies in anSDESColumn's shapes can have coordinates with Measure values; otherwise, returns FALSE.

Syntax

anSDESColumn.IsMeasured

Returns

Boolean


ReturnExtent (SDESColumn)
ReturnExtent

If anSQLWhereClause is a null string, it selects all the shapes in anSDESColumn, and the rectangle returned represents the coordinate boundary of anSColumn. If anSQLWhereClause selects specific shapes by their attribute values, the rectangle returned represents the smallest rectangle containing all the selected shapes. Otherwise, returns a nil object. The rectangle's coordinates always have the same units as the source data.

Syntax

anSDESColumn.ReturnExtent (anSQLWhereClause)

Returns

Rect


ReturnStatistics (SDESColumn)
ReturnStatistics

Returns a list of statistics for the shapes stored in anSDESColumn. The list contains ten elements in the order of:

  total number of features
  number of nil shapes
  number of point shapes
  number of linear shapes
  number of simple linear shapes
  number of polygon shapes
  minium feature ID
  maxium feature ID
  minium number of points of shapes
  maxium number of points of shapes

Syntax

anSDESColumn.ReturnStatistics

Returns

List


SetAveragePoints (SDESColumn)
SetAveragePoints
Example

Sets the average number of points each shape in anSDESColumn will have. You only use this request when you're creating a new SDESColumn.

Don't use this request in conjunction with the SetCreationKeyword request; use either the SetAveragePoints or the SetCreationKeyword request. If you're creating a spatial column to hold a large number of shapes (more than 50,000), set parameters in the dbtune file and use the SetCreationKeyword request.

Syntax

anSDESColumn.SetAveragePoints (aNumber)

Returns

Boolean


SetCoordRefByRect (SDESColumn)
SetCoordRefByRect
Example

Sets the coordinates that the shapes in anSDESColumn must be stored in, and sets the coordinate boundary to the reference rectangle aRect. The rectangle must encompass the entire region that its shapes will occupy. All the vertices for all shapes in anSDESColumn must fall within this rectangle. You only use this request when you're creating a new SDESColumn.

If the spatial column will contain shapes with measures, aRect must have measure values; create it with the RectM class. If the spatial column will contain three-dimensional shapes, aRect must have Z values; create it with the RectZ class.

Syntax

anSDESColumn.SetCoordRefByRect (aRect)

Returns

Boolean


SetCreationKeyword (SDESColumn)
SetCreationKeyword

 This request is only for advanced Avenue users who have an excellent understanding of SDE. Use this request when creating a new SDESColumn in the database; it lets you use parameters previously defined in SDE's DBTune file that are uniquely identified by the keyword anSDEKeyword. Consider learning to use the DBTune file if your spatial column will contain more than 50,000 shapes.

When you create a new spatial column, SDE creates private tables. You might want to specify how big those tables are at first, and in Oracle you can specify the Tablespace they're created in. There may be performance advantages to placing the spatial column's private tables in a different tablespace than the business table. These parameters are usually specific to the data for this spatial column.

If you don't provide a keyword, the tables will be created using a combination of the default parameters defined in the DBTune file, or the system defaults. If you use the SetAveragePoints and SetNumShapes requests, the tables will be created using calculations from the values defined with these requests. Don't use SetAveragePoints and SetNumShapes in conjunction with SetCreationKeyword: SDE won't use the dbtune file.

Syntax

anSDESColumn.SetCreationKeyword (anSDEKeyword)

Returns

Boolean


SetGridSizes (SDESColumn)
SetGridSizes
Example

You must specify a size for each of anSDESColumn's three spatial index grids by providing a list of three distances. The spatial column must have one spatial index, so the first number in the list must be a valid size; the second two numbers in aListOfGridSizes can be be zeros. A grid's size, a distance in the same units as the shapes' coordinates, must be appropriate for the size of the coordinate boundary and the size of the shapes in anSDESColumn. You only use this request when you're creating a new SDESColumn.

Syntax

anSDESColumn.SetGridSizes (aListOfGridSizes)

Returns

Boolean


SetMeasured (SDESColumn)
SetMeasured

Modifies the spatial column so that its shapes can have coordinates with Measure values. You can only use this request when you're creating a new SDESColumn.

Syntax

anSDESColumn.SetMeasured (isMeasured)

Returns

Boolean


SetNumShapes (SDESColumn)
SetNumShapes
Example

Sets the average number of features that anSDESColumn will contain to aNumber. You only use this request when you're creating a new SDESColumn.

Don't use this request in conjunction with the SetCreationKeyword request; use either the SetNumShapes or the SetCreationKeyword request. If you're creating a spatial column to hold a large number of shapes (more than 50,000), set parameters in the dbtune file and use the SetCreationKeyword request.

Syntax

anSDESColumn.SetNumShapes (aNumber)

Returns

Boolean


SetSColumnName (SDESColumn)
SetSColumnName

You can use this request between the time you create a new SColumn object and the time you create the spatial column in the database. This requests lets you specify a new name for the spatial column in the database.

Syntax

anSDESColumn.SetSColumnName (anSColumnName)

Returns

Boolean


SetStorageType (SDESColumn)
SetStorageType

Set the storage type of anSDESColumn to anSDESColumnStorageType. The default storage type is #SDESCOLUMN_STORAGE_TYPE_DEFAULT.

Syntax

anSDESColumn.SetStorageType (anSDESColumnStorageType)

Returns

Boolean


SetZ (SDESColumn)
SetZ

Modifies the spatial column so that its shapes will have coordinates with Z values. You can only use this request when you're creating a new SDESColumn.

Syntax

anSDESColumn.SetZ (HasZ)

Returns

Boolean


FreeLock (SDESColumn)
FreeLock
Example

Removes all of your locks on anSDESColumn and returns TRUE; otherwise, returns FALSE.

Syntax

anSDESColumn.FreeLock

Returns

Boolean


LockAll (SDESColumn)
LockAll

Locks all records in anSDESColumn's table that have shape values, and returns TRUE; otherwise, returns FALSE.

If canModify is TRUE, you can change the data in the locked records, but no one else can. Can-Modify locks can't overlap other locks. If canModify is FALSE, no one can change the data in the locked records. Can't-modify locks can overlap with other can't-modify locks. Locks don't prevent others from reading data.

Syntax

anSDESColumn.LockAll (canModify)

Returns

Boolean


LockArea (SDESColumn)
LockArea
Example

Locks all records in anSDESColumn's table whose shapes intersect aRectangle, and returns TRUE; otherwise, returns FALSE.

If canModify is TRUE, you can change the data in the locked records, but no one else can. Can-Modify locks can't overlap other locks. If canModify is FALSE, no one can change the data in the locked records. Can't-modify locks can overlap with other can't-modify locks. Locks don't prevent others from reading data.

Syntax

anSDESColumn.LockArea (aRectangle, canModify)

Returns

Boolean


SDESColumnTypeEnum

 The following enumeration defines the different kinds of shapes a spatial column can contain.

#SDESCOLUMN_TYPE_NIL

 No shape.

#SDESCOLUMN_TYPE_POINT

 A shape representing a single point.

#SDESCOLUMN_TYPE_LINEAR

 A shape representing a set of points connected in order by straight line segments. The segments can cross each other.

#SDESCOLUMN_TYPE_SIMPLELINEAR

 A shape representing a set of points connected in order by straight line segments. The segments cannot cross or touch.

#SDESCOLUMN_TYPE_AREA

 A shape representing a set of points connected in order by straight line segments and the space enclosed by those segments. The first and last points in the set are the same. An area shape can have one or more polygonal holes removed from the polygon's area. The donut holes cannot have islands in them.

#SDESCOLUMN_TYPE_MULTIPART

 A shape representing a set of sets of points. Each part of a multi-part shape can belong to any valid feature type.


SDESColumnStorageTypeEnum

 The following enumeration defines the different kinds of storage formats of a spatial column.

#SDESCOLUMN_STORAGE_TYPE_DEFAULT

SDE binary compressed storage format.

#SDESCOLUMN_STORAGE_TYPE_NORMALIZED

optional storage format for creating an SDO layer with Oracle DBMS.


SDESFilter

 A spatial filter represents spatial criteria that you can apply to an SDE query definition to choose which rows are retrieved from the database. You must create the SDEQueryDef using the SetSelectColumns, SetFromTables, and SetWhereClause requests.

When you apply spatial filters to an SDEQueryDef (using the SetSFilters request), the records retrieved must satisfy all of the spatial criteria in addition to any attribute criteria. Spatial filters are unioned together, so records must satisfy oneSDESFilter AND anotherSDESFilter.

Attributes

SpatialColumn.SpatialColumn is the SDESColumn containing the shapes that must satisfy the spatial criteria.

Filter.The Filter is the shape of the spatial criteria. For example, if you wanted to find all the homes that fall inside a 100m buffer zone around a highway, the Filter would be the Shape object representing the buffer zone.

SpatialSearch.The SpatialSearch is an enumeration indicating how you are going to compare the shapes in the SpatialColumn to the Filter. For example, to find the homes within the buffer zone you would use the enumeration #SDESPATIAL_SEARCH_ISWITHIN.

Test.The Test indicates which of the shapes you want to return. Your query can either return all the shapes that satisfy the spatial criteria, or all the shapes that don't. For example, to find the homes within the buffer zone the value of the Test attribute would be TRUE. Test is TRUE by default.

Inherits From

Obj

Enumerations

SDESpatialSearchEnum

Required Extension

     Database Access

Class Requests

Making an SDESFilter

Make ( anSDESColumn, aShape, aSpatialSearchEnum ) :  SDESFilter

Instance Requests

Getting Attributes

SetTest ( satisfyFilter )

__________

See also

SDEConnection
SDEQueryDef
SDERecordSet
SDESColumn
SDETable
SDELog
DBTheme


Make (SDESFilter)
Make
Example

 Creates a spatial filter object that will compare all the shapes in anSDESColumn to the filter, aShape, with the relationship defined by aSpatialSearchEnum.

Syntax

SDESFilter.Make (anSDESColumn, aShape, aSpatialSearchEnum)

Returns

SDESFilter


SetTest (SDESFilter)
SetTest

Tells the query you want to retrieve all the shapes in anSDESFilter's SColumn that return the value satisfyFilter when compared to anSDESFilter's filter shape with the search relationship.

If satisfyFilter is TRUE, the query returns all the records whose shapes satisfy anSDESFilter's conditions; if satisfyFilter is FALSE, the query returns all the records whose shapes do not satisfy anSDESFilter's conditions. By default, when you create anSDESFilter ArcView will set the test value to TRUE.

Syntax

anSDESFilter.SetTest (satisfyFilter)


SDESpatialSearchEnum

 This enumeration defines the methods for evaluating spatial relationships between the spatial filter object and the features in an SDETable.

#SDESPATIAL_SEARCH_EXTENT

The extent of the filter object overlaps or touches the extent of features in the table. The fastest search method.

#SDESPATIAL_SEARCH_EXTENTBYGRID

Same as above, but guarantees that the table's features returned by the query are in spatial index order.

#SDESPATIAL_SEARCH_COMMONPOINT

The spatial filter and features in the table share an identical vertex. Use to find adjacent features if topological integrity exists.

#SDESPATIAL_SEARCH_INTERSECTLINE

The spatial filter and features in the table must intersect without sharing a vertex. Does not include one shape completely inside the other. Use to find errors in topological integrity.

#SDESPATIAL_SEARCH_INTERSECTLINEORPOINT

Either of the previous two. The spatial filter touches table features.

#SDESPATIAL_SEARCH_COMMONLINE

The spatial filter shares a common line with table features.

#SDESPATIAL_SEARCH_INTERSECTAREAORLINE

The spatial filter touches table features or they share a common area.

#SDESPATIAL_SEARCH_INTERSECTAREA

The spatial filter and the table features share a common area. Either the spatial filter or the table features must be an area feature. Does not find adjacent features.

#SDESPATIAL_SEARCH_INTERSECTAREANOTOUCH

Either the spatial filter or the table features are wholly inside the other and their boundaries do not touch.

#SDESPATIAL_SEARCH_CONTAINS

The spatial filter is completely contained by the table features. If the table features are area features, the search feature must be completely inside the table features or their boundaries. If the search feature is a point, it must be one of the table features' vertices.

#SDESPATIAL_SEARCH_CONTAINSNOTOUCH

The table features must be area features. The spatial filter must be completely contained by the table feature without touching its boundary.

#SDESPATIAL_SEARCH_ISWITHIN

The table features are completely contained by the spatial filter. If the spatial filter is an area feature, the table features must be completely inside the spatial filter or its boundary. If the table features are point features, they must be vertices in the spatial filter.

#SDESPATIAL_SEARCH_ISWITHINNOTOUCH

The spatial filter must be an area feature. The table features must be completely contained by the spatial filter without touching its boundary.

#SDESPATIAL_SEARCH_FIRSTPOINTIN

The table features must be area features. The table features contain the first point of the spatial filter.

#SDESPATIAL_SEARCH_IDENTICAL

The spatial filter and the table features are identical in both feature type and vertices. Use to find duplicate data.


SDETable

 An SDETable represents a table in a relational database that may or may not have a spatial column for storing shapes. The SDETable has field objects representing the columns in the table; a spatial column's field will respond positively to the request IsTypeShape.

You can create a new table definition with the MakeNew request, then add it to the database with the SDEConnection.CreateTable request. You can spatially-enable an existing table, or index its columns using SDETable requests.

You can open a RecordSet directly from an SDETable that will represent all the columns in the table and all hte rows selected by the OpenRecordSet request's Where clause. Opening a RecordSet this way, rather than using a query definition, is useful when you're adding records to or deleting records from the table; you can only modify the database when the RecordSet's columns come from one table. When editing records in a table, use a RecordSet opened from a QueryDef that chooses only the columns you want to change.

Attributes

Fields.Fields is the list of Field objects representing the columns in an SDETable. Together, the fields describe the table's definition in the database; that is, the column names and their data types.

SDEConnection.The SDEConnection identifies the database containing an SDETable.

Inherits From

DBTableDef

Required Extension

     Database Access

Class Requests

Making a SDETable

Make ( anSDEConnection, aTableName ) :  SDETable

MakeNew ( aTableName, aFieldList ) :  SDETable

Instance Requests

Getting Attributes

SetCreationKeyword ( anSDEKeyword ) :  Boolean

Running a Query

OpenRecordSet ( anSQLWhereClause ) :  SDERecordSet

Indexing Fields in an SDETable

CreateIndex ( aFieldName, anIndexName, isUnique, isAscending, anSDEKeyword ) :  Boolean

DeleteIndex ( anIndexName ) :  Boolean

Modifying the Structure of an SDETable

CreateSColumn ( anSDESColumn ) :  Boolean

DeleteSColumn ( anSDESColumn ) :  Boolean

TruncateSColumn ( anSDESColumn ) :  Boolean

__________

See also

SDEConnection
SDEQueryDef
SDERecordSet
SDESColumn
SDESFilter
SDELog
DBTheme


Make (SDETable)
Make
Example

Returns anSDETable object representing the table named aTableName in the database identified by anSDEConnection; otherwise returns a nil object.

Syntax

SDETable.Make (anSDEConnection, aTableName)

Returns

SDETable


MakeNew (SDETable)
MakeNew
Example

Returns a new SDETable object named aTableName; otherwise returns a nil object.

This SDETable represents a new table definition; add this table to the database with the SDEConnection.CreateTable request. You can't open a RecordSet or perform other operations using this SDETable object even after using the CreateTable request because it isn't associated with an SDEConnection object. Create another SDETable with the Make request.

After adding a table to the database, you can add a spatial column to it. Create a new SColumn object, then add the spatial column to the table with the CreateSColumn request.

Syntax

SDETable.MakeNew (aTableName, aFieldList)

Returns

SDETable


SetCreationKeyword (SDETable)
SetCreationKeyword

 This request is only for advanced Avenue users who have an excellent understanding of SDE. Use this request when creating a new SDETable in the database; it lets you use parameters previously defined in SDE's DBTune file that are uniquely identified by the keyword anSDEKeyword.

When you create a new table, you might want to specify how big it is at first, how much it will grow when it exceeds that size, and in Oracle you can specify the Tablespace it's created in. These parameters are usually specific to the data for this table; they help maintain an efficient database. If you don't provide a keyword, the table will be created using default parameters defined in the DBTune file, or the system defaults.

Syntax

anSDETable.SetCreationKeyword (anSDEKeyword)

Returns

Boolean


OpenRecordSet (SDETable)
OpenRecordSet
Example

Returns an SDERecordSet representing all the columns in anSDETable, and all the records satisfying the attribute criteria specified with anSQLWhereClause. If anSQLWhereClause is a null string, "", the RecordSet will represent all the records in anSDETable. You can retrieve, edit, and store shapes with a RecordSet created with this request.

Syntax

anSDETable.OpenRecordSet (anSQLWhereClause)

Returns

SDERecordSet


CreateIndex (SDETable)
CreateIndex

 Creates an index named anIndexName for the values in the field named aFieldName and returns TRUE; otherwise returns FALSE. If isUnique is TRUE, a unique index will be created for the values. You won't be able to create a unique index for a field if it contains duplicate values. For these fields you can create an index by setting isUnique to FALSE. If isAscending is TRUE, values will be indexed in ascending order. If isAscending is FALSE, values will be indexed in descending order.

anSDEKeyword can either be a valid SDE keyword or a null string, "". The database creates an index table for the values in aFieldName. You can control the parameters used to create the index table by specifying anSDEKeyword, which uniquely defines a set of parameters located in SDE's DBTune file. For example, use a keyword with Oracle to place the index table in a different Tablespace from the source table to improve the performance of your queries. If you don't provide a keyword, the index table will be created using the default parameters defined in the DBTune file, or the system defaults.

Syntax

anSDETable.CreateIndex (aFieldName, anIndexName, isUnique, isAscending, anSDEKeyword)

Returns

Boolean


DeleteIndex (SDETable)
DeleteIndex

Deletes the index named anIndexName and returns TRUE; otherwise returns FALSE.

Syntax

anSDETable.DeleteIndex (anIndexName)

Returns

Boolean


CreateSColumn (SDETable)
CreateSColumn
Example

Creates a spatial column in anSDETable representing the object anSDESColumn.

Syntax

anSDETable.CreateSColumn (anSDESColumn)

Returns

Boolean


DeleteSColumn (SDETable)
DeleteSColumn
Example

Deletes all of the shapes in anSDESColumn, removes the spatial context from the column in anSDETable, and returns TRUE; otherwise returns FALSE. Afterwards, this column in the table can be used as a number field.

Syntax

anSDETable.DeleteSColumn (anSDESColumn)

Returns

Boolean


TruncateSColumn (SDETable)
TruncateSColumn

Truncates the anSDESColumn, removing all of its shapes, and returns TRUE; otherwise returns FALSE. The column in anSDETable remains a spatial column; you can add new shape values to it later.

Syntax

anSDETable.TruncateSColumn (anSDESColumn)

Returns

Boolean


appending records to a table (Database Access extension)
Appending Records to a Table

' this script is for the Database Access extension

' this script adds the shapes in a shapefile to an existing spatially-enabled

' table in the database

theView = av.GetActiveDoc

theFTheme = theView.FindTheme("NewRivers")

theFTab = theFTheme.GetFTab

theDBTheme = theView.FindTheme("Rivers")

theQueryDef = theDBTheme.GetQueryDef

theConnection = theQueryDef.GetConnection

theSCol = theDBTheme.GetSColumn

scolName = theSCol.GetSColumnName

' check to make sure all the fields in the shapefile are in the table

' The shape fields are added to the lists first since the shape field

' names do not necessarily match (an SDE SColumn can have any valid RDBMS

' name while a shape file can only name the shape field “shape”)

fList = {}

dbList = {}

fList.Add(theFTab.FindField("Shape"))

aRSet = theQueryDef.OpenRecordSet

dbList.Add(aRSet.FindField(scolName))

for each f in theFTab.GetFields

  if (f.IsTypeShape.Not) then

    dbf = aRSet.FindField(f.GetName)

    if (dbf <> nil) then

      ' This script only loads string and number type fields

      if ((f.IsTypeString <> dbf.IsTypeString) or

          (f.IsTypeNumber <> dbf.IsTypeNumber)) then

        msgbox.Info("Can't load data for field:"++f.GetName, "Wrong Data Type")

      else

        fList.Add(f)

        dbList.Add(dbf)

      end

    else

      msgbox.info("Can't load data for field:"++f.GetName, "Not in database")

    end

  end

end

' load data from the FTab into the table in the database.

' Tranactions are used to commit the data to the database

' after each record is added.

theConnection.BeginTrans

aRSet.AddNew

for each rec in theFTab

  for each f in fList

    theValue = theFTab.ReturnValue(f, rec)

    aRSet.SetValue(dbList.Get(fList.find(f)), theValue)

  end

  ok = aRSet.Update

  if (not ok) then

    msgbox.info(rec.asstring, "Can't store row in the database")

    msgbox.info(theConnection.GetErrorCode.AsString, "Error Code")

  end

  theConnection.CommitContinue

end

' The EndUpdate request should always be executed after

' updating the database using the AddNew and Edit requests.

' This request makes sure that all updates have been sent to

' the database.

aRSet.EndUpdate

theConnection.CommitTrans

aRSet.Close

' redraw the view

theDBTheme.Invalidate(true)

theView.GetDisplay.Flush


changing a database theme's query (Database Access extension)
Changing a Database Theme's Query

' this script is for the Database Access extension

' Your theme currently displays all the countries in the world.

' This script changes the query definition for your Countries DBTheme

' so only those countries that have a population greater than

' 200,000,000 are displayed in your view; population data is in an

' attribute table that you can join to your theme

' get the DBTheme from the View

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Cntry94")

' get the DBTheme's query definition

theQDef = theDBTheme.GetQueryDef

' add another table to theQDef's FromTables property

theFrTables = theQDef.GetFromTables

theFrTables.Add("world.demog")

theQDef.SetFromTables(theFrTables)

' build an SQL where clause that joins the demographics table to the

' theme and sets the new criteria

theWhere = "world.demog.fips_code = world.Cntry94.fips_code and"++

           "TOT_POP > 200000000"

theQDef.SetWhereClause(theWhere)

' then redraw the view

theDBTheme.Invalidate(true)

theView.GetDisplay.Flush


combining sdelogs (Database Access extension)
Combining SDELogs

' this script is for the Database Access extension

' this script finds all the major selected lakes in the world that have

' a surface area within a certain range. The current selection includes

' lakes from the middle latitudes

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Lakes")

theThmQDef = theDBTheme.GetQueryDef

theConnection = theThmQDef.GetConnection

' get the current selection logfile

Log1 = theDBTheme.GetSelection

' make a new logfile; MakeLogName guarantees that the log name you use

' will be original (opening the log in CREATE mode will not fail)

logName = SDELog.MakeLogName(theConnection)

Log2 = SDELog.Make(theConnection, logName, "world.lakes",#SDELOG_MODE_CREATE)

' clone the theme's QueryDef to create a new subset of features

' based on the same query, but with different criteria;

' set the where clause to identify the lakes you don't want

theQDef = thethmQDef.Clone

theQDef.SetWhereClause("Area > 70000 or Area < 3000")

' set the source of the QueryDef to nil and the destination to Log2,

' then Open the recordset. This adds references to the features that

' satisfy the query to the log file

theQDef.SetSrcDest(nil, Log2, false)

anRS = theQDef.OpenRecordSet

anRS.Close

if (Log2.Count < 1) then

  msgbox.info("No Lakes identified.", "Message")

  exit

end

' make Log2 a temporary logfile; it will be deleted when the current

' connection is closed

isTemporary = TRUE

Log2.ChangeType(isTemporary)

' combine the two subsets of features, where features in log2 are

' removed from log1

logName2 = Log2.GetName

Log1.Combine(logName2, #SDELOG_COMBINETYPE_DIFFERENCE)

' Log1 is still the selection for theDBTheme; redraw the view to see

' changes in your selection

theDBTheme.Invalidate(true)

theView.GetDisplay.Flush

By default, a query definition's source is always the tables in the database, and the destination is always the SDE client, which is your ArcView session. When you create a logfile to represent a subset of features, that logfile is stored on the SDE server. Therefore, you need to change the destination of your query from the client to the server. In the above example, we used the following request:

theQDef.SetSrcDest(nil, Log2, false)

where 'nil' identifies that the source of the QueryDef is still the database, but now the destination of the QueryDef is the logfile on the server represented by Log2 instead of the ArcView client.


creating database themes (Database Access extension)
Creating Database Themes

' this script is for the Database Access extension

' this script creates a database theme representing all the cities

' in the U.S. and adds it to your view

theView = av.GetActiveDoc

' creates an SDEConnection object if ArcView can connect to the database

' all strings for SDEConnection.Make are case sensitive. In this case "tiffany"

' is an Oracle Server so an empty string is used to specify the database

server = "tiffany"

instance = "esri_av"

database = ""

userName = "avtest"

password = msgbox.Password

if (password = nil) then exit end

anSDECon = SDEConnection.Make(server+":"+instance, database, userName, password)

if (anSDECon.HasError) then

  MsgBox.Error(anSDECon.GetErrorMsg, "Error Connecting to SDE")

  exit

end

' Create the query definition that your database theme will represent.

' You must set the SelectColumns and FromTables properties for each SDEQueryDef

' so the query knows what data to get and which tables to get it from. In

' this example, the cities table is owned by a user named world and therefore

' we must specify the name of the table as "world.cites"

aQDef = SDEQueryDef.Make(anSDECon)

aQDef.SetSelectColumns({"feature","name","population"})

aQDef.SetFromTables({"world.cities"})

aQDef.SetWhereClause("country = 'US'")

' create a spatial column; the SColumn tells the theme which column

' of spatial data it will draw

theSCol = SDESColumn.Make(anSDECon, "world.cities", "feature")

' create the DBTheme from the QueryDef and the SColumn

theDBTheme = DBTheme.Make(aQDef, theSCol, Point)

' display the database theme in your view

theDBTheme.SetName("US Cities")

theDBTheme.SetVisible(True)

theView.AddTheme(theDBTheme)

 If you have already made a network connection between ArcView and SDE,

 you can make a new database theme using the same connection. You can

 also modify and existing query definition to create a new theme. The

 following script shows you how to use the existing SDEQueryDef and

 SDEConnection objects:

' creates a new DBTheme of all the cities in Canada by using an

' existing connection and by modifying an existing query definition

theView = av.GetActiveDoc

' get the QueryDef, SColumn, and Connection objects

' from the DBTheme in the view

aDBTheme = theView.FindTheme("US Cities")

aQueryDef = aDBTheme.GetQueryDef

theCon = aQueryDef.GetConnection

theSCol = aDBTheme.GetSColumn

' if the connection is still open, make a new QueryDef and

' a new DBTheme, and add the new DBTheme to the view

if (theCon.IsConnected and theCon.HasError.Not) then

  ' copy the existing QueryDef and change the query

  ' to retrieve Canadian cities

  newQDef = aQueryDef.Clone

  newQDef.SetWhereClause("country = 'Canada'")

  ' create a new DBTheme using the new QueryDef and the

  ' existing SColumn and Connection objects

  newTheme = DBTheme.Make(newQDef, theSCol, Point)

  ' display the database theme in your view

  newTheme.SetName("Canadian Cities")

  newTheme.SetVisible(True)

  theView.AddTheme(newTheme)

else ' if the connection is closed or has an error

  MsgBox.Error(theCon.GetErrorMsg, "Connection Error")

end


deleting selected features  (Database Access extension)
Deleting Selected Features

' this script is for the Database Access extension

' this script deletes all the selected countries in the

' Countries DBTheme and their attributes from the source table

' get your DBTheme from the View

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Countries")

' make sure your DBTheme has selected features

theLog = theDBTheme.GetSelection

if (theLog = nil) then

  msgBox.Info("Your DBTheme must have selected features","")

  exit

end

' Clone the Querydef and re-set the set the select columns to

' SE_ROW_ID. SE_ROW_ID is a special field maintained by SDE

' that contains a unique value for each feature in the

' table. Using the modified cloned querydef, we can get the

' unique identifier and use it to delete the selected

' feature

theQuery = theDBTheme.GetQueryDef

theQueryCln = theQuery.Clone

theQueryCln.SetSelectColumns({"SE_ROW_ID"})

theQueryCln.SetSrcDest(theLog,nil,false)

' Here the id's of the features to delete are read from the

' cloned querfdef and used with the original querydef.

r = theQuery.OpenRecordSet

r2 = theQueryCln.OpenRecordSet

fldSClr2 = r2.FindField("SE_ROW_ID")

while (r2.Next)

  delStr = "feature = "+r2.GetValue(fldSClr2).AsString

  r.Delete(delStr)

end

r.Close

r2.Close

' redraw the view

theDBTheme.Invalidate(true)

theView.GetDisplay.Flush


deleting spatial columns and tables (Database Access extension)
Deleting Spatial Columns and Tables

' this script is for the Database Access extension

' this script deletes the spatial column and associated table

' represented by a DBTheme from the database

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("myTable")

theConnection = theDBTheme.GetQueryDef.GetConnection

theSCol = theDBTheme.GetSColumn

theTableName = theSCol.GetTableName

theTable = SDETable.Make(theConnection, theTableName)

' make sure the connection is open

if (theConnection.IsConnected.Not) then

  theConnection.Open

  bad = theConnection.HasError

  if (bad) then

    msgbox.Error("Connection has an error.", "Connection.HasError")

    msgbox.Info(theConnection.GetErrorMsg, "Error Message")

    exit

  end

end

' remove the theme from the view, then delete the spatial column

' and its table from the database

theView.DeleteTheme(theDBTheme)

ok = theTable.DeleteSColumn(theSCol)

if (not ok) then

  MsgBox.Error("Spatial column not deleted.", "SDETable.DeleteSColumn")

  MsgBox.Info(theConnection.GetErrorCode.AsString, "Error Code")

else

  ok = theConnection.DeleteTable(theTable)

  if (not ok) then

    MsgBox.Error("Table not deleted.", "Connection.DeleteTable")

    MsgBox.Info(theConnection.GetErrorCode.AsString, "Error Code")

  end

end


find by point (Database Access extension)
Find By Point

' this script is for the Database Access extension

' this script flashes all the features in the view at

' any point you click your mouse; the script must be

' attached to a tool in the View gui - its apply script

' get the first active theme in the view

theView = av.GetActiveDoc

theTheme = theView.GetActiveThemes.Get(0)

' make sure the active theme is a DBTheme

if (theTheme.Is(DBTheme).Not) then

  msgbox.error("The active theme is NOT a dbtheme!!","")

  exit

end

' mouse click to get the point - APPLY EVENT!!

' then flash features

p = theView.GetDisplay.ReturnUserPoint

IDList = theTheme.FindByPoint( p )

for each id in IDList

  theTheme.BlinkRecord( id )

end


making a database table (Database Access extension)
Making a database table

' this script is for the Database Access extension

' this script makes a DBTable document using a SDEConnection,

' and an SQL statement to retrieve desired records.

theCon = SDEConnection.Make("tiffany:esri_av","","avtest","avtest")

' make a new query definition object associated with

' the new connection

theQDef = SDEQueryDef.Make(theCon)

' create a SQL statement to select name, area, total population

' and fips_code from a business table and a joined demographics table

' for all countries with a total population greater than

' 100,000,000 and apply it to the query definition. Since the user that

' I am logged in as (avtest) owns both tables used in the SQL statement,

' I do not need to reference the select fields in theSelStr by their full

' name (Owner.Table.Field). I had to reference the fips_code field as

' cntry94.fips_code (Table.Field) since a field by this name appears in

' both of the from tables.

theSelStr = "select name, area, tot_pop, cntry94.fips_code from cntry94, demog"

theWhStr = "where tot_pop > 100000000 and cntry94.fips_code = demog.fips_code"

theQDef.SetSQL(theSelStr++theWhStr)

' make the DBTable from the query definition

theDBTab = DBTable.Make(theQDef)

' Make the DBTable the active document

DBWin = theDBTab.GetWin

DBWin.Activate

DBWin.SetTitle("Country, Area and Population > 100,000,000")


making a new table (Database Access extension)
Making a New Table

' this script is for the Database Access extension

' make a connection to the database

theServer = "tiffany:esri_av"

theDatabase = ""

theUser = "avtest"

thePassword = Msgbox.Password

if (thePassword = nil) then exit end

theConnection = SDEConnection.Make(theServer, theDatabase, theUser, thePassword)

' create the field objects, then create the new table object

field1 = Field.Make("Owner",#FIELD_CHAR,20,0)

field2 = Field.Make("Area",#FIELD_DECIMAL,6,4)

field3 = Field.Make("Lot",#FIELD_CHAR,12,0)

field4 = Field.Make("Block",#FIELD_CHAR,12,0)

newTable = SDETable.MakeNew("sampletab",{field1,field2,field3,field4})

' The SetCreationKeyword request refers to a set of parameters on the server which

' are used to further define the new table. Refer to your SDE systems administrator

' to find out if this request is required to create tables on your SDE Server.

newTable.SetCreationKeyword("avtest")

' if the new table object is created successfully,

' add the table's definition to the database

if (newTable = nil) then

  msgbox.Error("Can't create table object.", "SDETable.MakeNew")

  msgbox.Info(theConnection.GetErrorMsg, "Error Message")

  exit

else

  ok = theConnection.CreateTable(newTable)

  if (not ok) then

    msgbox.Error("Can't create table in database.", "SDEConnection.CreateTable")

    msgbox.Info(theConnection.GetErrorCode.AsString, "Error Code")

    exit

  end

end

' Get the new table once created in the Database

newSDETable = SDETable.Make(theConnection,"sampletab")

' load data from a VTab in your project into the new table in the database

theTable = av.FindDoc("myAttTable")

theVTab = theTable.GetVTab

theFields = theVTab.GetFields

r = newSDETable.OpenRecordSet("")

r.AddNew

for each rec in theVTab

  aRow = {}

  for each f in theFields

    theValue = theVTab.ReturnValue(f, rec)

    aRow.Add(theValue)

  end

  r.SetRow(aRow)

  ok = r.Update

  if (not ok) then

    msgbox.info(rec.asstring, "Can't store row in the database")

    msgbox.info(theConnection.GetErrorCode.AsString, "Error Code")

  end

end

' The EndUpdate request should always be executed after

' updating the database using the AddNew and Edit requests.

' This request makes sure that all updates have been sent to

' the database.

r.EndUpdate

r.Close


saving and remembering selections (Database Access extension)
Saving and Remembering Selections

' this script is for the Database Access extension

' this script saves the current selection; retrieve the

' saved selection later with GetLastSelection

' get the first active theme in the view

theView = av.GetActiveDoc

theTheme = theView.GetActiveThemes.Get(0)

' make sure the active theme is a DBTheme

if (theTheme.Is(DBTheme).Not) then

  msgbox.error("The active theme is NOT a dbtheme!!","")

  exit

end

' save the current selection

theTheme.RememberSelection

Now I can do things that manipulate the current selection, and then go back to the first selection later.

' this script retrieves the saved selection and makes

' it the current selection

' get the first active theme in the view

theView = av.GetActiveDoc

theTheme = theView.GetActiveThemes.Get(0)

' make sure the active theme is a DBTheme

if (theTheme.Is(DBTheme).Not) then

  msgbox.error("The active theme is NOT a dbtheme!!","")

  exit

end

' Get the saved selection SDELog

theLog = theTheme.GetLastSelection

' Restore the saved selection SDELog

theTheme.SetSelection( theLog )


selecting and exporting features (Database Access extension)
Selecting and Exporting Features

' this script is for the Database Access extension

' this script selects features intersecting the selected graphic

' shapes in the view, exports those features to a local ArcView

' shapefile, and adds the shapefile to your view

' get the DBTheme from the View

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Countries")

' make a list of shapes from the selected graphics

shapelist = {}

theGraphics = theView.GetGraphics.GetSelected

if (theGraphics.Count > 0) then

  for each g in theGraphics

    theShape = g.GetShape

    shapeList.Add(theShape)

  end

else ' if no shapes are selected

  MsgBox.Info("No graphics selected.", "Can't Continue")

  exit

end

' perform selection on the database theme

theDBTheme.SelectByShapes(shapelist, #VTAB_SELTYPE_NEW)

' Check to make sure the DBTheme can be exported

' (i.e. there are selected features)

if (theDBTheme.CanExportToFTab) then

  ' export features to a local shapefile

  myFile = FileName.Make("countries.shp")

  theFTab = theDBTheme.ExportToFTab(myFile)

  theFTheme = FTheme.Make(theFTab)

  ' add the FTheme to the view

  theView.AddTheme(theFTheme)

  theFTheme.SetVisible(true)

  MsgBox.Info("Export successful.", "Export to FTab")

  ' clear the selection

  theDBTheme.ClearSelection

else

  MsgBox.Info("No Features Selected. Unable to export.", "Export to FTab")

end


select by attributes (Database Access extension)
Select By Attributes

' this script is for the Database Access extension

' this script selects all the Cities in a cities DBTheme

' that are in Germany

' get your DBTheme from the view

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Cities")

' build an SQL where clause

theSQLWhereClause = "Country = 'Germany'"

' apply the SQL where clause to the cities DBTheme

theDBTheme.SelectByAttributes(theSQLWhereClause, #VTAB_SELTYPE_NEW)

' Here are some other examples of building SQL where clauses in Avenue.

' For more detailed information, see Selecting database theme features

' by their attributes.

'theSQLWhereClause = "Population > 10000000"

'aPop = 200000

'theSQLWhereClause = "area < "+ aPop.AsString

'aField = "Capital"

'aStrValue = "Y"

'theSQLWhereClause = aField ++"= '"+ aStrValue +"'"


select by point (Database Access extension)
Select By Point

' this script is for the Database Access extension

' this script selects the feature you click on with

' the mouse; must be the apply script for a tool

' finds the first active theme in the view

theView = av.GetActiveDoc

theTheme = theView.GetActiveThemes.Get(0)

' make sure the active theme is a DBTheme

if (theTheme.Is(DBTheme).Not) then

  msgbox.error("The active theme is NOT a dbtheme!!","")

  exit

end

' mouse click to get the point - APPLY EVENT!!

pnt = theView.GetDisplay.ReturnUserPoint

if (theTheme.CanSelect) then

  theTheme.SelectByPoint(pnt, #VTAB_SELTYPE_NEW)

end


select by theme (Database Access extension)
Select By Theme

' this script is for the Database Access extension

' this script selects all the features in the Parcels DBTheme that

' are within 100 feet of the selected roads in the Roads DBTheme

' get your DBThemes from the view

theView = av.GetActiveDoc

roadsDBTheme = theView.FindTheme("Roads")

parcelsDBTheme = theView.FindTheme("Parcels")

' make sure roadDBTheme has selected features for SelectByTheme

theLog = roadsDBTheme.GetSelection

if (theLog = nil) then

  MsgBox.Info("Roads theme must have selected features.", "Can't Continue")

  exit

end

' select all land parcels within 100 feet of the selected roads

distInFeet = 100

parcelsDBTheme.SelectByTheme(roadsDBTheme, #FTAB_RELTYPE_ISWITHINDISTANCEOF,

             distInFeet, #VTAB_SELTYPE_NEW)

All distances in DBTheme requests must be in the appropriate units of measure for the theme's spatial column.

The units for a spatial column in SDE can only be feet or meters. You can store decimal degrees data in an SDE spatial column, but SDE will pretend that the coordinates are either in feet or meters. This may cause confusion when providing distances for requests, such as SelectByTheme. When working with decimal degree data the distance you provide must be the correct distance in decimal degrees. You can convert feet or meters into decimal degrees using the following request:

distInFeet = 100

DDdist = Units.Convert(distInFeet, #UNITS_LINEAR_FEET, #UNITS_LINEAR_DEGREES)

NOTE: If a projection is defined for the view in which the theme appears, the distance will be in the Map Units of that projection. For example, if the DBThemes above where projected with a Robinson projection, the distance value 100 would mean 100 meters. In this case you should NOT convert the units.


show sql (Database Access extension)
Show SQL

' this script is for the Database Access extension

' this script will pop up a message box which

' contains the SQL statement for the first

' selected Theme in the active view

' get the first selected theme from the active view

theThemes = av.GetActiveDoc.GetActiveThemes

if (theThemes.Count = 0) then

  MsgBox.Warning("There are no active themes","Warning")

  exit

end

' check to make sure that the theme is a DBTheme.

' If it is then get its query definition, otherwise

' inform user.

theTheme = theThemes.Get(0)

if (theTheme.Is(DBTheme)) then

  ' get the theme's query definition

  theQDef = theTheme.GetQueryDef

  ' get the SQL statement from the query definition

  SQLstr = theQDef.GetSQL

  MsgBox.Report(SQLStr,"SQL Statment")

else

  MsgBox.Error("Selected theme is not a DBTheme.", "Error")

end


spatially enabling an existing table (Database Access extension)
Spatially-enabling an Existing Table

' this script is for the Database Access extension

' this script appends a spatial column and shape data to an existing

' table the database.

' make a new connection

theServer = "tiffany:esri_av"

theUser = "avtest"

theDatabase = ""

thePassword = MsgBox.Password

theConnection = SDEConnection.Make(theServer, theDatabase, theUser, thePassword)

' create a new spatial column object that can have single- and

' multi-part area features in it

newSColName = "shape"

featureList = {#SDESCOLUMN_TYPE_AREA, #SDESCOLUMN_TYPE_MULTIPART}

newSCol = SDESColumn.MakeNew(newSColName, featureList)

if (newSCol = nil) then

  MsgBox.Error("New spatial column object not created.", "SDESColumn.MakeNew")

  exit

end

' You need to estimate the number of features the spatial column will hold,

' The average number of vertices they will have, and the spatial column's

' spatial index grid size (the grid size is the distance you want for the

' index grid's spatial resolution.). You also need to provide a coordinate

' reference rectangle which must cover the spatial extent of all features to

' be added to the spatial column. The SetCreationKeyword request refers to a

' set of parameters on the server which are used to further define the new

' SColumn. Refer to your SDE systems administrator to find out if this request is

' required to create tables on your SDE Server.

newSCol.SetNumShapes(100)

newSCol.SetAveragePoints(200)

newSCol.SetGridSizes({20,0,0})

newSCol.SetCoordRefByRect(Rect.Make(-180@(-90),380@180))

newSCol.SetCreationKeyword("avtest")

' get the table object from the database, then add the new spatial column

' to the table. You can't use the new spatial column object until you've added

' its definition to the database.

theTable = SDETable.Make(theConnection, "myTable")

ok = theTable.CreateSColumn(newSCol)

if (Not ok) then

  msgBox.Info("Column not created", "SDEDataset.AddLayer")

  msgBox.Info(theConnection.GetErrorMsg,"Error Message")

  exit

end

' get the shapefile from the active view

theView = av.GetActiveDoc

theTheme = theView.FindTheme("myTheme")

theFTab = theTheme.GetFTab

' edit the existing table's records, loading shapes from the FTab

' into the new spatial column. To edit existing records you need to be able

' to identify which record you are editing. Therefore, both the table and

' the FTab must have a primary key field in common.

ftabShapeField = theFTab.FindField("Shape")

ftabKeyField = theFTab.FindField("aKeyField")

aQDef = QueryDef.Make(theConnection)

' It is VERY IMPORTANT to note that only one column is specified with the

' SetSelectColumns request since only one column is to be edited. When a

' RecordSet is edited (anRSet.Edit) ALL fields in the RecordSet will be updated

' even if some of the fields were not intended to be changed. This may cause

' incorrect data values to be added to your database. One way to prevent this,

' is to ALWAYS only include the fields to be edited in a RecordSet that you wish

' to perform edits with (SEE other methods for avoiding this problem below)

aQDef.SetSelectColumns({"Shape"})

aQDef.SetFromTables({"mytable"})

r = aQDef.OpenRecordSet

dbShapeField = r.FindField(newSColName)

theConnection.BeginTrans

for each rec in theFTab

  keyValue = theFTab.ReturnValue(ftabKeyField, rec)

  theShape = theFTab.ReturnValue(ftabShapeField, rec)

  ' The field or fields that you use to define the SQLWhereClause in the

  ' anRS.Edit request do not need to be in the RecordSet that you are editing

  ' In this case the "KeyField" field is used in the where clause yet the

  ' RecordSet that is being edited only contains the "shape" field

  r.Edit("aKeyField = "+keyValue.AsString)

  r.SetValue(dbShapeField, theShape)

  ok = r.Update

  if (not ok) then

    msgbox.info(rec.asstring, "Can't store shape in the database")

    msgbox.info(theConnection.GetErrorCode.AsString, "Error Code")

  end

  theConnection.CommitContinue

end

' The EndUpdate request should always be executed after

' updating the database using the AddNew and Edit requests.

' This request makes sure that all updates have been sent to

' the database.

r.EndUpdate

theConnection.CommitTrans

r.Close

' NOTE: If you are updating an RDBMS table with a recordset and you

' must include fields in this recordset that you do not plan to change,

' you should use the anRS.GetRow request before each edit. When you issue

' the anRS.Update request, you are updating all fields in the recordset

' including the fields that you have not set values for (anRS.SetValue).

' The fields that have not had values set for them (anRS.SetValue) will

' be given whatever value was set previously for these fields (ie a

' value from a previous edit or a nil value).The request anRS.GetRow

' sets the defaults for all fields to be the values in the current row.

' If the current row is the row that you are editing, then when you

' perform an update, you are sure that the fields that have not been edited

' will be set back to the original value.


updating values (Database Access extension)
Updating Values

' this script is for the Database Access extension

' this script locks all selected features in a DBTheme, starts a

' transaction on the dataset, and exports the selected features'

' attributes to a local dBASE file.

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Rivers")

theSCol = theDBTheme.GetSColumn

theConnection = theDBTheme.GetQueryDef.GetConnection

if (theDBTheme.CanExportToFTab.Not) then

  MsgBox.Info("Rivers theme must have a selection.", "Can't Export Values")

  exit

end

' try to lock the selected features

theLog = theDBTheme.GetSelection

area = theLog.ReturnExtent

canModify = true

ok = theSCol.LockArea(area, canModify)

if (ok.Not) then

  msgbox.error("Can't lock selected features.", "SColumn.LockArea")

  msgbox.info(theConnection.GetErrorMsg, "Error Message")

  exit

end

' start a transaction that will last for the life of your arcview session

ok = theConnection.BeginTrans

if (not ok) then

  msgbox.Error("Can't start transaction.", "Connection.StartTrans")

  msgbox.Info(theConnection.GetErrorMsg, "Error Message")

  theSCol.FreeLock

  exit

end

' create a local table of attributes for the selected features, and add

' the table to your project. The exported table Must have a Primary Key.

' In this case (Rivers), it is a field called "anint"

fName = theDBTheme.GetName.Substitute(" ","_")+".dbf"

theVTab = theDBTheme.ExportToVTab(fName.AsFileName, dBASE)

theTable = Table.Make(theVTab)

theTable.SetName(fName)

theTable.GetWin.Open

'Make the changes you want to the attribute values in the exported table. When you're finished, run the script below.

' this script updates the DBTheme's source layer with the

' attribute changes made to the previously exported table, prompts

' you to save or discard the changes, appropriately commits or

' rolls back the transaction, and unlocks the layer

theView = av.GetActiveDoc

theDBTheme = theView.FindTheme("Rivers")

theConnection = theDBTheme.GetQueryDef.GetConnection

fName = theDBTheme.GetName.Substitute(" ","_")+".dbf"

theVTab = av.FindDoc(fName).GetVTab

theVFlds = theVTab.GetFields

' prompt to save edits

change = MsgBox.YesNo("Save edits to the dbtheme's table?", "", false)

if (change) then

  ' Getting the select fields from the vtab in this

  ' way ensures that the order in which the fields are

  ' listed in the recordSet is the same as the order in

  ' which the fields appear in the vtab. Because of this we

  ' can update one row at a time using the anRS.SetRow

  ' request.

  theDBFlds = {}

  for each f in theVFlds

    theDBFlds.Add(f.GetName)

  end

  aQDef = theDBTheme.GetQueryDef.Clone

  aQDef.SetSelectColumns(theDBFlds)

  ' Apply the edits

  r = aQDef.OpenRecordSet

  for each rec in theVTab

    ' Here we assume that there is a key field called "anint" in

    ' the database

    keyVal = theVTab.ReturnValue(theVTab.FindField("anint"), rec).AsString

    r.Edit("anint = "+keyVal.AsString)

    rowList = {}

    for each f in theVFlds

      rowList.Add(theVTab.ReturnValue(f, rec))

    end

    r.SetRow(rowList)

    ok = r.Update

    if (ok.Not) then

      MsgBox.Info("The Database was not updated","Error")

      MsgBox.Info(theConnection.GetErrorMsg,"SDE Error Message")

      r.Close

      theDBTheme.GetSColumn.FreeLock

      exit

    end

    theConnection.CommitContinue

  end

  ' The EndUpdate request should always be executed after

  ' updating the database using the AddNew and Edit requests.

  ' This request makes sure that all updates have been sent to

  ' the database.

  r.EndUpdate

  r.Close

  ' commit edits to the relational database

  theConnection.CommitTrans

else

  ' rollback edits to the relational database

  theConnection.Rollback

end

' remove lock on layer

theDBTheme.GetSColumn.FreeLock


using spatial constraints (Database Access extension)
Using Spatial Constraints

' this script is for the Database Access extension

' This script will define a query definition for

' features that are within a given radius from an

' x,y location using a spatial filter constraint.

' This query definition would be used to define

' dbthemes with only the features that satisfy

' the spatial constraint.

theCon = SDEConnection.Make("tiffany:esri_av","","avtest","avtest")

theQDef = SDEQueryDef.Make(theCon)

' Make a spatial column object from the layer that the

' theme is going to be made from

theSCol = SDESColumn.Make(theCon,"world.cntry94","feature")

' Make the circle, and the spatial filter to apply to the

' query definition for the theme

blastr = Circle.Make(22.7@(-0.68),10)

theFilt = SDESFilter.Make(theSCol,blastr,#SDESPATIAL_SEARCH_INTERSECTAREA)

' make the query definition

theQDef.SetSelectColumns({"world.cntry94.feature","world.cntry94.name","world.cntry94.area","world.demog.tot_pop"})

theQDef.SetFromTables({"world.cntry94","world.demog"})

theQDef.SetWhereClause("world.cntry94.fips_code = world.demog.fips_code")

' specify the spatial filters for the query definition

theQDef.SetSFilters({theFilt})

' make the DBTheme and add it to the view

t = DBTheme.Make(theQdef,theSCol,Polygon)

v = av.FindDoc("View1")

v.AddTheme(t)

t.SetVisible(true)

' draw the filter circle

gl = v.GetGraphics

gl.Add(GraphicShape.Make(blastr))

v.Invalidate


working with blob values (Database Access extension)
Working With Blob Values

' this script returns an image blob from your DBTheme's source

' layer, and displays that image in your view. It is very important

' to maintain another field indicating what data the blob field

' stores, since blobs can be any data in any format.

theView = av.GetActiveDoc

myServer = "abbey"

myDatabase = ""

userName = "avtest"

myPassword = "avtest"

theCon = SDEConnection.Make(myServer,myDatabase,userName,myPassword)

theTable = SDETable.Make(theCon,"images")

' we want to add the TIFF images representing the study area of Seattle

' to the view. getvalue stores the image locally, and returns the new

' filename of the image.

localNames = {}

theWhere = "type like '%TIFF%' and description like '%Seattle%'"

theRSet = theTable.OpenRecordSet(theWhere)

field1 = theRSet.FindField("type")

field2 = theRSet.FindField("name")

field3 = theRSet.FindField("description")

field4 = theRSet.FindField("image")

while (theRSet.Next)

  theName = theRSet.GetValue(field2)

  localName = theRSet.GetValue(field4)

  msgbox.info("Local filename: "+localName.AsString, theName)

  localNames.Add(localName)

end

' new filename doesn't have correct file extension for the image type;

' need to SetExtensionChecking off to make the Image Source object

ISrc.setExtensionChecking(false)

for each n in localNames

  ' make the new image theme, add it to the view

  theISrc = ISrc.Make(n.AsString.AsSrcName)

  theITheme = ITheme.Make(theISrc)

  theView.AddTheme(theITheme)

end

ISrc.setExtensionChecking(true)


working with shapes (Database Access extension)
Working with Shapes

' this script is for the Database Access extension

' this script buffers all the rivers in the rivers dbtheme that belong to the

' Mississippi System to a distance of 5000 meters, and adds the buffer to the

' view as a graphic

theView = av.GetActiveDoc

theGraphicList = theView.GetGraphics

theDBTheme = theView.FindTheme("Rivers")

newQuery = theDBTheme.GetQueryDef.Clone

' change the selected columns to be only the spatial column for performance.

' Get the name of the spatial column from the theme's SColumn object

theCols = newQuery.GetSelectColumns

if (theCols.Count > 1) then

  theSCol = theDBTheme.GetSColumn

  scolName = theSCol.GetSColumnName

  newQuery.SetSelectColumns({scolName})

end

' modify dbtheme's query to find all the rivers of the Mississippi System

theWhere = newQuery.GetWhereClause

if (theWhere = "") then

  newQuery.SetWhereClause("System = 'Mississippi'")

else

  newQuery.SetWhereClause(theWhere ++ "and" ++ "System = 'Mississippi'")

end

' open a record set containing all the rivers satisfying the query

theRSet = newQuery.OpenRecordSet

' buffer the first shape in the record set first convert 5000 meters

' to degrees (NOTE: this only needs to be done if there is no projection

' set for the view and the data is stored on the SDE server in Decimal

' degrees. If the view has a projection, then the distance is in the Map Units

' of the projection)

distance = units.convert(5000, #UNITS_LINEAR_METERS, #UNITS_LINEAR_DEGREES)

sField = theRSet.FindField(scolName)

if (theRSet.Next) then

  theShape = theRSet.GetValue(sField)

  wholeBuffer = theShape.ReturnBuffered(distance)

else

  msgbox.info("No Rivers found.", "")

  exit

end

' buffer each other shape in the record set, and

' union the buffer with the first buffered shape

while (theRSet.Next)

  theShape = theRSet.GetValue(sField)

  shapeBuffer = theShape.ReturnBuffered(distance)

  wholeBuffer = wholeBuffer.ReturnUnion(shapeBuffer)

end

' create new symbol for the buffer graphic

newSym = RasterFill.Make

newSym.SetStyle(#RASTERFILL_STYLE_EMPTY)

newSym.SetOlColor(Color.GetBlue)

newSym.SetOlWidth(2)

' add final buffer shape to your view as a graphic shape

g = GraphicShape.Make(wholeBuffer)

g.SetSymbol(newSym)

theGraphicList.Add(g)

theGraphicList.Invalidate


Attribute editing Sample Extension (Database Access extension)
Directly editing a feature's attributes

Description:  This extension lets you edit a database themes attributes without creating a local file. Since the RDBMS tables are edited directly, field types that can’t be represented in ArcView tables (i.e., Blob fields) can be updated using this extension.

When this extension is loaded, a button with an eye glass icon is added to the View. Clicking this button opens a modeless dialog containing the following controls:

Arrow Icon tool - Click this tool, then use it in the view to select the feature in the active database theme whose attributes you want to edit. The attributes of the selected feature are then displayed in the ListBox on the dialog.

ListBox - Displays the attribute names and values for the selected feature in the active database theme. To change an attribute value, click one of the attributes in this ListBox. If you can edit this feature (i.e., you have correct privilages, it isn’t locked and you can start a transaction) the field name and value are displayed in the Field TextLabel and Value TextLine controls at the bottom of the dialog.

Field TextLabel and Value TextLine - These controls display the field name and value of the selected attribute in the ListBox. Edit attributes in the Value TextLine control. Hitting carriage return after editing the attribute value updates the ListBox control with the changes that have been made.

Apply Button - When all edits have been made, update the database by clicking Apply. When the updates are completed, select another feature to edit with the arrow icon tool.

Undo Button - Lets you undo the changes you made to the selected feature. When the updates are undone, make new edits on the current feature or select another feature to edit with the Arrow Icon tool.

Done Button - Closes the dialog and ends the attribute editing session.

Notes:

- Only non-joined database themes can be edited, since the Database Access extension doesn’t  allow editing of joined features.

- Blob fields can be updated be providing a path to a file whose contents you wish to store in the RDBMS as a blob. To avoid possible errors, make sure that the blob field is the last field listed in the ListBox control.

- When updating Date fields, use the default date format of the current ArcView session. This format may be set using the Date.SetDefFormat request in a script before clicking the eye glass button.

Requires:  The Database Access extension, The Dialog Designer extension.

FileName:  sde3aedt.avx


SDE3 Changing a database theme's connection Sample Script (Database Access extension)
Changing a database theme’s connection

Source Code

Description: This script allows you to remove duplicate connections from a project by changing the connection object from which a database theme is created.  Once a connection has been changed, the original connection is destroyed if no other objects (database table/theme) exist in the project. This is particularly useful if you are saving database themes in odb files since must create a new connection whenever you open a file and restore a database theme.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3chgc.ave


SDE3 Changing a database theme's connection Source Code
' Changing a database theme’s connection

'

' This script allows you to change a database theme’s connection to another

' connection object from the same SDE server and database. You will first be

' prompted for the database theme whose connection you want to use and then for

' the database theme whose connection you want to change. ArcView will remove

' the changed database theme's original connection object if no other objects

' (ie database tables/themes) belonging to that connection exist.

'

' The script can be used to remove multiple connection objects that refer to the

' same SDE Sever source.

' Get the DBThemes in the View

viwActive = av.GetActiveDoc

lstThms = viwActive.GetThemes

lstDbth = {}

for each t in lstThms

  if (t.Is(DBTheme)) then

    lstDbth.Add(t)

  end

end

if (lstDBth.Count = 0) then

  MsgBox.Error("There are no DBThemes in the active view","SDE3Merg")

  Return nil

end

' Pick the database theme whose connection you want to use - the TO connection

thmCon = MsgBox.ListAsString(lstDbth,"Select the theme whose connection you want to use","SDE3Merg")

if (thmCon = nil) then

  MsgBox.Error("No merge to theme selected","SDE3Merg")

  Return nil

end

' Pick the database theme whose connection you want to change - the CHANGE

'connection

lstDbth.RemoveObj(thmCon)

thmChg = MsgBox.ListAsString(lstDbth,"Select the theme whose connection you want change","SDE3Merg")

if (thmChg = nil) then

  MsgBox.Error("No change theme selected","SDE3Merg")

  Return nil

end

' Change the connection

ok  = thmChg.UseConnectionFrom(thmCon)

if (not ok) then

  MsgBox.Error("Can't merge connections. Make sure that"+nl+

  "the To and change connections are from the same server/database","ERROR")

end


SDE3 Counter Sample Script (Database Access extension)
Totaling the records represented by a database table

Source Code

Description:  Use this script to count the total number of records that a database table’s query will return. Execute this script on database tables that don’t display all the records selected by their query.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3cntr.ave


SDE3 Counter Source Code
' Totaling the records represented by a database table

'

' This script reports the total number of records that the SQL

' Query associated with the active DBTable will return. This number

' will not be the same as the total number of records in the DBTable Doc

' if you can still retreive more rows.

' Make sure that the active Document is a valid DBTable

dbtActive = av.GetActiveDoc

if (dbtActive.Is(DBTable).Not) then

  MsgBox.Info("Active Doc must be a DBTable","Sample.TableCount")

  return nil

end

if (dbtActive.HasError) then

  MsgBox.Info("The Active DBTable has errors","Sample.TableCount")

  return nil

end

' Report the number of records

numCnt = dbtActive.GetNumRecords

MsgBox.Info("Total Number of records:"++numCnt.AsString,"Sample.TableCount")


Feature editing Sample Extension (Database Access extension)
Editing features with the Check Out, Check In method

Description:  This extension lets you edit spatially enabled SDE data in ArcView using a check out / check in approach. Check out exports a spatially enabled SDE table to a shapefile. Edit the shapefile, then apply these changes to the database with check in. While you’re editing the shapefile, the corresponding SDE features are locked so no one else can change them.

This extension adds a menu called "SDE 3.0 editing" to the view GUI with the following menu choices:

Check Out - Creates a shapefile from all features in the active database theme. A theme representing the new shapefile called "Checked Out Features" is added to the view as the editable theme. A red box outlining the area that can be edited is displayed in the view. To edit a database theme, it can’t contain a join, must not be a multipoint theme and must not contain a BLOB field. The shapefile is located in the temp directory ($TEMP) and is called sdeedit1.shp.

Undo Check Out - Ends the editing session without applying any of the changes made to the Checked Out Features theme. The active view is returned to the state that it was in before the editing session began.

Check In - Applies the changes made to the Checked Out Features theme to the corresponding spatially enabled table in the SDE database. Once the updates are performed, the active view is returned to the state that it was in before the editing session began. If there is a problem during the update process, an error shapefile called (<theme name>sdeerr.shp) is created in the current working directory; this shapefile contains the row(s) causing the update error and the error code that was generated on update.

Notes:

- Do not change the theme properties of the theme called "Checked out Features", particularly. These properties are required for the check in process.

- When working with the project file used to create the extension (sde3edit.apr), you will get an error when you make a view active. To avoid this, comment all the lines in the scripts called "SDEEdit.CheckInUpdate" and "SDEEdit.CheckOutUpdate", which assume that there is a theme in the active view.

- If the theme called "Checked Out Features" is deleted from the view, the editing session will end without the edits being applied.

- The extension does not work with layers that contain Z or M shapes.

Requires:  The Database Access extension.

FileName:  sde3edit.avx


Linking database tables and database themes sample script (Database Access extension)
Linking database tables and database themes

Source Code

Description: These two scripts can be used to mimic the link between a regular theme and it’s attribute  table. The first script creates a database table made up of the records that correspond to the selected features in a database theme. The second script uses the records in a database table to select features in the associated database themes. Both of these scripts are contained in the sde3link.ave file.

The query that defines the database theme must not have a where clause.

The scripts are independent, so one script can be used without needing to use the other.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3link.ave


Linking database tables and database themes source code
' Linking database tables and database themes

'

' Part 1 - Makes a database table based on a selection the active database

' theme.

' This script updates (or creates if it doesn't exist) a table called "<theme

' name>Temp Selection Table" that contains a record for each selected feature in

' the active database theme. It assumes that the database theme does NOT have a

' where clause defined.

'

' The table created by this script is re-used so you must rename the database

' table before running the script again in order to save it.

'

' This script is executed on a View containing database themes

theView=av.GetActiveDoc

theActThemes=theView.GetactiveThemes

if (theActThemes.Count = 0) then

  return(nil)

end

thetheme=theActThemes.Get(0)

if (theTheme.is(DBTheme).NOT) then

  Return(Nil)

end

' Make sure your database theme has selected features.

theLog = theTheme.GetSelection

if (theLog = nil) then

  msgBox.Error("Your database theme must have selected features","")

  Return(Nil)

end

' Clone the Querydef and re-set the select columns to

' SE_ROW_ID. SE_ROW_ID is a special field maintained by SDE

' that contains a unique value for each feature in the

' table.

theQuery = theTheme.GetQueryDef

theClonedQuery = theQuery.Clone

theClonedQuery.SetSelectColumns({"SE_ROW_ID"})

theClonedQuery.SetSrcDest(theLog,nil,false)

' Build a query string that includes only the selected features in the

' database theme. This is done using the id's of the selected features which

' can be read from the cloned querfdef.

r = theQuery.OpenRecordSet

r2 = theClonedQuery.OpenRecordSet

fldSClr2 = r2.FindField("SE_ROW_ID")

r2.Next

qStr = theQuery.GetSQL++"where feature = "+r2.GetValue(fldSClr2).asstring

while (r2.Next)

  qStr = qstr++"or"++"feature = "+r2.GetValue(fldSClr2).AsString

end

r.Close

r2.Close

' Create a database table using the query string

aQueryDef=QueryDef.Make(theTheme.GetQueryDef.GetConnection)

aQueryDef.SetSQL(qstr)

theDBTable=av.GetProject.FindDoc(theTheme.GetName++"Temp Selection Table")

oldpost=NIL

if (theDBTable<>NIL) then

  if (theDBTable.Is(DBTABLE).not) then

    MsgBox.Error("The table"++theTheme.GetName++"Temp Selection Table, is not a DBTABLE","ERROR")

    Return(nil)

  end

  oldpost=theDBTABLE.GetWin.ReturnOrigin

  av.GetProject.RemoveDoc(theDBTable)

end

theDBTable = DBTable.Make(aQueryDef)

theDBTable.SetName(theTheme.getname++"Temp Selection Table")

' Position the table in it's original location

DBWin = theDBTable.GetWin

DBWin.Activate

DBWin.SetTitle(theTheme.getname++"Temp Selection Table")

if (oldpost<>NIL) then

  DBWIN.moveto(oldpost.getx,oldpost.gety)

end

' Part 2 - Changes a database theme's selection to correspond to the records

' in a database table.

' This script finds all of the database theme's whose querydef is identical to

' the database table's querydef minus the where clause. When it finds a matching

' database theme, the themes selection is modified to reflect the records in the

' database table and a message box specifying the modified theme and view is

' displayed.

'

' This script is executed on a database table

theDBTable=av.GetActiveDoc

if (theDBTable.Is(DBTABLE).Not) then

  Return(nil)

end

theQueryDef=theDBTable.GetQueryDef

' Separate the where clause from the rest of the query

oldSQL=theQueryDef.GetSQL

qdeflist=oldsql.AsList

newSQL=""

aWhere=FALSE

whereSQL="("

for each apart in qdeflist

 if (aWhere=TRUE) then

   whereSQL=whereSQL++apart

   continue

 end

 if (apart="where") then

   aWhere=TRUE

   continue

 end

 newSQL=newSQL++apart

end

whereSQL=whereSQL+")"

' Find all of the database themes in the project that match the database table's

' SQL query and record the theme and view in a dictionary.

viewDict=Dictionary.Make(100)

for each adoc in av.GetProject.GetDocs

  if (adoc.is(View)) then

    themeList={}

    for each atheme in adoc.GetThemes

      if (atheme.is(DBTHEME)) then

        if (atheme.GetQueryDef.GetSQL.trim=newSQL.trim) then

          themeList.Add(aTheme)

        end

      end

      viewDict.Add(adoc,themeList)

    end

  end

end

' Update the selection of each matching theme using the "where" part

' of the database tables SQL statement. Display a message box to indicate

' which theme has been updated.

for each aView in viewDict.ReturnKeys

  if (viewDict.Get(aView).Count > 0) then

    for each atheme in viewDict.Get(aView)

      aTheme.SelectByAttributes (whereSQL, #VTAB_SELTYPE_NEW)

      MsgBox.Info(atheme.GetName,aView.GetName)

    end

  end

end


SDE3 Flip Selection Sample Script (Database Access extension)
Switching a database theme's selected features

Source Code

Description: This script changes the active database theme’s selection, the unselected features become the selected set. The effect is similar to the table’s system script Table.SwitchSelection. This script can be added to the view GUI by making it the click script for a new button in the button bar.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3nsel.ave


SDE3 Flip Selection Source Code
' Switching a database theme's selected features

'

' Changes the selection so that the features that are currently unselected

' become the selected set. This script assumes that the active document is a

' view with only 1 active dbtheme in it.

'

' Get the Active DBTheme and its querydef

viwActive = av.GetActiveDoc

lstThmAct = viwActive.GetActiveThemes

if (lstThmAct.count <> 1) then

  MsgBox.Info("Please make 1 DBTheme active","SDE3NSel")

  Return nil

end

dthAct = lstThmAct.Get(0)

if (dthAct.Is(DbTheme).Not) then

  MsgBox.Info("The active theme must be a DBTheme","SDE3NSel")

  Return nil

end

strDbthTable = dthAct.GetSColumn.GetTableName

qdfDbth = dthAct.GetQueryDef

conDbth = qdfDbth.GetConnection

' get the current selection logfile

logDbth = dthAct.GetSelection

' make a new logfile

logNewName = SDELog.MakeLogName(conDbth)

logNew = SDELog.Make(conDbth, logNewName, strDbthTable ,#SDELOG_MODE_CREATE)

' populate the new log with All the features in this querydef

qdfDbth2 = qdfDbth.Clone

qdfDbth2.SetSrcDest(nil, logNew, false)

anRS = qdfDbth2.OpenRecordSet

anRS.Close

' subtract the features in the selection log from the new log

strLogDbth = logDbth.GetName

logNew.Combine(strLogDbth, #SDELOG_COMBINETYPE_DIFFERENCE)

' Make the new log the selection log and redraw

dthAct.SetSelection(logNew)

dthAct.Invalidate(true)

viwActive.GetDisplay.Flush


SDE3 Save Password Sample Script (Database Access extension)
Saving login information in the project file

Source Code

Description: This script saves the password of each selected connection to the project file. When the script is executed, pick from a list of the active open connections in your project. The next time the project is restored, the selected connections will be restored automatically - you won’t need to log in.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3savp.ave


SDE3 Save Password Source Code
' Saving login information in the project file

'

' This script lists the connections in the current ArcView

' session and allows you to save the passwords to the project file

' for several of the connections at once. When this is done, the

' user does not have to connection info when the project is opened.

' NOTE: make sure that when you connect, you specify the instance. If

' you let this default (ie. esri_sde) then the connection will not be

' properly restored on project open if its password is saved to the project.

' Check to see if there are any connections, If not exit

lstCon = SDEConnection.GetALLConnections

if (lstCon.Count = 0) then

  MsgBox.Info("Must have at least one open connection","SDE3SavP")

  Return nil

else

  ' Get the connections for which the Password is to be saved.

  lstConStr = {}

  for each c in lstCon

    lstConStr.Add(c.getconnectionstring+":"+

                 c.getdatabasename+":"+

                 c.getusername)

  end

  lstConSave = MsgBox.MultiListAsString(lstConStr, "Pick connections for password save","SDE3SavP")

  if ((lstConSave = nil) or (lstConSave.Count = 0)) then

    Return nil

  end

end

' Save each password to the current project

strSaved = ""

for each strSave in lstConSave

  conSQL = lstCon.Get(lstConStr.Find(strSave))

  if (conSQL.HasError) then

    MsgBox.info("Connection"++strSave++"has Error, not save to project","SDE3SavP")

    continue

  end

  conSQL.SavePassword(True)

  strSaved = strSaved + strSave + nl

end

' Report which passwords were saved successfully

MsgBox.Report(strSaved,"Passwords saved for connection(s)")


SDE3 Split Polygon Sample Script (Database Access extension)
Splitting polygons in a database theme

Source Code

Description:  This script splits a polygon feature in the active database theme with a user defined line that bisects the feature. Before running the script, draw a graphic line that intersects a polygon in at least two places, make sure it is the only graphic selected. When the script is executed, the original polygon is split into two output polygons. Each output polygon may be a multipart polygon depending on how many times the split line intersects the original polygon. The original attribute values, including area, become the attributes of both output polygons.

The database theme must be a polygon theme and must not contain attributes from joined tables.

If more than one polygon is intersected by the graphic line, the first of these polygons found by SDE will be the one that is split.

This script does not work with layers that contain Z or M shapes. The script can be modified to work with Z or M layers, but note that some Avenue requests (i.e. aPolygon.Split) do not maintain Z or M data values.

Name:

Requires:  ArcView Database Access extension

Self:

Returns:

FileName:  sde3splp.ave


SDE3 Split Polygon Source Code
' Splitting polygons in a database theme

'

' Uses the selected graphic line to split a polygon in the active

' theme. The attributes of the split polygon are preserved in the

' resulting 2 polygons.

' Get the script name

strScript = Script.The.GetName

' get the selected split polyline drawn by the user

' on the view

theView = av.GetActiveDoc

theDisplay = theView.getDisplay

theGraphics = theView.getGraphics

if (theGraphics.HasSelected.Not) then

  MsgBox.Error("No selected Graphics","Error")

  Return nil

end

theSelectedG = theGraphics.getSelected.get(0)

theGShape = theSelectedG.getshape

if (theGshape.is(line)) then

  theGshape=theGshape.aspolyline

elseif (theGshape.is(polyline).not) then

  MsgBox.error("The selected graphic should be a line or polyline.  Exiting.","Error")

  Return nil

end

' get active dbtheme. Assumes the 1st active theme is a database theme

theTheme = theView.GetActiveThemes.Get(0)

if (theTheme.is(dbtheme).not) then

  msgbox.error("The active theme is not a Database Theme, Exiting.","Error")

  Return nil

end

if (theTheme.GetShapeClass.GetClassName <> "Polygon") then

  msgbox.error("The database theme is not a Polygon Theme, Exiting.","Error")

  Return nil

end

theCon = theTheme.GetQueryDef.GetConnection

if (theCon.IsConnected.Not) then

  msgbox.info("Required connection isn't active. Exiting...","Check In")

  Return nil

end

theTheme.ClearSelection

' Select the feature that is to be split and get the selection log

theTheme.selectbyShapes({theGshape},#VTAB_SELTYPE_NEW)

anSDElog = theTheme.GetSelection

' Lock the Area around the split line

theSCol = theTheme.GetSColumn

aLock = theSCol.LockArea(theGShape.ReturnExtent,True)

if (aLock.Not) then

  MsgBox.Info("Cannot lock area, exiting",strScript)

  Return nil

end

' Find the shape that is intersected

theQuery = theTheme.GetQueryDef

sFldName = theTheme.GetSColumn.GetSColumnName

theQuery.SetSrcDest(anSDElog,nil,false)

anRS = theQuery.OpenRecordSet

sFld = anRS.FindField(sFldName)

aRowId = nil

while(anRS.Next)

  shpRS = anRS.GetValue(sFld)

  lstPoints = ShpRS.PointIntersection(theGShape)

  if (lstPoints.Count < 2) then

    continue

  else

    ' Get the SDE ID of the feature

    aPnt = shpRS.ReturnCenter

    aRowId = theTheme.FindByPoint(aPnt).Get(0)

    rowOrig = anRS.GetRow.DeepClone

    shpOrig = shpRS.Clone

    Break

  end

end

anRS.Close

' Make sure that there is a feature to be split

if (aRowId = nil) then

  MsgBox.Warning("Line does not intersect the selected feature",strScript)

  theCon.FreeAllLocks

  Return nil

end

' Split the cloned polygon with the line

lstPolys = {}

lstPolys = shpOrig.Split(theGShape)

' start transaction

if (theCon.BeginTrans.Not) then

  MsgBox.Warning(theCon.GetErrorMsg, strScript)

  theCon.FreeAllLocks

  exit

end

' add the split polys and attributes to the database

theQuery.SetSrcDest(nil,nil,false)

r = theQuery.OpenRecordSet

if (r.CanUpdate.Not) then

  MsgBox.Error("Cannot edit the DBTheme, make sure the theme does not has a join",strScript)

  theCon.FreeAllLocks

  theCon.RollBack

  Return nil

end

r.AddNew

for each n in 0..1

  spShp = lstPolys.Get(n)

  numFactor = ((spShp.ReturnArea)/ShpOrig.ReturnArea)

  msgbox.info((numFactor * 100).AsString, "% of total area")

  indpoly = rowOrig.FindByClass(Polygon)

  rowOrig.Set(indpoly,spShp)

  r.SetRow(rowOrig)

  ok = r.Update

  if (ok.Not) then

    theCon.RollBack

    theCon.FreeAllLocks

    r.Close

    MsgBox.Error("New feature not added, aborting",strScript)

    theView.Invalidate

    av.PurgeObjects

    Return nil

  end

end

' delete the Old feature

ok = r.delete(sFldName++"="++aRowID.AsString)

if (ok.Not) then

    theCon.RollBack

    theCon.FreeAllLocks

    r.Close

    MsgBox.Error("Old feature not Deleted, aborting",strScript)

    theView.Invalidate

    av.PurgeObjects

    Return nil

end

r.Close

' choose to commit or rollback the transaction

c = MsgBox.YesNo("Select Yes to commit transaction, No to rollback", strScript, TRUE)

if (c) then

  if (theCon.CommitTrans.Not) then

    MsgBox.Warning("Could not commit the changes",strScript)

  end

else

  if (theCon.RollBack.Not) then

    MsgBox.Warning("Could not rollback the changes", strScript)

  end

end

' unlock features in layer (Free up locks)

if (theCon.FreeAllLocks.Not) then

  MsgBox.Warning("Could not free the locks", strScript)

end

' Clean up

theTheme.clearSelection

theView.invalidate


Tools for SDE Sample Extension (Database Access extension)
Tools for loading, manipulating, and analyzing SDE data

Description: This extension lets you perform operations on SDE data. When loading, the extension adds a menu called "SDE 3.0 Tools" to the view and project DocGUI. Use these tools to get information, add, and update data.

The "SDE 3.0 Tools" menu in the view DocGUI contains the following choices:

List SColumn - Lists all the spatial columns for which you have read access.

SColumn Info - Lists how many shapes of each SDE feature type exists in the active database theme's spatial column.

** DBTheme Extent - Returns coordinates describing the extent of features currently in the active database theme.

** Buffer Selected Features - Buffers selected features in the active database theme. Enter the buffer distance in the units in which the data is stored; for example, enter a distance in decimal degrees if the database theme contains decimal degrees shapes.

* Apply Spatial Filter - Creates a spatial filter from the first selected graphic, and applies it to the database theme. Only shapes, that have the spatial relationship you choose with the graphic remain in the theme. To apply a second spatial filter to this theme, select a different graphic, then choose this menu option again.

* Remove Spatial Filter - Removes all spatial filters from the active database theme.

* Load New SColumn - Loads an FTheme in the view into a new SDE table with a spatial column. Records that fail to load will be recorded in a shapefile called <ThemeName>,sdeerr.shp located in the current working directory; a field called Errors will be added containing the error that occurred.

* Append to SColumn - Loads an FTheme in the view into an existing SDE table with a spatial column. The FTheme's fields and the columns must have the same name and data type. Records that fail to load will be recorded in a shapefile called <themeName>sdeerr.shp, located in the current working directory; a field called Errors will be added containing the error that occurred.

Delete Selected Features - Permanently deletes selected features and their attributes from the SDE database. You must specify which attribute column uniquely identifies each selected feature.

Delete SColumn - Permanently deletes an SDE table's spatial column; the rest of the table remains unchanged. Afterwards, themes relying on this spatial column will be invalid.

The "SDE 3.0 Tools" menu in the project Doc GUI contains the following choices:

Communication Check - For PC platforms only. Checks entries in the Hosts file for your SDE server. Checks the Services file SDE default instance name, esri_sde, and port number 5150/tcp.

List Connections - Lists active connections in your current project.

List Tables - Lets you choose an access privilege, then lists the tables for which you have that privilege; for example, you can list the tables that you have permission to update. The tables may have spatial columns.

Table count records - Counts how many records are in the selected table in the database.

SQL Select - Enter a valid SQL Select statement into the dialog. The dialog creates a database table using this statement. The database table will be empty if the statement returns an error.

Load Table - Creates a new table in SDE representing the contents of an ArcView table.

Append Table - Loads data from an ArcView table into an existing SDE table. Columns in the ArcView and SDE tables must have the same name and data type.

Delete Table - Deletes an SDE table from the database.

Requires:  The Database Access Extension. A view DocGUI named "View" (the default) and a project DocGUI named "Project" (The default).

FileName:  sde3tls.avx

* Will not work when used with Z or M shapes. The scripts can be modified accept Z or M shapes using Avenue.

** Will work with Z or M shapes, but only the x and y coordinates are used.