1 Replies - 2054 Views - Last Post: 07 December 2012 - 11:12 AM

#1 notice88  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 21-December 11

How can I pass data coming from a query in function parameters?

Posted 06 December 2012 - 09:43 AM

Im creating a query which get data from a function but Im getting an error about the parenthesis in passing data in function using query.. here is my sample code


        SELECT 
              field1,
              field2
        FROM
              table1 a
              INNER JOIN function1((SELECT date1 from table2),(SELECT date2 from Table2),a.field1,a.Field2) b ON a.field1 = b.SimilarFieldReturnedFromFunction



a.field1 and b.field2 is also used in passing data. I can accomlish this if I manually pass string parameters (LIKE THIS function1('11-02-2012','11-02-2012',50,50)) it will run smothly but i just can't find a way to do this dynamically. this is for my VIEWS

Is This A Good Question/Topic? 0
  • +

Replies To: How can I pass data coming from a query in function parameters?

#2 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 352
  • View blog
  • Posts: 769
  • Joined: 27-June 09

Re: How can I pass data coming from a query in function parameters?

Posted 07 December 2012 - 11:12 AM

If you are joining to a function, you cannot use fields from the table as parameters. You are essentially trying to join table1 to a set of tables returned by the function. Instead of a join, a subquery can be used to accomplish this.

SELECT 
a.field1,
a.field2
FROM Table1 a
WHERE field1=(SELECT SimilarToField1 FROM function1(somedate1, somedate2, a.field1, a.field2))


This post has been edited by mojo666: 07 December 2012 - 11:13 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1