1

I have created a stored proc that returns one column of id's for linking.

sql = call myproc(555) 

The above works perfectly returning a result set of id's.

sql = "select * from mytable  where id in (call myproc(555))"

The above query says my syntax is incorrect and bombs.

Suggestions? Thanks Glenn

user3757731
  • 277
  • 2
  • 11
  • I don't know really whether this is allowed or not, but if you use a user defined function instead of a stored procedure , it will work 100% – Abdo Adel Jun 02 '15 at 19:36
  • 1
    If I remember correctly, stored procs can't be used inside other queries (or at least are generally useless within them); go with @AbdoAdel suggestions and make it a `stored function` instead. – Uueerdo Jun 02 '15 at 19:38
  • I found some hack to do it here http://stackoverflow.com/questions/209383/select-columns-from-result-set-of-stored-procedure – Abdo Adel Jun 02 '15 at 19:56
  • Thanks for the very fast responses! It helped knowing that stored procs can not be used inside another query. I checked into functions, however it appears they can not return result sets. What works perfectly is creating a view. Thanks again. – user3757731 Jun 02 '15 at 20:07

0 Answers0