Update
Package: Libraries.Data.Database · Inherits from: Libraries.Language.Object, Libraries.Data.Database.Query, Libraries.Data.Database.Support.RemappableName
The Update query represents the Update command of the SQL (Structured Query Language) language. This query allows for the modification of a record that already exists in the database.
Example Code
use Libraries.Data.Database.Database
use Libraries.Data.Database.Update
Database database
database:Connect("localhost", "myDatabase", "user", "SuperSecret456")
Update query
query:SetTable("orders")
query:Add("status", "Shipped")
query:Add("comments", "Express shipping")
database:Update(query)
Actions
Add(text column, number value)
This action is used to add which column will be modified and what value it will be set to.
Parameters
columntext: The name of the column that will be updatedvaluenumber: The value the column will be updated with
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("products")
query:Add("MSRP", 9.99)
Add(text column, text value)
This action is used to add which column will be modified and what value it will be set to.
Parameters
columntext: The name of the column that will be updatedvaluetext: The value the column will be updated with
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("products")
query:Add("productName", "The Moon")
Add(text column, Libraries.Compute.BigInteger value)
This action is used to add which column will be modified and what value it will be set to.
Parameters
columntext: The name of the column that will be updatedvalueLibraries.Compute.BigInteger: The value the column will be updated with
Example
use Libraries.Data.Database.Update
use Libraries.Compute.BigInteger
text value = "2147483648"
BigInteger largeNumber
largeNumber:SetValue(value)
Update query
query:SetTable("distances")
query:Add("distance_in_mm", largeNumber)
Add(text column, integer value)
This action is used to add which column will be modified and what value it will be set to.
Parameters
columntext: The name of the column that will be updatedvalueinteger: The value the column will be updated with
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("orders")
query:Add("customerNumber", 42)
Add(text column, boolean value)
This action is used to add which column will be modified and what value it will be set to.
Parameters
columntext: The name of the column that will be updatedvalueboolean: The value the column will be updated with
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("orders")
query:Add("shipped", true)
AddExpression(text column, text value)
This action is used to add which column will be modified and what value it will be set to using an expression. Since the value is an expression it will be parsed and can use column names within it.
Parameters
columntext: The name of the column that will be updatedvaluetext: The expression the column will be updated with
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("products")
query:AddExpression("MSRP", "MSRP + 0.10")
ConvertToStructuredQueryLanguage()
This action returns the query as text in Structured Query Language (SQL). Not intended to be used directly by the user, this is more for internals of the API to make calls to the database
Returns
text
Empty()
Removes all columns and values associated with them from the query.
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("orders")
query:Add("status", "Shipped")
query:Add("comments", "Express shipping")
query:Empty()
HasColumn(text name)
This action checks if the update query has a specific column in the set list.
Parameters
nametext: The name of the column to search for
Returns
boolean: Returns true if the column was found, false otherwise
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("orders")
query:Add("status", "Shipped")
query:Add("comments", "Express shipping")
boolean statusChange = query:HasColumn("status")
RemoveColumn(text name)
This action removes a specific column.
Parameters
nametext: The name of the column that will be removed
Returns
boolean: Returns true if the column was removed, false otherwise
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("orders")
query:Add("status", "Shipped")
query:Add("comments", "Express shipping")
query:RemoveColumn("comments")
SetIsFiltering(boolean filtering)
If this flag is set to false then the query will be allowed to run with no filter which updates all rows in the table.
Parameters
filteringboolean: If true this query will not use a filter for updating rows
Example
use Libraries.Data.Database.Update
Update query
query:SetTable("tasks")
query:Add("status", "Delayed")
query:SetIsFiltering(true)
UsingFilter()
This action returns whether or not this Update query will use a filter.
Returns
boolean: Returns true if not using a filter and false if it will
Example
use Libraries.Data.Database.Update
Delete query
query:SetTable("tasks")
query:Add("status", "Delayed")
query:SetIsFiltering(false)
boolean filtering = query:UsingFilter()
Inherited Actions
20 actions from Libraries.Data.Database.Query
- AddNameRemap(text newName, Libraries.Data.Database.Support.RemappableName original)
- AddPreparedParameter(Libraries.Data.Database.Support.Parameter param)
- AddSubquery(text name, Libraries.Data.Database.Find subquery)
- AddTableNameRemap(text table, text newName)
- AddTableReference(text table)
- EmptyPreparedParameters()
- EmptyTableReferences()
- Filter(text value)
- GetDatabaseMetaData()
- GetNameRemaps()
- GetPreparedParameters()
- GetRawFilter()
- GetTable()
- GetTableReferences()
- GetTranslatedFilter()
- SetDatabaseMetaData(Libraries.Data.Database.DatabaseMetaData meta)
- SetTable(text table)
- SetTable(text table, text newName)
- SetTableWithName(text table, text newName)
- ToText()