sql query with fieldName as variable name

info at vallemediatime.com info at vallemediatime.com
Tue May 31 14:17:21 CDT 2005


Hi Peter, thanks again
I know that it's a lingo question, but not only...
I've tried with your suggestion, look at two differentet code:

query = "SELECT RecID, * from Students WHERE F = '" & searchString & "'"
gCursor = gDb.sqlSelect(query, #kServer, #kReadWrite, #kRandom)
this is ok, the query works right

if I use:

global gSearchField
put gSearchField
-- "F"

query = "SELECT RecID, * FROM Students WHERE " && gSearchField && " = '" &
searchString & "'"
gCursor = gDb.sqlSelect(query, #kServer, #kReadWrite, #kRandom)
put gCursor
-- VOID

Any suggestion?
I don't undestand how is possible to pass a lingo variable into a sql query,
I think that "F" instead of F make error...
Paolo






----- Original Message -----
From: "peter salomon" <peter.salomon at gmx.net>
To: "Valentina Developers" <valentina at lists.macserve.net>
Sent: Tuesday, May 31, 2005 12:51 PM
Subject: Re: sql query with fieldName as variable name


> Hi Paolo,
>
> this is a lingo question i think, not valentina.
> i´m not sure what you want to do, of course you can store anything in
> global variables, also fieldnnames. You do it by defining it:
>
> global gFieldName
> then you put something into it:
>
> gFieldName = "fldAnyName"
> if you want to build an sql string you can construct it as:
>
> "SELECT RecID, * FROM students WHERE" && gFieldName && "= '" &
searchString &
> "'"
>
> you need a field in your table named  "fldAnyName" and
> searchstring must be a local or global variable containing a string..
>
> is that what you wanted to know?
> Peter
>
> info at vallemediatime.com wrote:
>
> >Hi Ruslan,
> >I will keep the fieldname as global variable name, how can I write it?
> >
> >global fieldName
> >query = "SELECT RecID, * from STUDENTS WHERE fieldName = '" &
searchString &
> >"'"
> >
> >I've tried with:
> >query = "SELECT RecID, * from STUDENTS WHERE 'fieldName' = '" &
searchString
> >& "'" and other forms
> >but I don't try the right way...
> >
> >P.S. Thank Peter for the "nil" answer :-)
> >
> >
> >
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.322 / Virus Database: 267.2.0 - Release Date: 27/05/2005
>
>



More information about the Valentina mailing list