Re: Writting Trigger

From: Álvaro G. Vicario <alvaro.NOSPAMTHANX_at_demogracia.com.invalid>
Date: Wed, 30 Nov 2011 11:07:07 +0100
Message-ID: <jb4v81$ir4$1_at_dont-email.me>



El 29/11/2011 13:30, KonradWo escribió/wrote:
> I have table and i dont know how to write trigger to this table
>
> Table:
> CREATE TABLE TAB1
> (
> ID NUMBER(9),
> ID2 VARCHAR2(20)
> )
>
> Valuses:
>
> INSERT INTO TAB1 VALUES (1,'')
> INSERT INTO TAB1 VALUES (2,'')
> INSERT INTO TAB1 VALUES (3,'')
> INSERT INTO TAB1 VALUES (4,'')
>
> Single update:
> UPDATE TAB1
> SET
> ID2 = ('TEXT' || (SELECT ID FROM TAB1 WHERE ID=1))
> WHERE ID=1
>
> I have a question:
> How to update whole table based on "Single update" ?
>
> I need help with writeing trigger based on "Single update" to automate this process.

Your sample code looks fairly similar to the more obvious and less convoluted single query:

UPDATE TAB1
SET ID2 = 'TEXT' || ID
WHERE ID=1 ... even this:

UPDATE TAB1
SET ID2 = 'TEXT1'
WHERE ID=1 Other than that, I'm not sure I understand your requirements. Do you want to write a trigger so every time you update one row all other rows will receive the same update? Why do you think you need that? What do you have so far?

-- 
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Received on Wed Nov 30 2011 - 04:07:07 CST

Original text of this message