I know this is off topic, but I know many of you use PostgreSQL so I 
thought I would start here. I  am writing a query in a function that 
does not work and was wondering if anyone sees a problem. My table 
follows:

Table 1
----------
id_user
rel_id_section
idx_registration

And the Function is:

    CREATE OR REPLACE FUNCTION unregister_user() RETURNS OPAQUE AS '
        DECLARE
            current_registration  int2;
            maximum_registration  int2;
        BEGIN

            SELECT INTO registration_record *
                   FROM registration
                   WHERE rel_id_section = OLD.rel_id_section AND
                         id_user = OLD.id_user;
            IF FOUND THEN
                RAISE EXCEPTION ''user is enrolled'';
            ELSE
                RAISE EXCEPTION ''No registration exists: %, %'',
                                OLD.id_user, OLD.rel_id_section;
            END IF;
            RETURN NULL;
        END
    ' LANGUAGE 'plpgsql';

I have put a delete trigger that runs this function and it does not 
matter if the record exists or not it always returns that "No 
registration exists." If I remove the portion of the where clause 
that verifies the user the query works fine. I belive I need to quote 
the data or something, but can not find in the docs how.

Does anyone have any ideas?

Thanks,
Chad


--
Pop3Now Personal, Manage 5 Email Accounts From 1 Secure Window
Sign Up Today!  Visit http://www.pop3now.com/personal



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to