This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).
We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:
Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,
Post an idea.
Get feedback from the IBM team and other customers to refine your idea.
Follow the idea through the IBM Ideas process.
Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.
IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.
ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.
The CEAC has reviewed this requirement and recommends that IBM view this as a HIGH priority requirement that is important to address as it is a function that is available in other databases.
Background: The COMMON Europe Advisory Council (CEAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CEAC has a crucial role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community and has therefore reviewed your RFE.
To find out how CEAC help to shape the future of IBM i, see CEAC @ ibm.biz/BdYSYj and the article "The Five Hottest IBM i RFEs Of The Quarter" at ibm.biz/BdYSZT
Sabine Jordan + Sara Anrdres – CEAC Program Manager, IBM
There are several ways to deal with existing objects, depending on what you need to accomplish.
1. To drop an SQL object with no error if it does not exist, use the IF EXISTS clause on the DROP statement.
DROP TABLE mytable IF EXISTS;
2. To create a table if it might already exist, use the OR REPLACE clause on the CREATE TABLE statement. You can either keep the existing rows or remove them.
create or replace table mytable ( id int, name varchar(100)) on replace preserve rows;
create or replace table mytable ( id int, name varchar(100)) on replace delete rows;
3. For logic similar to what you described, a compound statement can be used. The following is a single statement. It can be run from within RUNSQL or in Run SQL Scripts.
begin
if exists (select * from qsys2.systables where table_schema = 'MYLIB' and table_name = 'MYTABLE') then
drop table mytable;
else
create table mytable ( id int, name varchar(100));
end if;
end;
Db2 for i development team
IBM Power Systems Development
There's not an IF EXISTS function, but wouldn't CREATE OR REPLACE TABLE/PROCEDURE/etc work in this scenario? Or if you want to delete all of the time and then create some of the time, use DROP TABLE/PROCEDURE/etc IF EXISTS (it will not cause an error if the object doesn't exist) followed by the CREATE TABLE/PROCEDURE/etc. statement.