Version 3 of TimpleSQL

Updated 2003-02-25 18:52:23

TimpleSQL v1.3 Was released on February 25, 2003!

Downloads & Additional Info/Examples: http://www.simplifiedlogic.com/TimpleSQL/Default.htm

What is TimpleSQL?

TimpleSQL is a set of standalone procedures that helps the developer either quickly prepare values, or execute submission, for INSERT or UPDATE queries into a database using tclodbc.

TimpleSQL only requires a standard one-dimensional Tcl Array of your input values and the target table name/array where you want to insert or update your information. TimpleSQL gathers the target table's column name/formatting requirements and, depending on your desired action, will generate the proper SQL input string based on the matching indexes in your Tcl Array. You can also Validate your submission data relative to the target table before submission (recommended).

TimpleSQL can either prepare and execute the submission of the generated SQL, or you can use some lower level commands to help you generate SQL structures (e.g., SELECT, INSERT, UPDATE) for hard coding SQL in your own applications.

Using TimpleSQL, you can quickly database enable standard Tcl/TK and CGI Applications for things like submission forms, polls, and shopping carts.

QUICK EXAMPLE: INSERT Record into Database (uses tclodbc)


 # Load the Pacakges
 package require TimpleSQL
 package require tclodbc

 # Connect to the database
 database db MyDatabaseName

 # Submission data that you create in your appliation/CGI.
 #  - The Array Index Values are the Target Table Column Names
 set arr(FName) John
 set arr(LName) "Doe's last name"
 set arr(State) Anywhere
 set arr(ZIP) 12345
 set arr(AddToMailingList) 1
 set arr(submitDate) [[clock format [[clock seconds]] -format %m/%d/%y]]


 # Generate the Table Column Type Cross Ref Info
 GenTableColTypes typTbl tbl_RegistrationInfo


 # Validate the Submission Value Formats to the Target Table Formats
 # - If NOT OF - then return the errors.
 # - If OK - then use the TimpleSQLInsert to submit the array to the table 

 if [[catch {ValidateSubmissionData arr typTbl} err]] {
     # Data is NOT Valid - Report Errors
     foreach item [[join $err]] {
         puts "ERROR: $item"
     }
 } else { 
     # Data is Valid/Compatiable with Target Database - Insert Record
     TimpleSQLInsert arr typTbl
 }


 # Disconnect from the Database & Exit
 db disconnect
 exit