sql insert

Flutter, sqflite, and escaping quotes with SQL INSERT and UPDATE statements

When you want to do a SQL INSERT or UPDATE using the Flutter sqflite package, I’ve found that it’s best to use their insert and update methods (as shown below) so you don’t have to worry about escaping single- and double-quotes. This is similar to the reason why Java developers switched from Statement to PreparedStatement way back in the late 1900s.

As an example, given this SQLite database table:

A Drupal 7 db_insert query (SQL INSERT statement)

Drupal 7 database FAQ: How do I use the Drupal dbquery function to perform a SQL INSERT? (Or, what is the Drupal 7 dbinsert syntax?)

I didn't type db_query in that question by mistake. I just spent 45 minutes trying to use it for a Drupal 7 SQL INSERT, which of course I've now learned doesn't work.

In short, if you're looking for a Drupal 7 db_insert example that shows how to perform a SQL INSERT, and also happens to show some SQL Timestamp fields, here's a 'submit' function I'm currently writing:

Creating a PHP date in the format for a SQL Timestamp insert

PHP date/time FAQ: How do I create a date in the proper format to insert a SQL Timestamp field into a SQL database?

First off, you may not need to create a date in PHP like this. If you're using plain old PHP and a database like MySQL, you can use the SQL 'now()' function to insert data into a SQL timestamp field, like this:

Use the PHP addslashes function to fix SQL INSERT problems

PHP MySQL FAQ: Can you share an example of how to use the PHP addslashes function when creating a SQL INSERT statement?

When you're inserting records into a database table with plain PHP (as opposed to using a PHP framework), some of the fields you're inserting may have characters in them that will cause problems during the SQL INSERT process. Characters that will cause problems on database INSERT statements include the single quote, double quote, backslash, and NUL characters.

A Spring JDBC SELECT and INSERT example (Spring DAO)

A Spring JDBC SELECT and INSERT example: Here's the source code for a complete Spring DAO class from a project that I'm currently working on (a Java-based web interface to the open source Nagios project) that shows how to use a few Spring JDBC methods, including both a SELECT example and a simple INSERT example.

I'll add more examples to this site later (and with more introduction/description), but for now I'm just going to drop this Java class sample out here and hope that it helps you "Learn Spring JDBC by example".

Java JDBC Insert Example: How to insert data into a SQL table

Table of Contents1 - Step 1: A sample database2 - How to create a JDBC INSERT statement3 - Step 2: Execute the JDBC INSERT statement4 - The JdbcInsert1.java program5 - Related Java JDBC content6 - Summary

In my first JDBC tutorial (How to connect to a JDBC database) I demonstrated how to connect your Java applications to standard SQL databases like MySQL, SQL Server, Oracle, SQLite, and others using the JDBC Connection object.

In this article I’ll take the next step and show how to insert data into a database table using Java, JDBC, and SQL.