Обсуждение: Passing parameters to a Trigger

Поиск
Список
Период
Сортировка

Passing parameters to a Trigger

От
Antonio Scotti
Дата:
I need to pass to a trigger two dynamic text parameters stored into a
table (I can obtain them via a simple select). How can I obtain such a
thing?

Thanks everyone,
    Antonio Scotti


Re: Passing parameters to a Trigger

От
Josh Berkus
Дата:
Antonio,

> I need to pass to a trigger two dynamic text parameters stored into a
> table (I can obtain them via a simple select). How can I obtain such a
> thing?

You can't.  Triggers do not accept parameters.

If the parameters you're talking about are table columns, you can access them
through the NEW and OLD record objects.

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


Re: Passing parameters to a Trigger

От
Antonio Scotti
Дата:
   Triggers do accept parameters. In fact when you type CREATE TRIGGER
you can also specify some arguments. They are accessible via trigdata
not by the standard args of a function (in fact a trigger function must
not have parameters). The manual makes an example of passing the
current_user to a trigger, but it is not clear to me. Can anyone explain
how to make it works?

Antonio Scotti

Josh Berkus ha scritto:

>Antonio,
>
>
>
>>I need to pass to a trigger two dynamic text parameters stored into a
>>table (I can obtain them via a simple select). How can I obtain such a
>>thing?
>>
>>
>
>You can't.  Triggers do not accept parameters.
>
>If the parameters you're talking about are table columns, you can access them
>through the NEW and OLD record objects.
>
>
>




Re: Passing parameters to a Trigger

От
Tom Lane
Дата:
Antonio Scotti <ascotti@mbigroup.it> writes:
> The manual makes an example of passing the
> current_user to a trigger, but it is not clear to me.

Where exactly?  I couldn't find any such example in a quick search.

In general, the arguments offered in CREATE TRIGGER can only be literal
constants, so I don't think this could work.

            regards, tom lane

Re: Passing parameters to a Trigger

От
Antonio Scotti
Дата:
    The exact reference to what I've read is: in the .pdf file
"programmer-7.2-A4.pdf" at the very beginning of page 240. It is the
programmer's reference manual, the section regardings the CREATE TRIGGER
command in the paragraph explaing the meaning of 'args'.
    It says something about passing the current_user to a trigger but it
is not clear to me so I'd like to have it explained.
    However I've managed to solve my problem in another way. I simply
call the trigger with no parameters at all and then I do a query into
the trigger body (which is written in C) so I get the missing parameters.

    Regards,
        Antonio Scotti

Tom Lane ha scritto:

>Antonio Scotti <ascotti@mbigroup.it> writes:
>
>
>>The manual makes an example of passing the
>>current_user to a trigger, but it is not clear to me.
>>
>>
>
>Where exactly?  I couldn't find any such example in a quick search.
>
>In general, the arguments offered in CREATE TRIGGER can only be literal
>constants, so I don't think this could work.
>
>            regards, tom lane
>
>




Re: Passing parameters to a Trigger

От
Tom Lane
Дата:
Antonio Scotti <ascotti@mbigroup.it> writes:
>     The exact reference to what I've read is: in the .pdf file
> "programmer-7.2-A4.pdf" at the very beginning of page 240. It is the
> programmer's reference manual, the section regardings the CREATE TRIGGER
> command in the paragraph explaing the meaning of 'args'.
>     It says something about passing the current_user to a trigger but it
> is not clear to me so I'd like to have it explained.

No, what it's suggesting is passing two field names (constant strings)
to a trigger, which then uses those as the names of the fields to stick
current user and current time values into.  The trigger would have to
compute current user and current time for itself.

            regards, tom lane

New and investigating

От
"Alain Gougeon"
Дата:
Hi there

My name is Alain, i have like 14 years behind me working with Oracle, and
nothing else basically.

Recently i came across PostgreSQL and found it to be a very atractive thing,
in concept at least. I would like to know more about it, but not technically
yet, rather on the side of the capabilities it has from a "managerial" point
of view. I was wondering if i could find some pointers here. Thanks
everybody for they contributions.

(i already saw the oficial PostgreSQL page "advocacy")

The kind of questions that i ask myself are like:

. Is it really industrial strength? Where can i find articles/white
papers/etc that document it? (many people in the lists mention MySQL and
stuff like that, that's another ballgame alltogether)

. How does it compare to Oracle and the other main players in regards of
solidity, availability, trustability, dificulty of learning, installing,
mantaining?

. How powerful is its internal language (we're quite spoiled here working
with Oracle's PL/SQL which is very good...)

. Is there any article or study done of PostgreSQL from an Oracle
background: ups and downs, surprises, diferences, etc...

. In what cases would it be recomendable and relatively riskless to consider
using PostgreSQL instead of Oracle, and, much more importantly, in which
cases NOT.

. It seems that documentation might be sparse. How confident can one be of
obtaining technical knowledge of PostgreSQL without a very long trial and
failure path? Are there books on it?

. In the few mails that i have been cheking, i saw a lot of thing with which
i am not familiar. Is PostgreSQL really compliant with ANSI SQL?

. I've read an interview of Tom Lane where it comes out that PostgreSQL came
out to be faster than the other databases. Anybody got a link to that
article? tests?

. How efficient is PostgreSQL in terms of memory usage, queueing and all
these elaborated but useful (usually) things that show up inevitably in high
end products (like Oracle). (that could be rephrased as, "how not so basic
is PostgreSQL?"

etc...

I guess you see the picture.

At present all the development i am in charge of relies heavily on Oracle's
PL/SQL, but with the new ages coming up of having several tiers, and the
evergrowing needs for computing resources in front of the shrinking budgets
of struggling economies, this is something i would reconsider. PostgreSQL
places itself like a potential alternative to the oficial great actual
players, but it is really hard to trust anybody's speech right out. The
truth normally lies in many more details, known to the experienced
practicioners. I hope to be able to gather some impresions here

Thanks everybody.

Alain Gougeon
La Paz, Bolivia.