Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax for passing a string with '?' thru SQLEXEC
Message
From
18/07/2006 18:09:08
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
18/07/2006 16:58:19
Calvin Smith
Wayne Reaves Computer Systems
Macon, Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01137400
Message ID:
01137425
Views:
16
>I am attempting to write to a Postgres table using SQLEXEC. Trouble is that the user occasionally types a '?' into a memo field and this causes an error in SQLEXEC. Apparently VFP thinks this is a param query. Is there any way around this?

VFP's engine which communicates with ODBC sources uses the question mark as a prefix for variables to be passed, and parses the rest of the SQL command string to extract the variable (or expression), which it will then replace with a local variable (local to the server-side script). The end result (thanks, Mike Yearwood - message #1110465) is, roughly, this set of commands to be executed serverside:
declare @var1 {type goes here}
select @var1=N'{your VFP variable's content as converted string}
select * from ... where ...somefield=@var1
The parser seems to find the question mark somewhere in your SQL string and gets confused, trying to extract a variable from the characters immediately to the right of it. If it's a typical text, a question mark is followed by a space or a carriage return, which then means it just finds nothing.

You can turn this to your advantage. You probably already have the value in a variable. Instead of generating a command like
update yourtable set somefield='{your text containing a question mark}'
you can have a command like this:
update yourtable set somefield=?yourVariable
(where your variable contains the value to be passed) and let Fox do the rest. The variable needs to be in scope when SqlExec() executes. Then VFP takes care of all the conversions for you.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform