Questions about anonymous procedure/function.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions about anonymous procedure/function.

Ying Lu
Greetings,

I have a question about whether I am able to create an *anonymous*
procedure/function under postgreSQL 8. Something like:

Begin
   ... ...
   update ...
   IF ... THEN
   rollback
   END IF;
   ... ...
END;

I'd like to do a series of operations. If any one of the opers failed,
all previous operation will rollback. Actually, I do not want to create
named functions. Just used the structure for different tables with minor
changes.


Another question is about how to create a function/procedure do not need
a return value (void for return value). It seems that postgreSQL forces
to return some value?

Thanks a lot!
Emi


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
Reply | Threaded
Open this post in threaded view
|

Re: Questions about anonymous procedure/function.

Richard Huxton
Ying Lu wrote:

> Greetings,
>
> I have a question about whether I am able to create an *anonymous*
> procedure/function under postgreSQL 8. Something like:
>
> Begin
>   ... ...
>   update ...
>   IF ... THEN
>   rollback
>   END IF;
>   ... ...
> END;

No

> I'd like to do a series of operations. If any one of the opers failed,
> all previous operation will rollback.

Well that's just a transaction.

 > Actually, I do not want to create
> named functions. Just used the structure for different tables with minor
> changes.

Create your function, call it, drop it.

> Another question is about how to create a function/procedure do not need
> a return value (void for return value). It seems that postgreSQL forces
> to return some value?

Just return a boolean.

--
   Richard Huxton
   Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match