|
Home > Archive > Programming with dBASE > February 2006 > SQL Statements
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Bosco Wilson 2006-02-12, 11:23 am |
| I am trying to export a few tables to a file, but want to export only fields
that match a date. I am using a simple form with a date selector named
"date" and a "submit" button to do the export. I am having problems with
the SQL statement. I have tried:
q.sql = 'select column1, column2 from table1 where date = ' +
form.date.value
Obviously not working. What is the correct way to do this?
Thank you for any help.
Bosco
| |
| Robert Bravery 2006-02-12, 11:23 am |
| HI,
Watch youre datatypes. youre sql statement is a string, and I think youre
trying to add a date datatype to it
try this
q.sql = "select column1, column2 from table1 where date = '" +
form.date.value+"'"
Robert
"Bosco Wilson" <bosco@wilserv.net> wrote in message
news:W5E%236n%23LGHA
.2016@news-server...
> I am trying to export a few tables to a file, but want to export only
fields
> that match a date. I am using a simple form with a date selector named
> "date" and a "submit" button to do the export. I am having problems with
> the SQL statement. I have tried:
>
> q.sql = 'select column1, column2 from table1 where date = ' +
> form.date.value
>
> Obviously not working. What is the correct way to do this?
>
> Thank you for any help.
>
> Bosco
>
>
| |
| Ivar B. Jessen 2006-02-12, 1:23 pm |
| On Sun, 12 Feb 2006 10:28:24 -0500, in dbase.programming,
Subject: SQL Statements,
Message-ID: <W5E#6n#LGHA.2016@news-server>,
"Bosco Wilson" <bosco@wilserv.net> wrote:
>I am trying to export a few tables to a file, but want to export only fields
>that match a date. I am using a simple form with a date selector named
>"date" and a "submit" button to do the export. I am having problems with
>the SQL statement. I have tried:
>
>q.sql = 'select column1, column2 from table1 where date = ' +
>form.date.value
>
>Obviously not working.
You will never get anything like this to work ;-)
DATE is a reserved word in local sql. See the OLH on reserved words.
DATE should never be used as a name for a date selector, whatever that is.
DATE should never be used as a column name in a SQL statement as you do here.
DATE should never be used as you do here in form.date.value.
>What is the correct way to do this?
q.sql = 'select column1, column2 from table1 where column2 = :MydateVal'
q.params["MyDateVal"] = form.entryfield1.value
This assumes that table1 has the date values in column2 and the selected date is
in the forms entryfield1.
Ivar B. Jessen
| |
|
|
>
> You will never get anything like this to work ;-)
>
> DATE is a reserved word in local sql. See the OLH on reserved words.
>
> DATE should never be used as a name for a date selector, whatever that is.
> DATE should never be used as a column name in a SQL statement as you do here.
> DATE should never be used as you do here in form.date.value.
>
Could he not just do something like:
select a.column1,a.column2 from table1 a where a."date" = form.date.value
Glenn Fausel
Uses date too often
| |
| Bosco Wilson 2006-02-12, 8:23 pm |
| Thanks everyone for the tips. q.params[] seems to work perfectly :)
Thanks again.
Bosco
"Ivar B. Jessen" <bergishagen@it.notthis.dk> wrote in message
news:4tvuu1d2jdebjg1
3ln5rgdjghhp3hndlgc@
4ax.com...
> On Sun, 12 Feb 2006 10:28:24 -0500, in dbase.programming,
> Subject: SQL Statements,
> Message-ID: <W5E#6n#LGHA.2016@news-server>,
> "Bosco Wilson" <bosco@wilserv.net> wrote:
>
>
> You will never get anything like this to work ;-)
>
> DATE is a reserved word in local sql. See the OLH on reserved words.
>
> DATE should never be used as a name for a date selector, whatever that is.
> DATE should never be used as a column name in a SQL statement as you do
> here.
> DATE should never be used as you do here in form.date.value.
>
>
> q.sql = 'select column1, column2 from table1 where column2 = :MydateVal'
> q.params["MyDateVal"] = form.entryfield1.value
>
> This assumes that table1 has the date values in column2 and the selected
> date is
> in the forms entryfield1.
>
>
> Ivar B. Jessen
| |
| Ivar B. Jessen 2006-02-12, 8:23 pm |
| On Sun, 12 Feb 2006 14:59:41 -0500, in dbase.programming,
Subject: Re: SQL Statements,
Message-ID: <#LCkh$AMGHA.1752@news-server>,
"Bosco Wilson" <bosco@wilserv.net> wrote:
>Thanks everyone for the tips. q.params[] seems to work perfectly :)
>
>Thanks again.
You are welcome ;-)
Ivar B. Jessen
|
|
|
|
|