Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ahsan Rana
  Where is Ahsan Rana?
 Lahore
 Pakistan
 Ahsan Rana
 To: Rick C. Hodgin
  Where is Rick C. Hodgin?
 Indianapolis
 Indiana - United States
 Rick C. Hodgin
 Tags
Subject: RE: Conditional View in MySql
Thread ID: 365665 Message ID: 365687 # Views: 40 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Sunday, December 30, 2012 9:59:20 AM         
   


> > Hi Experts
> >
> > I want to create View in MySql with Where Condition and Where Condition is variable. User can select any product from VFP Form and View in MySql will select data only for the selected product.
> >
> > Rgds:
> > Ahsan Rana
>
>
>
> You need to assemble the SQL expression you want to execute on MySql with SQLEXEC() as a regular character string, replacing the WHERE clause portion with your variables.
>
> Example:
>
lcSql = "SELECT * FROM myTable WHERE $field$ $cond$ $value$"
> 
> * Replace the variable portions
> lcSql = STRTRAN(lcSql, "$field$", thisForm.whatever.field.value)
> lcSql = STRTRAN(lcSql, "$cond$",  thisForm.whatever.condition.value)
> lcSql = STRTRAN(lcSql, "$value$", thisForm.whatever.data.value)
> 
> * Alternatively:
> lcSql = "SELECT * FROM myTable WHERE " + ;
>             thisForm.whatever.field.value + " " + ;
>             thisForm.whatever.condition.value + " " + ;
>             thisForm.whatever.data.value
> 
> * You can then log the constructed string here, or do whatever else you'd like with it
> 
> * To execute:
> lnResult = SQLEXEC(gnConn, lcSql, 'c_myCursor')
> 

>
> Basically, you're assembling the string to be the thing you need in the way you need it.
>
> Best regards,
> Rick C. Hodgin


Following is my Code. Should be great full if you set my code as per your query

ac = '12345'

= SqlExec(mConn,"Select * From Inv Where Code = ?ac","Inv")


Now ac is variable and I want that MySql View call data only for code = ac. I think in this way I can select data very fast for view and other wise if there is no Where Condition in View, View query will call data for over all and that process will take some time.

Rgds:
Ahsan Rana

ENTIRE THREAD

Conditional View in MySql Posted by Ahsan Rana @ 12/29/2012 6:40:17 PM
RE: Conditional View in MySql Posted by Rick Hodgin @ 12/29/2012 7:36:07 PM
RE: Conditional View in MySql Posted by Ahsan Rana @ 12/30/2012 9:59:20 AM
RE: Conditional View in MySql Posted by Michel Levy @ 12/30/2012 11:10:28 AM
RE: Conditional View in MySql Posted by David Mustakim @ 12/30/2012 11:30:42 AM
RE: Conditional View in MySql Posted by Stefan Wuebbe @ 12/30/2012 12:51:16 PM
RE: Conditional View in MySql Posted by Ahsan Rana @ 12/30/2012 1:01:04 PM
RE: Conditional View in MySql Posted by Stefan Wuebbe @ 12/30/2012 1:13:28 PM
RE: Conditional View in MySql Posted by David Mustakim @ 12/30/2012 4:40:56 PM
RE: Conditional View in MySql Posted by Michel Levy @ 12/30/2012 5:59:59 PM
RE: Conditional View in MySql Posted by David Mustakim @ 12/30/2012 6:53:52 PM
RE: Conditional View in MySql Posted by Michel Levy @ 12/30/2012 1:06:01 PM
RE: Conditional View in MySql Posted by Rick Hodgin @ 12/30/2012 2:59:44 PM
RE: Conditional View in MySql Posted by Michel Levy @ 12/30/2012 6:19:54 PM
RE: Conditional View in MySql Posted by Rick Hodgin @ 12/30/2012 11:46:35 PM
RE: Conditional View in MySql Posted by Michel Levy @ 12/31/2012 12:08:20 PM
RE: Conditional View in MySql Posted by Rick Hodgin @ 12/31/2012 9:37:10 PM
RE: Conditional View in MySql Posted by Michel Levy @ 12/30/2012 6:20:12 PM
RE: Conditional View in MySql Posted by Rick Hodgin @ 12/31/2012 12:06:08 AM
RE: Conditional View in MySql Posted by M. Tanveer Ul Hassan Shaheen @ 12/29/2012 9:05:17 PM
RE: Conditional View in MySql Posted by M. Tanveer Ul Hassan Shaheen @ 12/29/2012 9:11:09 PM
RE: Conditional View in MySql Posted by David Mustakim @ 12/30/2012 1:49:10 PM
RE: Conditional View in MySql Posted by Anders Altberg @ 12/30/2012 4:09:15 PM