Re: how to create a function w/in a query?



On 20 Jan 2007 09:15:14 -0800, "ash" <ash477@xxxxxxxxxxx> wrote:

Using Access ('07 I have now - but doesn't matter) - lets say i have 2
tables

Table1, with fields a,b,c
Table2, with fields h,i,,j

I want a query that does something like this:

select a, b, c, function( select j from Table2 where c =h)
from Table1


Something like that. Basically, I know how to do this in oracle. I
can call an oracle function within a select statement, and bring some
value back from another table. I can even pass in a value from the
select, into the function - if I recall correctly. Anyhow, I want to
know how i can do this with Access. (I'm using Access 2007 - but i dont
think the queries are much different from '03). I'm somewhat new to
access queries, so any help or pointing me to a site that shows this,
would be great!

Ash

Oracle and SQL/Server let you mix programming language constructs with
SQL queries... but Access doesn't. What you can do is create a
function in VBA, by creating a new Module; and you can call that
function from a Query. You can pass *values* - strings, numbers, etc.
- but (other than passing a SQL string and having code in your
function that parses it) you can't pass a SQL statement.

John W. Vinson[MVP]
.



Relevant Pages

  • Re: Incredibly slow query when asking for specific row, but not when asking f?r *
    ... table1.*, table2.*) is very quick, querying for any specific fields is ... What are the query plans? ... Probably the second query gives poor performance because a not so ...
    (comp.databases.sybase)
  • Re: Can this be done using a Data adapter??
    ... values to table3. ... view and manually run the insert or update SQL commands. ... have the 1st column read only and put the table1 values there). ... have done up to now is i bring the data of table1 and table2 from the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Extract trades that do NOT match the other table
    ... HOW do you determine which records in Table1 MATCH a record in Table2? ... Assuming that ID and Name both must match then try the following query. ... All trades from before till now. ...
    (microsoft.public.access.queries)
  • Re: How do I show all in a count query?
    ... you will have to do this in the SQL view of the ... of a new query. ... FROM Table1 ... "Joseph C." wrote: ...
    (microsoft.public.access.queries)
  • RE: Table as Criteria
    ... > Build your SQL statement in VBA using the table names picked by the user from ... > Select Table1.* from Table1 etc. ... > Select Table2.* from Table2 etc. ... >> I would like to do a dynamic query, but don't know how, so if anybody could ...
    (microsoft.public.access.queries)