Additional
AnyDAC
SimpleIAX
Forums
Welcome, Guest
Please Login or Register to post messages. Lost Password?
tadquery and string problem
(1 viewing) 1 Guest
Go to bottom
TOPIC: tadquery and string problem
#21363
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
tadquery and string problem 2012/06/25 03:20 (11 Months ago)
Hi,

if i execute this statement:

select 'prova&ciao' as field1
from anaimb0f

this is what i get:

field1: prova

but if I execute this statement:

select 'prova&&ciao' as field1
from anaimb0f

this is what i get:

field1: prova&&ciao


The problem is that I need to have one & in my select because it's an html link that users have to click.

Could you please take a look at it?

Thanks,
Lorenzo
Logged Logged
The administrator has disabled public write access.
#21364
Support
Moderator
Posts: 5639
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 03:28 (11 Months ago)
Hello

1) AnyDAC recognizes '&' and '!' as macros marker. To disable macro processing set ResourceOptions.MacroCreate and MacroExpand to False. More about that:
www.da-soft.com/anydac/docu/Preprocessing_Command_Text.html

2) Still the best is to use parameters instead of literals.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
#21365
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 03:35 (11 Months ago)
Wow i did not know about this functionality!!

thank you so much.

Lorenzo
Logged Logged
The administrator has disabled public write access.
#21366
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 04:06 (11 Months ago)
I also would like to use parameters but in this case I cannot (at least i don't think i can) because the purpose of this program is that a user can insert a query in a txt, the program will get the txt and execute the query.

Just a question...fortunately in this project I do not need macros.

But what if I need macros and I also need to have a string composed with the '&' ?

I think it would be great to have a way to skip macro conversion just in a particular situation like mine...

do you think it's could be possible in the future?
Logged Logged
The administrator has disabled public write access.
#21367
Support
Moderator
Posts: 5639
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 09:00 (11 Months ago)
If you need to execute a query, which is not under your control, then you should turn off macro processing. If you going to provide the query by your self, then you can double the '&', AnyDAC will leave only single '&' from each two.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
#21368
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 09:47 (11 Months ago)
Hi,
thanks for answering.

However if I do:

Adquery1.Close;
Adquery1.SQL.text := 'select "prova&&ciao" as field1 from anaimb0f';
Adquery1.Open;

I see two && into the tdbgrid, not one.

Am I doing something wrong?
Logged Logged
The administrator has disabled public write access.
#21369
burdi
Moderator
Posts: 439
graphgraph
Karma: 8
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/25 11:01 (11 Months ago)
Probably you see 'field1' and not 'prova&&ciao' ?
Logged Logged
The administrator has disabled public write access.
#21371
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/26 01:29 (11 Months ago)
this is what i see with

Adquery1.SQL.text := 'select "prova&ciao" as field1 from anaimb0f';
Logged Logged
The administrator has disabled public write access.
#21372
lorife
Platinum Boarder
Posts: 354
graphgraph
Karma: 1
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/26 01:29 (11 Months ago)
this is what i see with

Adquery1.SQL.text := 'select "prova&&ciao" as field1 from anaimb0f';
Logged Logged
The administrator has disabled public write access.
#21375
Support
Moderator
Posts: 5639
graph
Karma: 99
User Offline Click here to see the profile of this user
Re:tadquery and string problem 2012/06/26 04:09 (11 Months ago)
Ok, I see. The '&' has special handling:
- &<name> - macro name;
- && - substituted as is - '&&'.
This is done because in many DBMS the '&&' is an operator. So, AnyDAC understands '&&' as operator and not as escaped '&'.

So, in your case you should turn off macro processing. When you will need to specify a command with a macro inside, then you should turn on macro processing.
With best regards,
DA-SOFT Technologies Support Team
Logged Logged
The administrator has disabled public write access.
Go to top