pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedhow to determine where a select statement fails
9+ messages / 5 participants
[nested] [flat]
* how to determine where a select statement fails
@ 2001-07-26 15:15 Heather Johnson <hjohnson@nypost.com>
2001-07-26 15:56 ` Re: how to determine where a select statement fails Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 18:05 ` Re: how to determine where a select statement fails Brent R. Matzelle <bmatzelle@yahoo.com>
0 siblings, 2 replies; 9+ messages in thread
From: Heather Johnson @ 2001-07-26 15:15 UTC (permalink / raw)
To: pgsql-php
I am using php to do a select query which returns rows on the condition that
a conjunction is true in the WHERE clause. This is the SELECT statement:
SELECT low_range, high_range, st_name, city, zip FROM router
WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
In the event that the query fails to return any rows, I'd like to be able to
determine which conjunct caused it to fail. So, for example, if the
user-entered $st_name isn't in the router table, I'd like to know that
st_name = '$st_name' is what made the conjunction false and caused the query
to fail. $pg_errormsg isn't this specific about query failures though. Does
anyone know how I might be able to get this information?
Thanks!
Heather Johnson
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: how to determine where a select statement fails
2001-07-26 15:15 how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
@ 2001-07-26 15:56 ` Adam Lang <aalang@rutgersinsurance.com>
1 sibling, 0 replies; 9+ messages in thread
From: Adam Lang @ 2001-07-26 15:56 UTC (permalink / raw)
To: pgsql-php
I really don't think that is SQL's job. I think you have to code conditions
like that yourself.
Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Heather Johnson" <hjohnson@nypost.com>
To: <pgsql-php@postgresql.org>
Sent: Thursday, July 26, 2001 11:15 AM
Subject: [PHP] how to determine where a select statement fails
> I am using php to do a select query which returns rows on the condition
that
> a conjunction is true in the WHERE clause. This is the SELECT statement:
>
> SELECT low_range, high_range, st_name, city, zip FROM router
> WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
>
> In the event that the query fails to return any rows, I'd like to be able
to
> determine which conjunct caused it to fail. So, for example, if the
> user-entered $st_name isn't in the router table, I'd like to know that
> st_name = '$st_name' is what made the conjunction false and caused the
query
> to fail. $pg_errormsg isn't this specific about query failures though.
Does
> anyone know how I might be able to get this information?
>
> Thanks!
> Heather Johnson
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: how to determine where a select statement fails
2001-07-26 15:15 how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
@ 2001-07-26 18:05 ` Brent R. Matzelle <bmatzelle@yahoo.com>
2001-07-26 18:35 ` Re: Re: how to determine where a select statement fails Adam Lang <aalang@rutgersinsurance.com>
1 sibling, 1 reply; 9+ messages in thread
From: Brent R. Matzelle @ 2001-07-26 18:05 UTC (permalink / raw)
To: Heather Johnson <hjohnson@nypost.com>; pgsql-php
--- Heather Johnson <hjohnson@nypost.com> wrote:
> I am using php to do a select query which returns rows on the
> condition that
> a conjunction is true in the WHERE clause. This is the SELECT
> statement:
>
> SELECT low_range, high_range, st_name, city, zip FROM router
> WHERE st_name = '$st_name' AND city = '$city' AND zip =
> '$zip';
>
> In the event that the query fails to return any rows, I'd like
> to be able to
> determine which conjunct caused it to fail.
I'm not sure if I understand what your problem is. If a query
does not return any rows (pg_numrows() < 1) then that is not
really a "failure". If the SQL was incorrect then I would
suggest printing it to the browser (echo $query) and pasting it
in a query program like psql or winsql to determine which line
of code was incorrect.
Brent
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Re: how to determine where a select statement fails
2001-07-26 15:15 how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
2001-07-26 18:05 ` Re: how to determine where a select statement fails Brent R. Matzelle <bmatzelle@yahoo.com>
@ 2001-07-26 18:35 ` Adam Lang <aalang@rutgersinsurance.com>
0 siblings, 0 replies; 9+ messages in thread
From: Adam Lang @ 2001-07-26 18:35 UTC (permalink / raw)
To: pgsql-php
Basically, the person wants to know which where clause caused the query to
return 0 results.
Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Brent R. Matzelle" <bmatzelle@yahoo.com>
To: "Heather Johnson" <hjohnson@nypost.com>; <pgsql-php@postgresql.org>
Sent: Thursday, July 26, 2001 2:05 PM
Subject: [PHP] Re: how to determine where a select statement fails
> I'm not sure if I understand what your problem is. If a query
> does not return any rows (pg_numrows() < 1) then that is not
> really a "failure". If the SQL was incorrect then I would
> suggest printing it to the browser (echo $query) and pasting it
> in a query program like psql or winsql to determine which line
> of code was incorrect.
>
> Brent
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: how to determine where a select statement fails
@ 2001-07-26 15:35 Timothy_Maguire@hartehanks.com
2001-07-26 18:30 ` Re: Re: how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
0 siblings, 1 reply; 9+ messages in thread
From: Timothy_Maguire@hartehanks.com @ 2001-07-26 15:35 UTC (permalink / raw)
To: Heather Johnson <hjohnson@nypost.com>; +Cc: pgsql-php; pgsql-php-owner@postgresql.org
other than putting an if statement and doing 3 more queries, I can't think
of anything
something like:
if(pg_numrows == 0)
{
select * from table where streetname = streetname
if(pg_numrows == 0)
{
you found your error
}
else
{
do another query.........
}
}
Tim.
Timothy P. Maguire
Web Developer II
Harte-Hanks
978 436 3325
"Heather Johnson"
<hjohnson@nypost.com To: <pgsql-php@postgresql.org>
> cc:
Sent by: Subject: how to determine where a select statement
pgsql-php-owner@post fails
gresql.org
07/26/01 11:15 AM
I am using php to do a select query which returns rows on the condition
that
a conjunction is true in the WHERE clause. This is the SELECT statement:
SELECT low_range, high_range, st_name, city, zip FROM router
WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
In the event that the query fails to return any rows, I'd like to be able
to
determine which conjunct caused it to fail. So, for example, if the
user-entered $st_name isn't in the router table, I'd like to know that
st_name = '$st_name' is what made the conjunction false and caused the
query
to fail. $pg_errormsg isn't this specific about query failures though. Does
anyone know how I might be able to get this information?
Thanks!
Heather Johnson
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Re: how to determine where a select statement fails
2001-07-26 15:35 Re: how to determine where a select statement fails Timothy_Maguire@hartehanks.com
@ 2001-07-26 18:30 ` Heather Johnson <hjohnson@nypost.com>
2001-07-26 18:56 ` Re: Re: how to determine where a select statement fails Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 19:05 ` Re: Re: how to determine where a select statement fails Rene-Raphael <rene_raphael@mac.com>
0 siblings, 2 replies; 9+ messages in thread
From: Heather Johnson @ 2001-07-26 18:30 UTC (permalink / raw)
To: Timothy_Maguire@hartehanks.com; +Cc: pgsql-php; pgsql-php-owner@postgresql.org
Thanks for the suggestion! I don't really want to do that though b/c the
table that I'm searching is pretty large. I was hoping to do only one query
on the table and then put some indexes on the fields to improve performance.
But I can't think of a way to structure my code so that I can do just one
query AND get info about which user-entered values don't find a match.
(Brent Matzelle suggested that this isn't really a "failure" of the query,
and I guess he's right, so hopefully this describes what I'm talking about a
little better).
Heather
----- Original Message -----
From: <Timothy_Maguire@hartehanks.com>
To: "Heather Johnson" <hjohnson@nypost.com>
Cc: <pgsql-php@postgresql.org>; <pgsql-php-owner@postgresql.org>
Sent: Thursday, July 26, 2001 11:35 AM
Subject: [PHP] Re: how to determine where a select statement fails
>
> other than putting an if statement and doing 3 more queries, I can't think
> of anything
>
> something like:
> if(pg_numrows == 0)
> {
> select * from table where streetname = streetname
> if(pg_numrows == 0)
> {
> you found your error
> }
> else
> {
> do another query.........
> }
> }
>
> Tim.
>
> Timothy P. Maguire
> Web Developer II
> Harte-Hanks
> 978 436 3325
>
>
>
>
> "Heather Johnson"
> <hjohnson@nypost.com To:
<pgsql-php@postgresql.org>
> > cc:
> Sent by: Subject: how to
determine where a select statement
> pgsql-php-owner@post fails
> gresql.org
>
>
> 07/26/01 11:15 AM
>
>
>
>
>
>
> I am using php to do a select query which returns rows on the condition
> that
> a conjunction is true in the WHERE clause. This is the SELECT statement:
>
> SELECT low_range, high_range, st_name, city, zip FROM router
> WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
>
> In the event that the query fails to return any rows, I'd like to be able
> to
> determine which conjunct caused it to fail. So, for example, if the
> user-entered $st_name isn't in the router table, I'd like to know that
> st_name = '$st_name' is what made the conjunction false and caused the
> query
> to fail. $pg_errormsg isn't this specific about query failures though.
Does
> anyone know how I might be able to get this information?
>
> Thanks!
> Heather Johnson
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Re: how to determine where a select statement fails
2001-07-26 15:35 Re: how to determine where a select statement fails Timothy_Maguire@hartehanks.com
2001-07-26 18:30 ` Re: Re: how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
@ 2001-07-26 18:56 ` Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 20:13 ` Re: Re: how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
1 sibling, 1 reply; 9+ messages in thread
From: Adam Lang @ 2001-07-26 18:56 UTC (permalink / raw)
To: ; +Cc: pgsql-php
What you also have to keep in mind is that one clause is not necessarily
keeping you from getting zero rows.
For example.
You have st_name and city.
Say you hve 5 entries for a street named "main" and 5 entries for a city
named "plainfield". But you have NO entries for a street named "main" in
the city of "plainfield". The fact you are looking for both is what returns
zero rows. Individually they exist.
What you are trying to do is nto easy at all. You can't just do if
statements to see which column has zero rows. You have to also check to see
what combo of clauses return ero.
Adam Lang
Systems Engineer
Rutgers Casualty Insurance Company
http://www.rutgersinsurance.com
----- Original Message -----
From: "Heather Johnson" <hjohnson@nypost.com>
To: <Timothy_Maguire@hartehanks.com>
Cc: <pgsql-php@postgresql.org>; <pgsql-php-owner@postgresql.org>
Sent: Thursday, July 26, 2001 2:30 PM
Subject: Re: [PHP] Re: how to determine where a select statement fails
> Thanks for the suggestion! I don't really want to do that though b/c the
> table that I'm searching is pretty large. I was hoping to do only one
query
> on the table and then put some indexes on the fields to improve
performance.
> But I can't think of a way to structure my code so that I can do just one
> query AND get info about which user-entered values don't find a match.
> (Brent Matzelle suggested that this isn't really a "failure" of the query,
> and I guess he's right, so hopefully this describes what I'm talking about
a
> little better).
>
> Heather
> > "Heather Johnson"
> > <hjohnson@nypost.com To:
> <pgsql-php@postgresql.org>
> > > cc:
> > Sent by: Subject: how to
> determine where a select statement
> > pgsql-php-owner@post fails
> > gresql.org
> >
> >
> > 07/26/01 11:15 AM
> >
> >
> >
> >
> >
> >
> > I am using php to do a select query which returns rows on the condition
> > that
> > a conjunction is true in the WHERE clause. This is the SELECT statement:
> >
> > SELECT low_range, high_range, st_name, city, zip FROM router
> > WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
> >
> > In the event that the query fails to return any rows, I'd like to be
able
> > to
> > determine which conjunct caused it to fail. So, for example, if the
> > user-entered $st_name isn't in the router table, I'd like to know that
> > st_name = '$st_name' is what made the conjunction false and caused the
> > query
> > to fail. $pg_errormsg isn't this specific about query failures though.
> Does
> > anyone know how I might be able to get this information?
> >
> > Thanks!
> > Heather Johnson
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Re: how to determine where a select statement fails
2001-07-26 15:35 Re: how to determine where a select statement fails Timothy_Maguire@hartehanks.com
2001-07-26 18:30 ` Re: Re: how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
2001-07-26 18:56 ` Re: Re: how to determine where a select statement fails Adam Lang <aalang@rutgersinsurance.com>
@ 2001-07-26 20:13 ` Heather Johnson <hjohnson@nypost.com>
0 siblings, 0 replies; 9+ messages in thread
From: Heather Johnson @ 2001-07-26 20:13 UTC (permalink / raw)
To: Adam Lang <aalang@rutgersinsurance.com>; +Cc: pgsql-php
Yes, you're right--I'd have to consider combo cases too. Thanks to everybody
that made suggestions. I guess it's not a really big deal if I can't do
this---was just hoping to add some bells and whistles to a script that
basically works fine as it is. ;)
----- Original Message -----
From: "Adam Lang" <aalang@rutgersinsurance.com>
Cc: <pgsql-php@postgresql.org>
Sent: Thursday, July 26, 2001 2:56 PM
Subject: Re: [PHP] Re: how to determine where a select statement fails
> What you also have to keep in mind is that one clause is not necessarily
> keeping you from getting zero rows.
>
> For example.
>
> You have st_name and city.
>
> Say you hve 5 entries for a street named "main" and 5 entries for a city
> named "plainfield". But you have NO entries for a street named "main" in
> the city of "plainfield". The fact you are looking for both is what
returns
> zero rows. Individually they exist.
>
> What you are trying to do is nto easy at all. You can't just do if
> statements to see which column has zero rows. You have to also check to
see
> what combo of clauses return ero.
>
> Adam Lang
> Systems Engineer
> Rutgers Casualty Insurance Company
> http://www.rutgersinsurance.com
> ----- Original Message -----
> From: "Heather Johnson" <hjohnson@nypost.com>
> To: <Timothy_Maguire@hartehanks.com>
> Cc: <pgsql-php@postgresql.org>; <pgsql-php-owner@postgresql.org>
> Sent: Thursday, July 26, 2001 2:30 PM
> Subject: Re: [PHP] Re: how to determine where a select statement fails
>
>
> > Thanks for the suggestion! I don't really want to do that though b/c the
> > table that I'm searching is pretty large. I was hoping to do only one
> query
> > on the table and then put some indexes on the fields to improve
> performance.
> > But I can't think of a way to structure my code so that I can do just
one
> > query AND get info about which user-entered values don't find a match.
> > (Brent Matzelle suggested that this isn't really a "failure" of the
query,
> > and I guess he's right, so hopefully this describes what I'm talking
about
> a
> > little better).
> >
> > Heather
> > > "Heather Johnson"
> > > <hjohnson@nypost.com To:
> > <pgsql-php@postgresql.org>
> > > > cc:
> > > Sent by: Subject: how to
> > determine where a select statement
> > > pgsql-php-owner@post fails
> > > gresql.org
> > >
> > >
> > > 07/26/01 11:15 AM
> > >
> > >
> > >
> > >
> > >
> > >
> > > I am using php to do a select query which returns rows on the
condition
> > > that
> > > a conjunction is true in the WHERE clause. This is the SELECT
statement:
> > >
> > > SELECT low_range, high_range, st_name, city, zip FROM router
> > > WHERE st_name = '$st_name' AND city = '$city' AND zip = '$zip';
> > >
> > > In the event that the query fails to return any rows, I'd like to be
> able
> > > to
> > > determine which conjunct caused it to fail. So, for example, if the
> > > user-entered $st_name isn't in the router table, I'd like to know that
> > > st_name = '$st_name' is what made the conjunction false and caused the
> > > query
> > > to fail. $pg_errormsg isn't this specific about query failures though.
> > Does
> > > anyone know how I might be able to get this information?
> > >
> > > Thanks!
> > > Heather Johnson
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Re: how to determine where a select statement fails
2001-07-26 15:35 Re: how to determine where a select statement fails Timothy_Maguire@hartehanks.com
2001-07-26 18:30 ` Re: Re: how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
@ 2001-07-26 19:05 ` Rene-Raphael <rene_raphael@mac.com>
1 sibling, 0 replies; 9+ messages in thread
From: Rene-Raphael @ 2001-07-26 19:05 UTC (permalink / raw)
To: pgsql-php
Hi,
Your user could enter data freely or from popup menu by example ?
By my few knowledge, maybe, there no low cost ( number of queries )
solution ...
Tell ( of force ) your user to add condition step by step if there is
too many results, no why?
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2001-07-26 20:13 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-26 15:15 how to determine where a select statement fails Heather Johnson <hjohnson@nypost.com>
2001-07-26 15:56 ` Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 18:05 ` Brent R. Matzelle <bmatzelle@yahoo.com>
2001-07-26 18:35 ` Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 15:35 Re: how to determine where a select statement fails Timothy_Maguire@hartehanks.com
2001-07-26 18:30 ` Heather Johnson <hjohnson@nypost.com>
2001-07-26 18:56 ` Adam Lang <aalang@rutgersinsurance.com>
2001-07-26 20:13 ` Heather Johnson <hjohnson@nypost.com>
2001-07-26 19:05 ` Rene-Raphael <rene_raphael@mac.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