Article View: borland.public.vdbase.data.sql
Article #585Re: Any ideas how to make this work?
From: Steve Koterski
Date: Tue, 20 Oct 1998 00:00
Date: Tue, 20 Oct 1998 00:00
39 lines
2375 bytes
2375 bytes
On Tue, 20 Oct 1998 10:51:33 -0500, mike <none@notgiven.com> wrote:
>I am trying to use variables to create a query statement:
>
>the dbmaint.dbf database has the following fields +.
>unti_num = numeric 8,0
>entrydate = date 8,0
>
>unit is loaded from a form entry field that formats it as text.
>I then use the VAL() function to convert it to numeric.
>the following statement works great.
>results.query1.sql = "select * from dbmaint.dbf where unit_num = " +unit
>
>sdate is loaded the same way as unit, from an entry field on a form that
>is formated at a date entry field.
>the following statement does NOT work.
>results.query1.sql = "select * from dbmaint.dbf where unit_num = " +unit
>+ " and entrydate >=" +sdate
>
>Can this be made to work?
>Is this the way I should be trying to do this?
What does "does NOT work" mean, exactly? You're getting an error message?
No error, but no or incorrect results?
One potential problem I see is that the date literal (represented by your
sdate variable) winds up with no delimiting quotation marks. Local SQL
requires that date literals in SQL statements be surrounded by quotation
marks. I would suggest a change something like:
results.query1.sql = 'SELECT * FROM dbmaint.dbf WHERE (unit_num = ' +
unit + ') AND (entrydate >= "' + sdate + '")'
//////////////////////////////////////////////////////////////////////////
Steve Koterski "What is success in this world? I would say
Technical Publications it consists of four simple things: to live
INPRISE Corporation a lot, to love a lot, to laugh a lot, and
http://www.inprise.com/delphi from it all, to learn a lot."
-- Richard J. Needham
Technical Details
Message-ID:
<3630d1d7.9783294@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<362CB185.25FCA8EF@notgiven.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff5a1,a104ec5b907376c2 X-Google-Attributes: gidff5a1,public From: skoterski@NOSPAMinprise.com (Steve Koterski) Subject: Re: Any ideas how to make this work? Date: 1998/10/20 Message-ID: <3630d1d7.9783294@forums.inprise.com> X-Deja-AN: 403262813 Content-Transfer-Encoding: 7bit References: <362CB185.25FCA8EF@notgiven.com> Content-Type: text/plain; charset=us-ascii Organization: INPRISE Corporation, Technical Publications Mime-Version: 1.0 Reply-To: skoterski@NOSPAMinprise.com Newsgroups: borland.public.vdbase.data.sql