Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General PostgreSQL Topics / March 2007

Tip: Looking for answers? Try searching our database.

If criteria is Null then show all.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
valntyn - 07 Mar 2007 20:33 GMT
I have an .asp page that passes four variables to another .asp page by using
an HTML form.  A SQL query then runs against an Access database using those
four variables.  The variables are: "cnty", "rte", "bgn", and "nd".

My current SQL statement is as follows:

SQL = "SELECT * FROM Construction WHERE County='" & cnty & "' AND Route='" &
rte & "' AND Begin<=" & nd & " AND Ending>=" & bgn & ""  

This works just fine, but I would like to add the ability to make "nd" and
"bgn" Null (leave those fields blank on the HTML form), and then return all
records that match the "cnty" and "rte" variables.  I have an SQL Query in
the Access database that does this perfectly but I'm having trouble getting
the same functionality on the web.

Any help is greatly appreciated!
Lew - 09 Mar 2007 14:23 GMT
> I have an .asp page that passes four variables to another .asp page by using
> an HTML form.  A SQL query then runs against an Access database using those
[quoted text clipped - 10 lines]
> the Access database that does this perfectly but I'm having trouble getting
> the same functionality on the web.

Pseudocode:

if ( empty( cnty ))
  SQL = "SELECT * FROM Construction WHERE Route='" & rte & "' AND Begin<=" &
nd & " AND Ending>=" & bgn

else
  SQL = "SELECT * FROM Construction WHERE County='" & cnty & "' AND Route='"
& rte & "' AND Begin<=" & nd & " AND Ending>=" & bgn

-- Lew
Lew - 09 Mar 2007 14:26 GMT
>> I have an .asp page that passes four variables to another .asp page by
>> using
[quoted text clipped - 16 lines]
>> getting
>> the same functionality on the web.

Sorry, I focused on the wrong variable:

Pseudocode:

if ( empty( bgn ) OR empty( nd ) )
  SQL = "SELECT * FROM Construction WHERE County='" & cnty & "' AND
Route='" & rte & "' "

else
  SQL = "SELECT * FROM Construction WHERE County='" & cnty & "' AND
Route='" & rte & "' AND Begin<=" & nd & " AND Ending>=" & bgn

-- Lew
HansH - 09 Mar 2007 16:23 GMT
> My current SQL statement is as follows:
>
[quoted text clipped - 9 lines]
> getting
> the same functionality on the web.

How about ...
FLAG = empty( bgn ) OR empty( nd ) ? 'true' : 'false';
SQL = "SELECT * FROM Construction WHERE County='" & cnty
   & "' AND Route='" & rte
   & "' AND ( " & FLAG
       & " or Begin<=0" & nd & " AND Ending>=0" & bgn & " )"

Note: assuming numerical input for nd and bgn, thus prepending 0.

Leaving out vowels in variable names ... Hebrew background?

HansH
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.