Subject Re: Paremeter for SQL SELECT
From Svatopluk Blaha <svatopluk.blaha@seznam.cz>
Date Thu, 26 Mar 2015 09:05:43 -0400
Newsgroups dbase.getting-started

Sam Onabanjo Wrote:

> function Pushbutton_onClick1
>      efID = form.ENTRYFIELD1.value
>      d = new database()
>      d.databaseName := "WhatName"
>      d.active := true
>      q = new query()
>      q.database := d
>      q.active = false
>      q.sql = "C:\...\Job\SelectID.sql"
>      q.params["pID"] = efID
>      q.active = true
>      return
>
> (1)     d.databaseName:="WhatName"
>
>         WhatName is the name of your previously created database where the
> table you will reference later resides.  If you are not using a database,
> you don’t need any reference to d.
>
> (2)    q.sql ="C:\...\Job\SelectID.sql"
>
>         Once you have a database referenced, you don’t need to quote the
> folder (directory) where your table resides.  The system will pick that up
> from the database.
>
>         The correct syntax for using this statement is as follows:
>
>         q.sql:=[select (the list of fields to select or * if all fields)
> from (the name of the table) WHERE (the conditions that must be fulfilled
> before the rowset will qualify to be retrieved).
>
>         In dBase code, the above statement would be as follows:
>
>         q.sql:=[select citycode,name,address from CUSTOMERS where citycode =
> :ccode]
>         q.params['ccode']='LA'
>         q.requestLive :=false
>         q.active:=true
>
>         Note the way the params was used.  (a)  It must be preceded by a
> colon (:) when declared and (2) the colon must be removed when being sent to
> the params[] clause, but instead must be enclosed in quotes.
>
>         The code above will retrieve the citycode, name and address from the
> customers table for all customers whose citycode is LA.
>
> HTH
>
> Sam Onabanjo
> "Svatopluk Blaha"  wrote in message news:j9gt2M$XQHA.632@ip-AC1E04A7...
>
> I will use the code pattern from Knowledgebase for Using the Params Property
> of the Query.  My problem is "WhatName", what is its relation to the query
> "q"  or to the "SelectID.sql" ? All I used was "not found".
>
> function Pushbutton_onClick1
>      efID = form.ENTRYFIELD1.value
>      d = new database()
>      d.databaseName := "WhatName"
>      d.active := true
>      q = new query()
>      q.database := d
>      q.active = false
>      q.sql = "C:\...\Job\SelectID.sql"
>      q.params["pID"] = efID
>      q.active = true
>      return
>
> SelectID.sql : SELECT List.ID, List.xy FROM List WHERE pID = :efID

Svatopluk Blaha wrote

Many thanks for explaining but using your's code I do not obtain asked result. Table Job has fields Id and Xy, value of Id are "A" or "B". Formular has an entryfield for input parameter value and  a pushbutton for starting selection. The code I have is:
....
class JobFForm of FORM
   with (this)
      ....
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
     ...
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
     ...
      text = "SELECT"
   endwith

   function PUSHBUTTON1_onClick
      cId = form.entryfield1.value  // cId = "A"
      ? "cId= "+cId
      q = new Query()
      q.sql=[SELECT * FROM Job WHERE Id = :pId]
      q.params['pId'] = 'cId'
      q.requestLive := false
      q.active:=true
      return

No result. Single statement: SELECT * FROM Job WHERE Id = 'A' works as it is expected of course. Where i made a mistake?
>



Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0