If you run the script through System iNavigator's Run an SQL Script, you can
ignore errors based on objects that are not found in drop statements.
Click on Options and select "Ignore 'Object not found' on DROP".
Run your Script after.
When using RUNSQLSTM you may set the severity level (ERRLVL) to 21, so the
Drop Error Not Found will be ignored.
... but you have to check the spoolfile log to find out if there are other
level 20 errors.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von James Lampert
Gesendet: Wednesday, 15.8 2012 01:23
An: Midrange Systems Technical Discussion
Betreff: Help with SQL script
We received an SQL script from one of our off-site developers, an SQL expert
who doesn't know scat about AS/400s, one that apparently runs fine on DB2
for Unix/Linux, but failed miserably when I tested it on our
V6 box.
Even if I *could* publish all 938 lines of it, I wouldn't burden the List
with it. Instead, a rough summary of the thing, with my abridgments in
<angle brackets>:
--==============================================================
-- DBMS name: IBM DB2 UDB 9.7 Common Server
-- Created on: 2012/8/7 0:46:18
--==============================================================
alter table B_User_Roles
drop foreign key F_Relationship_20;
alter table B_User_Roles
drop foreign key F_Relationship_21;
<and so forth, a bunch of "alter table" statements for tables that don't
exist yet, which the developer *says* shouldn't stop the script from
creating the files from scratch>
drop table B_Groups;
drop table B_Roles;
drop table B_Settings;
drop index Relationship_21_FK;
drop index Relationship_20_FK;
drop table B_User_Roles;
<and so forth, dropping any existing files in the library>
--==============================================================
-- Table: B_Groups
--==============================================================
create table B_Groups
(
group_id NUMERIC(20) not null,
name VARCHAR(50) not null,
description VARCHAR(200),
constraint P_Identifier_1 primary key (group_id) );
--==============================================================
-- Table: B_Roles
--==============================================================
create table B_Roles
(
role_id NUMERIC(20) not null,
name VARCHAR(50) not null,
description VARCHAR(100),
type SMALLINT,
is_grantable SMALLINT,
function_name VARCHAR(50),
object_id NUMERIC(20),
object_type INTEGER,
constraint P_Identifier_1 primary key (role_id) );
--==============================================================
-- Table: B_Settings
--==============================================================
create table B_Settings
(
setting_id NUMERIC(20) not null,
name VARCHAR(50) not null,
content VARCHAR(1024),
owner_type SMALLINT,
owner_id NUMERIC(20),
constraint P_Identifier_1 primary key (setting_id) );
--==============================================================
-- Table: B_User_Roles
--==============================================================
create table B_User_Roles
(
user_id NUMERIC(20),
role_id NUMERIC(20)
);
--==============================================================
-- Index: Relationship_20_FK
--==============================================================
create index Relationship_20_FK on B_User_Roles (
user_id ASC
);
--==============================================================
-- Index: Relationship_21_FK
--==============================================================
create index Relationship_21_FK on B_User_Roles (
role_id ASC
);
<continuing with a bunch of additional CREATE TABLE and CREATE INDEX
statements>
alter table B_User_Roles
add constraint F_Relationship_20 foreign key (user_id)
references B_Users (user_id)
on delete restrict on update restrict;
alter table B_User_Roles
add constraint F_Relationship_21 foreign key (role_id)
references B_Roles (role_id)
on delete restrict on update restrict;
<continuing with a bunch more ALTER TABLE statements>
******
Running the whole script (in RUNSQLSTM) failed, but running the first CREATE
TABLE from it, in isolation, worked.
Is there any reasonable expectation that the whole script would even run on
an AS/400? I don't even understand the error messages I got.
--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.