Include Variable within "TEXT INTO" (SOLVED)

Include Variable within "TEXT INTO" (SOLVED)

Postby fraxzi » Fri May 18, 2018 6:44 am

Hi All,

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

Example
Code: Select all  Expand view


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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Include Variable within "TEXT INTO"

Postby hmpaquito » Fri May 18, 2018 7:42 am

hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Include Variable within "TEXT INTO"

Postby fraxzi » Fri May 18, 2018 8:30 am

hmpaquito wrote:Hi,

Looking at viewtopic.php?f=6&t=29700&start=0

Regards



I tried:
Code: Select all  Expand view

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


The result should be:
Code: Select all  Expand view

SELECT * FROM table WHERE country = 'Spain'
 


but I got: :(
Code: Select all  Expand view

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
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Include Variable within "TEXT INTO"

Postby hmpaquito » Fri May 18, 2018 9:48 am

Please, you should thoroughly review the link that I showed here. :D
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Include Variable within "TEXT INTO"

Postby Horizon » Fri May 18, 2018 10:18 am

fraxzi wrote:
hmpaquito wrote:Hi,

Looking at viewtopic.php?f=6&t=29700&start=0

Regards



I tried:
Code: Select all  Expand view

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


ps. I have not tested.

The result should be:
Code: Select all  Expand view

SELECT * FROM table WHERE country = 'Spain'
 


but I got: :(
Code: Select all  Expand view

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



Maybe
Code: Select all  Expand view

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

 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Include Variable within "TEXT INTO"

Postby anserkk » Fri May 18, 2018 10:59 am

Did you try this ?

Code: Select all  Expand view
TEXT INTO cSql
  SELECT Column1
  FROM myTable
  WHERE Column2 = ?
ENDTEXT
nMyVar:=1
cSql := FW_AdoApplyParams( cSql, { nMyVar } )


Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Include Variable within "TEXT INTO"

Postby nageswaragunupudi » Fri May 18, 2018 12:51 pm

fraxzi wrote:Hi All,

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

Example
Code: Select all  Expand view


cVar := 'Spain'

TEXT INTO cSql

        SELECT * FROM table WHERE country = cVar

ENDTEXT

 


Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests