Groups > dBase > dBase SQL Servers > Re: variables in local sql select




variables in local sql select

variables in local sql select
Thu, 21 Feb 2008 16:03:53 -000
Is this the only way?

dummy = "SELECT lname, FROM patient WHERE patient_id = " +
form.patient_id
&dummy

Thanks,
Andy



Post Reply
Re: variables in local sql select
Thu, 21 Feb 2008 17:15:23 +010
Andy Ellis schrieb:
> Is this the only way?
> 
> dummy = "SELECT lname, FROM patient WHERE patient_id = " +
form.patient_id
> &dummy

No.
P P P are the 3 golden rules for SQL servers.

Use P rocedures whereever it could be efficient,
Create  P rimary Keys for EVERY table,
P arametrize your queries to make them dynamic.


Query1.SQL = "Select lname from patient where patient_id = :pm_id"
Query1.params["pm_id"] = dummy

On first use:
Query1.active = .T.

On subsequent uses, for example when scrolling through a parent grid:
Query1.params["pm_id"] = query2.rowset.fields["id"].value
Query1.requery()
Post Reply
Re: variables in local sql select
Thu, 21 Feb 2008 17:16:33 +010
Lysander schrieb:
> Create  P rimary Keys for EVERY table,
> P arametrize your queries to make them dynamic.

Post Reply
about | contact