Complex update with SQL in OpenEdge

Complex update with SQL in OpenEdge

We covered Update data in OpenEdge using SQL and ODBC in a previous post. In this post we will review complex update with SQL. Let’s assume that you have a client such as DBeaver set up. Connect to your OpenEdge database using ODBC. In my examples, I am using Sports2000 database. We will run through situations where update is done on multiple columns using literal data or data from another table. We’ll use JOIN and WHERE clauses for targeted updates.

Complex update using SQL in OpenEdge

Individual update

Let’s update a department name from Testing to Testing only. Always remember to use a WHERE clause, without which the entire table can get updated. If you plan to update the entire table, great…leave out the WHERE clause.

Update multiple columns

Let’s update multiple columns in the department table for a single row.

Update a table using data from another table

To demonstrate the example of updating one table using data from another table, let’s create a dummy table called location and enter some data in it. We will update data in location table using data from warehouse table.

Great! Now, let’s update these 2 rows with data from warehouse.

 

As you may have noticed, we can use SELECT statement that retrieves one and only one row from warehouse matching location table’s record and also ensure that a corresponding row exists in warehouse table.

Be sure to see other topics listed on Modern web applications and API with OpenEdge, SQL, ODBC and PHP