Selecting a user-defined scalar function that takes as a parameter another field
Posted
by ghills
on Stack Overflow
See other posts from Stack Overflow
or by ghills
Published on 2010-03-26T22:48:02Z
Indexed on
2010/03/26
22:53 UTC
Read the original article
Hit count: 411
I have a table a
with a list of id's, and a user-defined function foo(id)
that takes the id and returns a VARCHAR(20)
.
What I am trying to do is:
SELECT
id,
foo(id) AS 'text field'
FROM a
However, instead of calling the function for each ID number, like I desired, the text comes back the same for every row. I have tested the foo() function manually with the returned ID's and it does not have that problem, so I realize I must not understand something about the evaluation of the query.
© Stack Overflow or respective owner