Re: DLookup('field', 'table', ['condition']) - Mailing list pgsql-sql

From Josh Berkus
Subject Re: DLookup('field', 'table', ['condition'])
Date
Msg-id 3A9BD875.AA1290BD@agliodbs.com
Whole thread Raw
In response to Re: DLookup('field', 'table', ['condition'])  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-sql
Mr. Ambos,

> Is this supposed to give effectively the same result as the subquery
> (select student.id where name='Bill Gates' limit 1)?  I don't think
> that subquery is supported in 7.0, but will be in 7.1 along with
> EXECUTE for plpgsql which should let you build a query out of the
> parts you give it.  I think you'd possibly be able to do this in 7.0
> using pltcl but I don't know tcl so I can't help there.

Based on an earlier discussion regarding dynamic queries and EXECUTE,
what you want will be hard to do with an SQL or PL/pgSQL function
(although possible) even in 7.1.  According to one developer, with
PL/Tcl it's easier to build dynamic queries; one could also use C or
Perl.

However, you may want to re-think why you're using a dynamic "DLookup"
function rather than a more specific function, saved query, or view. 
Dynamic queries are always going to run slower, regardless of language,
than saved DB structures.  This is especially true of Dlookup in MS
Access, let alone DSum or DCount.  

If the program role you're trying to serve is frequent (student look-up,
for example) in your application, you would probably be better off in
several regards constructing a specific function to fill that purpose
(lf_lookup_student_id(VARCHAR)).  Personally, I'm a function "junkie" an
I've never had need to replicate the VBA Dlookup functionality.

-Josh Berkus


-- 
______AGLIO DATABASE SOLUTIONS___________________________                                       Josh Berkus  Complete
informationtechnology      josh@agliodbs.com   and data management solutions       (415) 565-7293  for law firms, small
businesses      fax  621-2533   and non-profit organizations.       San Francisco
 


pgsql-sql by date:

Previous
From: Kyle
Date:
Subject: Debug messages in beta5
Next
From: Tom Lane
Date:
Subject: Re: Debug messages in beta5