SELECT Trigger
Posted in 2011
Topics: Triggers, Constraints & Referential Integrity
Hi All, I am looking for some help from experts with SELECT trigger or similar option. I was under the impression that we could change the value of selected or other column in SELECT result without actually updating the value in database column. So far what I read, I dont think this is possible option. It tells me how to populate (add/update) other tables but not the one used in your SELECT trigger. About what I am looking for to do with SELECT trigger (or any other suggestion you might have): an example, if column1 has value 1, and colum2 has value One, I would like to have a select trigger to detect the value of column1 as 1 and returns the column2 value as First instead of One. I do not want to change the value in database but would like to get the said result in SELECTs output. I know there is a way that I can get this result by using a CASE statement in my SELECT but it will work if I use the column name in my SELECT and will not work if I used * for all columns. I am looking for an option to get what I need at little higher level, where the * or column name when used in SELECT can produce the same result without Affecting (or making changes in lots of ) other apps and without changing the database value. I was hoping to get advantage of SELECT trigger but doesnt look like it will work.. I hope I wrote my question/requirement clearly here...If not, I apologize in advance and will try to give more specific example, if needed. I am using IDS 11.5 on AIX. -Dharmendra
Hello.
I think you could use IF statements, or even CASE, inside your original
select statement (projection section),
in order to filter the options and results you´re trying to return.
select a.field1, a.field2,
case field3 when 0 then 'Pend'
when 1 then 'Em aprov'
when 2 then 'Aguardan'
when 3 then .....
else '#error' end as field_alias
from ....
where....
Hope it helps.
Best regards.
Em 02/03/2011 13:23, DHARMENDRA SHARMA escreveu:
> Hi All,
>
> I am looking for some help from experts with "SELECT" trigger or similar
> option.
>
> I was under the impression that we could change the value of "selected " or
> other column in SELECT result without
> actually updating the value in database column. So far what I read, I don't
> think this is possible option. It tells me how to populate (add/update) other
> tables
> but not the one used in your SELECT trigger.
>
> About what I am looking for to do with SELECT trigger (or any other
suggestion
> you might have):
> an example, if column1 has value 1, and colum2 has value "One", I would like
> to have a select trigger to detect the value of column1 as "1" and returns
the
> column2
> value as "First" instead of "One". I do not want to change the value in
> database but would like to get the said result in SELECT's output. I know
> there is a way that I can
> get this result by using a CASE statement in my SELECT but it will work if I
> use the column name in my SELECT and will not work if I used "*" for all
> columns.
> I am looking for an option to get what I need at little higher level, where
> the "*" or "column name" when used in SELECT can produce the same result
> without
> Affecting (or making changes in lots of ) other apps and without changing the
> database value. I was hoping to get advantage of "SELECT trigger" but doesn't
> look like
> it will work..
>
> I hope I wrote my question/requirement clearly here...If not, I apologize in
> advance and will try to give more specific example, if needed.
>
> I am using IDS 11.5 on AIX.
>
> -Dharmendra
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--
Alexandre Marini
Tecnologia da Informação - DBA
msn: alexandre_marini@hotmail.com
SEFAZ-MS / SGI-UGSR / Sistemas IBM-Informix
Cert-Info-Mgmt_color <Cert-Info-Mgmt_color.jpg>
IBM Certified System Administrator - Informix Dynamic Server V10 / V11
<http://www.iiug.org/conf/2011/iiug/>