Home > Archive > SQL Anywhere database > April 2005 > procedures vs functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author procedures vs functions
Jim

2005-04-26, 8:23 pm

I have ASA 9.0.2.2451

Is it function caching that is the biggest differentiating feature between
procedures and functions? Are there other major differences? Just trying
to figure out when to use each.


David Kerber

2005-04-26, 8:23 pm

In article <426e95a0$1@forums-1-dub>, jimsjbox@yahoo.com says...
> I have ASA 9.0.2.2451
>
> Is it function caching that is the biggest differentiating feature between
> procedures and functions? Are there other major differences? Just trying
> to figure out when to use each.


I use functions when I need to assign the return value to a variable (or
a query), as in:

select a, funcX(a) from mytable

And I use procedures when I either don't need a return value, or need to
return a recordset rather than just a single value.


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Breck Carter

2005-04-26, 8:23 pm

From the book...

Functions are expected to return values so the CREATE
FUNCTION statement requires a RETURNS clause to specify the
data type of the return value. That's not the only
difference between functions and procedures; here's a list
of characteristics that make a function different from a
procedure:

The only parameter disposition allowed is IN, and that's the
default; OUT and INOUT parameters aren't allowed.

A function cannot return a result set or have a RESULT
clause.

The default return value is NULL instead of zero.

The correspondence between arguments and parameters is
strictly positional.

A function can be defined as DETERMINISTIC or NOT
DETERMINISTIC.

Note: A function can be invoked by a CALL statement just
like a procedure, and in that case none of the differences
in the above list apply. However, this book doesn't discuss
the subject of using CALL to invoke a function... if you
want a procedure, use CREATE PROCEDURE.

Breck

> I have ASA 9.0.2.2451
>
> Is it function caching that is the biggest differentiating
> feature between procedures and functions? Are there other
> major differences? Just trying to figure out when to use
> each.
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com