# DataSource

> Source: https://manual.pvxplus.com/views-system/views-definition-object/datasource

**DataSource** is a subordinate object used to define the primary data source for the view or data sources defined in relationships. It will create groups of **[DS_Item](https://manual.pvxplus.com/views-system/views-definition-object/ds-item)** and **[DS_Link](https://manual.pvxplus.com/views-system/views-definition-object/ds-link)** objects to do this. The main **DataSource** object corresponds to a record in the *pvxview.src* file.

For information on the *pvxview.src* file structure, see **[Views System File Structures](https://manual.pvxplus.com/views-system/views-system-file-structures/overview#src)**. Properties are read only and are set using corresponding **Set*xxx*( )** methods.

## DataSource Properties

The following table lists the properties of the **DataSource** subordinate object:

| **Property** | **Description** |
| --- | --- |
| **Description$** | Data source name - short description of data source (used to identify the data source). |
| **Expression_Ind$** | Expression indicator for *PrimarySource$.*   <br>  <br>"=" denotes *PrimarySource$* contains an expression to be evaluated.  <br>  <br>A blank indicates that the value of *PrimarySource$* is a fixed value ***(Default)***. |
| **InternalID$** | Internal identifier for the data source. |
| **InitLogicType$** | Single character string indicating logic type:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| C \| Call \|<br>\| X \| Execute \|<br>\| I or blank \| Ignore ***(Default)*** \| |
| **InitLogic$** | Logic to be executed when a data source object is established. Reference based on **InitLogicType$**.  <br>  <br>If type C, **InitLogic$** contains *program; entrypoint*.  <br>  <br>If type X, **InitLogic$** contains PxPlus statement(s) to be executed. String, 128 characters. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **CloseLogicType$** | Same as for **InitLogicType$**. |
| **CloseLogic$** | Logic to be executed when a data source object is dropped. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **LongDescription$** | Long description for storing notes about the data source. |
| **LogicObject$** | Object specified to supply logic references. See **[Logic Procedures](https://manual.pvxplus.com/views-system/logic-procedures/overview)**. |
| **PrimarySource$** | Primary data source, contents of this property vary according to **SourceType$**: *Logical file name* (L), *File name* (P), *Object name;tableID* (O), or *External database table connection string* (T). |
| **SourceType$** | Source type indicator:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| L \| PxPlus file identified by logical name. \|<br>\| P \| PxPlus file identified by path name or prefix file reference to an external database table (PxPlus SQL ODBC Driver, ADO, Oracle, MySQL or DB2). \|<br>\| O \| Custom data source object. \|<br>\| T \| External database table. \|<br>\| D \| Disabled source. \| |
| **Src** | Object identifier to the data source driver associated with the data source (e.g. *\*views/logio*, *\*views/fileio* or any custom data source object). |
| **UpdateStamp$** | Last update. |
| ***The following items are object Groups*** (**\*obj/group**) ***that define a list of related objects:*** |  |
| **DS_Item** | Standard group of **DS_Item** objects. One object for each item defined in the data source. |
| **DS_Link** | Standard group list of **DS_Link** objects. One object for each link used by the **DataSource**. |

## DataSource Methods

The following table lists the methods of the **DataSource** subordinate object:

| **Method** | **Description** |
| --- | --- |
| AddItem(\[*ColumnName$* **\|** " **\*** " **\])** | ***(Internal Use Only)***<br>Create a new **DS_Item** object.<br>If a column name (no trailing "$") is supplied, the item object is initialized with information derived from the data source driver. If an \**asterisk* is supplied, all columns in the source will be added. Use **ViewCtl** equivalent. |
| **AddLink( )** | ***(Internal Use Only)***<br>Create a new **DS_Link** object. Use **ViewCtl** equivalent. |
| **Clear( )** | Re-initialize the data source object and delete all subordinate objects. |
| **ClearItems( )** | ***(Internal Use Only)***<br>Remove subordinate **DS_Item** objects. |
| **ClearLinks( )** | ***(Internal Use Only)***<br>Remove subordinate **DS_Link** objects. |
| GetItem(*Item$* **\|** *idx*) | Return the **DS_Item** object handle for the specified item. If *Item$* is used, the method will attempt to match it to both the item description and name. |
| **GetItemCount( )** | Return the number of items in the data source. |
| GetItemIndex(*Item$***)** | Return the **DS_Item** group index for the specified item. (Name or description may be used.) |
| GetLink(*LinkDesc$* **\|** *idx*) | Return the object identifier for the specified **DS_Link** object. |
| **GetLinkCount( )** | Return the number of links defined for the data source. |
| GetLinkIndex(*LinkDesc$***)** | Return the **DS_Link** group index for the specified link. |
| RemoveItem(*Item$* **\|** *idx*) | ***(Internal Use Only)***<br>Remove the specified **DS_Item** object. If *Item$* is used, the method will attempt to match it to both the item description and name. Use **ViewCtl** equivalent. |
| RemoveLink(*LinkDesc$* **\|** *idx*) | ***(Internal Use Only)***<br>Remove the specified **DS_Link** object. Use **ViewCtl** equivalent. |
| **SetCloseLogic** (*Type$,Logic$***)** | Set **CloseLogic$**. |
| SetDescription(*Description$***)** | ***(Internal Use Only)***<br>Set description of data source (used to identify the data source). Use **ViewCtl** equivalent. |
| SetInitLogic(*Type$,Logic$***)** | Set **InitLogic$**. |
| SetInternalID(*InternalID$***)** | ***(Internal Use Only)***<br>Set internal identifier for the data source. |
| SetLogicObject(*ObjNm$***)** | Set **LogicObject$**. |
| SetLongDescription$(*LongDesc$***)** | Set long description for storing notes about the data source. |
| SetPrimarySource(*SrcType$,SrcName$,Expr*) | Set **SourceType$** and **PrimarySource$**.<br>*Expr* is either **X** or " " *null*. |
| SetUpdateStamp(*Stamp$***)** | ***(Internal Use Only)***<br>Set date/time stamp of last update. |
