Page 1 of 1

Include Variable within "TEXT INTO" (SOLVED)

Posted: Fri May 18, 2018 6:44 am
by fraxzi
Hi All,

Is there a way to include/inject variable within TEXT INTO?

Example

Code: Select all


cVar := 'Spain'

TEXT INTO cSql

        SELECT * FROM table WHERE country = cVar

ENDTEXT

 

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 7:42 am
by hmpaquito

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 8:30 am
by fraxzi
hmpaquito wrote:Hi,

Looking at http://forums.fivetechsupport.com/viewt ... 00&start=0

Regards

I tried:

Code: Select all

var := "'Spain'"
TEXT INTO cSQL
        select * from table where country = <<var>>
ENDTEXT
 
The result should be:

Code: Select all

SELECT * FROM table WHERE country = 'Spain'
 
but I got: :(

Code: Select all

SELECT * FROM table WHERE country = <<var>>
 

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 9:48 am
by hmpaquito
Please, you should thoroughly review the link that I showed here. :D

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 10:18 am
by Horizon
fraxzi wrote:
hmpaquito wrote:Hi,

Looking at http://forums.fivetechsupport.com/viewt ... 00&start=0

Regards

I tried:

Code: Select all

var := "'Spain'"
TEXT INTO cSQL
        select * from table where country = <<var>>
ENDTEXT
 
ps. I have not tested.

The result should be:

Code: Select all

SELECT * FROM table WHERE country = 'Spain'
 
but I got: :(

Code: Select all

SELECT * FROM table WHERE country = <<var>>
 

Maybe

Code: Select all

var := "'Spain'"
TEXT INTO cSQL
        select * from table where country = $1
ENDTEXT
cSQL:= Expand( cSQL, Var )

 

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 10:59 am
by anserkk
Did you try this ?

Code: Select all

TEXT INTO cSql
  SELECT Column1 
  FROM myTable
  WHERE Column2 = ? 
ENDTEXT
nMyVar:=1
cSql := FW_AdoApplyParams( cSql, { nMyVar } )
Regards
Anser

Re: Include Variable within "TEXT INTO"

Posted: Fri May 18, 2018 12:51 pm
by nageswaragunupudi
fraxzi wrote:Hi All,

Is there a way to include/inject variable within TEXT INTO?

Example

Code: Select all


cVar := 'Spain'

TEXT INTO cSql

        SELECT * FROM table WHERE country = cVar

ENDTEXT

 

Code: Select all

PRIVATE cVar := "'Spain'"  // do not declare cVar as local

TEXT INTO cSql
 SELECT * FROM table WHERE country = &cVar
ENDTEXT