Topics
- Introduction 1
- SQL Yoga Primer 3
- Notes on Error Reporting 3
- General Concepts 4
- Database Objects 5
- Database Connections 5
-
SQL Query Objects
6
- Introduction to SQL Query Objects
- Creating A SQL Query Object
- How Do I Create Records In a Database Table Using a SQL Query Object?
- How Do I Delete Records From the Database Table Using a SQL Query Object?
- How To Use Cursors With a SQL Query Object
- How Can I Convert a User Search String Into An AND/OR Search When Generating a Query?
- Record Objects 5
- Table Objects 4
- Table Relationships 3
Other Resources
How-tos
- Lessons
GLX Application Framework
- GLX Application Framework 1.1
- Converting An Existing Application To Use The Framework
SQL Yoga
- SQL Yoga
- SQL Yoga Examples
- SQL Yoga To-Do Application
- SQL Yoga IDE Plugin
Plugins, Externals and Libraries
- Plugins
Comments
0 comments for this lesson
How Do I Create Records In a Database Table Using a SQL Query Object?
A SQL Query object provides a quick way of creating data in a database. This lesson will show you how to use sqlquery_create to do so.
Note: When using sqlquery_create none of the validations or callbacks you've defined for Table objects will be triggered.
Create An Array
The first step is to fill in an array variable with the values you want to insert into the database. The array keys should be the names of the columns in your database table.
## Create array with column values for new database record.
put "My Dog's Car" into theRowA["title"]
put false into theRowA["draft"]
Create The Record
Once you have created the array you just pass it as a parameter to sqlquery_create along with the name of the table you want to create the record in. SQL Yoga will generate the query for you.
sqlquery_create "lessons", theRowA
put the result into theError
put it into theAffectedRows


Add your comment