Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am trying to write my first trigger. It is an insert trigger as follows:

<b>Fatal error</b>:  postgres7 error: [-1: ERROR:  INSERT has more target columns than expressions at character 78

INSERT INTO
dash_pre_queue
            (ord_obj_guid,
             ord_entry_type_guid,
             client_obj_guid, 
             installer_obj_guid, 
             installer_serial_number, 
             datetime, 
             ord_proc_state_guid,
             created,
             ord_esc_type_guid,
             in_error,
             ord_entry_guid)
SELECT
    (ord_obj_guid,
            NULL,
            client_obj_guid,
            inst_obj.inst_obj_guid,
            inst_obj.installer_serial_number,
            clock_timestamp(),
            ord_proc_state_guid,
            NULL,
            NULL,
            NULL,
            NULL)
    FROM
            ord_obj
    JOIN
            inst_obj ON inst_obj.inst_obj_guid = ord_obj.inst_obj_guid
    WHERE
            ord_obj.ord_obj_guid = NEW.ord_obj_guid

I left the error message on top. The structure of the target table matches the INSERT INTO columns. I have verified the NULL values are allowed.

If you count the columns in the Insert clause, they match the SELECT statement, yet, I get the error above stating that there is somehow a disconnect. Any ideas as to what I am doing wrong?

share|improve this question
    
just for giggles check and see if dash_pre_queue has any triggers –  HLGEM Feb 8 '13 at 14:47
add comment

1 Answer

up vote 2 down vote accepted

Remove parens around column list in select. This doesn't do what you think it does.

share|improve this answer
    
Thank you, depesz! That did the trick. –  dneimeier Feb 8 '13 at 15:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.