Include Variable within "TEXT INTO" (SOLVED)

Post Reply
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Include Variable within "TEXT INTO" (SOLVED)

Post 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

 
Last edited by fraxzi on Tue May 22, 2018 1:08 am, edited 1 time in total.
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Re: Include Variable within "TEXT INTO"

Post by hmpaquito »

User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: Include Variable within "TEXT INTO"

Post 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>>
 
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Re: Include Variable within "TEXT INTO"

Post by hmpaquito »

Please, you should thoroughly review the link that I showed here. :D
Horizon
Posts: 997
Joined: Fri May 23, 2008 1:33 pm

Re: Include Variable within "TEXT INTO"

Post 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 )

 
Regards,

Hakan ONEMLI

Harbour & VS 2019 & FWH 20.12
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Include Variable within "TEXT INTO"

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Include Variable within "TEXT INTO"

Post 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
 
Regards

G. N. Rao.
Hyderabad, India
Post Reply