windowsxp — 2012-10-11T12:29:42-04:00 — #1
I need a routine which will return 4 values . I want to call this routine in select query like below ...
select col1 , col2 , routine(col3) from mytable
which routine I need ? Do I need view / store proc / function or what is the proper way to solve this ?
rcashell — 2012-10-11T14:45:51-04:00 — #2
You will need a function, however, a function can only return a single value. So routine(col3) can only return a single int, varchar, date and any other data type.
felgall — 2012-10-11T17:42:24-04:00 — #3
Simply create an object containing the values to be returned and return the object.
r937 — 2012-10-11T18:58:19-04:00 — #4
an object? in sql? neat trick if you can pull that off
or maybe you meant in php?
i agree, i would do the routine in the application layer, if possible, i.e. if the result depends on the value of col3 alone and not some other fields/rows/tables
windowsxp — 2012-10-11T22:24:37-04:00 — #5
I want to do this in DB side.
What are the choices I have ?
based on the col3 value ..I want to pick 4 values from other table .
r937 — 2012-10-11T22:36:34-04:00 — #6
sounds like a join