Database and SQL Commands
Intro Text
dcDatabase Commands
Intro Text
dcdb.Query
This standard query will look up values found in the table (a type of database) listed at
Table
and store the resulting list in a variable named in
Result
Inside the Query Tags, the various fields or columns that can be selected using the
Select
tags:
-
Field
marks the column to pull from -
As
is an optional attribute to rename the field. This commonly gets used to remove dc or dcm in front of the field for ease of use farther along in the script -
Composer
todo - other point
Collector
tags determine the search parameter for the query, defining the
Field
and
Values
to search
In addition, the
Where
tags define filters that can be applied to the query, also using
Field
and
Value
attributes
<dcdb.Query Table="dcPuppies" Result="PuppyList">
<Select Field="Id" />
<Select Field="dcName" Composer="dcTranslate" As="Name" />
<Select Field="dcAlias" As="Alias" />
<Select Field="dcForSale" As="ForSale" />
<Select Composer="dcmStoreImage" As="Image" />
<Collector Field="Id" Values="[1,2]" />
<Where>
<Equal Field="dcForSale" Value="true" />
</Where>
</dcdb.Query>
<dcs.Out>{$PuppyList}</dcs.Out>
Output:
[
{Id: 1, Name: "Fido", Alias: "fido", ForSale; true},
{Id: 2, Name: "Spot", Alias: "spot", ForSale; true},
]
dcdb.QueryFirst
Double check? Similar to Query command but only returns the first valid entry
<dcdb.QueryFirst Table="dcPuppies" Result="PuppyList">
<Select Field="Id" />
<Select Field="dcName" Composer="dcTranslate" As="Name" />
<Select Field="dcAlias" As="Alias" />
<Select Field="dcForSale" As="ForSale" />
<Select Composer="dcmStoreImage" As="Image" />
<Collector Field="Id" Values="[1,2]" />
<Where>
<Equal Field="dcForSale" Value="true" />
</Where>
</dcdb.Query>
<dcs.Out>{$PuppyList}</dcs.Out>
Output:
[
{Id: 1, Name: "Fido", Alias: "fido", ForSale; true}
]
dcdb.LoadRecord
Discinction between Query and LoadRecord?
Searches record via
Id
parameter and returns record as
Result
<dcdb.LoadRecord Table="dcmThread" Id="{$_Param.Id}" Result="Thread">
<Select Field="dcmTitle" As="Title" />
<Select Field="dcmManagedFormName" As="Form" />
<Select Field="dcmUuid" As="Uuid" />
<Select Field="dcmManagedFormToken" As="Token" />
</dcdb.LoadRecord>
Output:
TODO
dcdb.LoadTenant
??? Used to pull site config parameter from tenant config?
<dcdb.LoadTenant Result="StoreSettings">
<Select Field="dcmStoreInstructionsPickup" As="InstructionsPickup" />
</dcdb.LoadTenant>
dcdb.UpdateRecord
Locates the record with the
Id
matching in the
Table
and updates any
Field
s with the appropriate
Value
s
Result purpose?
<dcdb.UpdateRecord Table="flwSiteTracker" Id="$ResultId.Id" Result="EntryResult">
<Update Field="Site" SubId="{$OutData.SiteMark}" Value="$Data.UUID" />
<Update Field="SiteAdded" SubId="{$OutData.SiteMark}" Value="$Now" />
</dcdb.UpdateRecord>
dcdb.UpdateTenant
text
Example
dcdb.InsertRecord
Generates a new entry in the
Table
Result purpose?
<dcdb.InsertRecord Table="flwSiteTracker" Result="EntryResult">
<Update Field="RecId" Value="$OutData.RecId"/>
<Update Field="Added" Value="$Now" />
<Update Field="First" Value="$Data.First"/>
<Update Field="Last" Value="$Data.Last"/>
<Update Field="Email" Value="$Data.Email"/>
<Update Field="Site" SubId="{$OutData.SiteMark}" Value="$Data.UUID" />
<Update Field="SiteAdded" SubId="{$OutData.SiteMark}" Value="$Now" />
</dcdb.InsertRecord>
dcdb.RetireRecord
text
Example
dcSql Support
Intro Text
dcdb.SqlSelect
text
Example
dcdb.SqlSelectRow
text
Example
dcdb.SqlSelectVar
text
Example
dcdb.SqlExecute
text
Example
dcdb.SqlInsertWriter
text
Example
dcdb.SqlUpdateWriter
text
Example
dcdb.SqlDeleteWriter
text
Example