Q: Wich constraint was violated (I4GL) ?
Posted in 1995
Hi there,
Is there a way in I-4GL to know wich CONSTRAINT has been violated (I don't
want to place it in errorlog) ?
Suppose I have the following:
CREATE DATABASE test;
CREATE TABLE test
(
c1 CHAR(18) NOT NULL,
c2 CHAR(1) DEFAULT 'Y' NOT NULL
CHECK (c2 IN ('Y', 'N')) CONSTRAINT test_c2,
c3 CHAR(1) DEFAULT 'Y' NOT NULL
CHECK (c3 IN ('Y', 'N')) CONSTRAINT test_c3
);
When I run :
{
{ database test
{
{ main
{
{ whenever error continue
{ INSERT INTO test VALUES (1,"T","J")
{ whenever error stop
{
{ end main
{
I get error -530 as expected, but I don't know wich CONSTRAINT was violated:
test_c2 or test_c3
After running this one thru the debbuger, I noticed that after executing the
INSERT, SQLCA.SQLERRM, has the name of the violated CONSTRAINT. But when
trying to get the value of SQLCA.SQLERRM (wich is reserved) in runtime, I
can't. Why does this happen ? Is there a way ?
{
{ DUMPING GLOBAL VARIABLES
{
{ status = -530
{ int_flag = 0
{ quit_flag = 0
{ sqlca = {
{ sqlcode = -530
{ sqlerrm = "natal.test_c2
{ "
{ sqlerrp = (null)
{ sqlerrd = {10, 0, 0, 2, 37, 21}
{ sqlawarn = " "
{ }
{
Thanks in advance
Joao Natal
+----------------------------------------------------------+
| Joao Natal | E-mail : natal@telepac.pt |
| Est. Ext. da Circunvalacao, | Voice : 351-02-523516 |
| 7996 3o. Dto. | Fax : 351-02-523516 |
| 4200 Porto | |
| Portugal | |
+----------------------------------------------------------+