pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: DLookup('field', 'table', ['condition'])
3+ messages / 3 participants
[nested] [flat]
* Re: DLookup('field', 'table', ['condition'])
@ 2001-02-27 04:27 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Herbert Ambos <herbert@hindang.msuiit.edu.ph>
0 siblings, 1 reply; 3+ messages in thread
From: Stephan Szabo @ 2001-02-27 04:27 UTC (permalink / raw)
To: Herbert Ambos <herbert@hindang.msuiit.edu.ph>; +Cc: pgsql-sql
On Tue, 27 Feb 2001, Herbert Ambos wrote:
> I'm trying to create Domain Aggregate function that mimic Access' Dlookup
> function, but without any luck, after digging (i think) all the docs
> don't have the solution yet.
>
> Syntax:
>
> DLookup ('field', 'table|view', ['condition'])
>
> where:
> field -- column name or calculation
> table|view --
> condition (optional) -- SQL WHERE condition without the
> WHERE keyword
>
> If the query returns multiple rows then it will only get the
> topmost column.
> If the query retuns 0 rows then NULL would be returned
>
>
> An example argument to the function would be
>
> DLookup ('id', 'student', 'name=\'Bill Gates\'') --> '2001-432'
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* DLookup('field', 'table', ['condition'])
@ 2001-02-27 12:20 Herbert Ambos <herbert@hindang.msuiit.edu.ph>
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Ambos @ 2001-02-27 12:20 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm trying to create Domain Aggregate function that mimic Access' Dlookup
function, but without any luck, after digging (i think) all the docs
don't have the solution yet.
Syntax:
DLookup ('field', 'table|view', ['condition'])
where:
field -- column name or calculation
table|view --
condition (optional) -- SQL WHERE condition without the
WHERE keyword
If the query returns multiple rows then it will only get the
topmost column.
If the query retuns 0 rows then NULL would be returned
An example argument to the function would be
DLookup ('id', 'student', 'name=\'Bill Gates\'') --> '2001-432'
For now, I use some workaround for this, and it would be easier for me if
this function is present.
Hope u guys can help ;). Thank u in advance
Herbert
--
MSU - Iligan Institute of Technology
Iligan City, Philippines
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: DLookup('field', 'table', ['condition'])
@ 2001-02-27 16:40 Josh Berkus <josh@agliodbs.com>
parent: Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2001-02-27 16:40 UTC (permalink / raw)
To: 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 information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-02-27 16:40 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-27 12:20 DLookup('field', 'table', ['condition']) Herbert Ambos <herbert@hindang.msuiit.edu.ph>
2001-02-27 04:27 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-02-27 16:40 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox