× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Tue, 2014-09-23 at 13:45 -0400, rob@xxxxxxxxx wrote:
Please try the following in your own shop:
Start IBM i Navigator for Windows.
Expand your IBM i
Expand Databases
Select the database below it (almost always named the same as the IBM i
involved).
Off to the bottom right you will see Databases tasks.
Start "Run an SQL script"

For your first statement put the following:

create table yourlib.yourtable
(ActiveRecordCode char (1) not null,
constraint Cst_ActiveRecordCode_MustBeZ check (ActiveRecordCode='Z'));

Run that. After that is done run:

INSERT INTO yourlib.yourtable (ActiveRecordCode) VALUES('A');

You will get an error like this:
SQL State: 23513
Vendor Code: -545
Message: [SQL0545] INSERT, UPDATE, or MERGE not allowed by CHECK
constraint. Cause . . . . . : The value being inserted or updated does
not meet the criteria of CHECK constraint CST_ACTIVERECORDCODE_MUSTBEZ.
The operation is not allowed. Recovery . . . : Change the values being
inserted or updated so that the CHECK constraint is met. Otherwise, drop
the CHECK constraint CST_ACTIVERECORDCODE_MUSTBEZ.

Now, what possible use would be some mediator on this? This is not a
trigger. This is a constraint. How would your mediator even be activated
upon a check constraint? How would you possibly "grab the message and
forward it on up the stack."? And, if you could do so, what would then
appear the next time you run this insert using Run an SQL Script? Instead
of getting
SQL State: 23513
Vendor Code: -545
Message: [SQL0545] INSERT, UPDATE, or MERGE not allowed by CHECK
constraint. Cause . . . . . : The value being inserted or updated does
not meet the criteria of CHECK constraint CST_ACTIVERECORDCODE_MUSTBEZ.
The operation is not allowed. Recovery . . . : Change the values being
inserted or updated so that the CHECK constraint is met. Otherwise, drop
the CHECK constraint CST_ACTIVERECORDCODE_MUSTBEZ.

You would get, what? The following?
SQL State: ?????
Vendor Code: ???
Message: [CPF9898] ???

My mistake, I hadn't clocked that it was a constraint as opposed to a
trigger and was running on from earlier posts in this part of the
thread.

That said, if there was a trigger program... would that get the
constraint messages or does it work:-

Program update > Before TriggerA runs
> Before TriggerB runs
> Constraint DB program runs

Please be aware I'm still at the newbe stage here, although I have some
understanding of the concepts _how_ they glue together is still on my
"to have a play around" list (which is growing considerably), even
simple things such as can multiple before triggers exist or is there
only one allowed I'm yet to find out; as is do constraints act as a
stand alone "program" (called after the trigger has finished) or do they
exist below the before trigger(s?) in a call stack.


All that said, is there an exit point for a constraint(s)?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.