×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

combine three records to one with a sql select()

combine three records to one with a sql select()

combine three records to one with a sql select()

(OP)
Hi,
I am facing a complete blackout, it seems, following code, which intents to combine the three records surname,insertion,famname into one record fullname, however somehow my coding is incorrect. Anybody to spot the error?

CODE --> vfp

lcLetter = 'K'
lcSQL = 'Select district, Alltrim(Alltrim(surname)+' '+Alltrim(insertion))+' '+famname As fullnaam, Id from NAW '+;
	IIF(Empty(m.lcLetter),'','where Substr(surname,1) = "'m.lcLetter)+'" order by 1 into cursor junklist nofilter' 

So the cursor should read e.g.
"Koen Piller","1"
"Kyle the Expert","2"


Regards,

Koen

RE: combine three records to one with a sql select()

What does lcSQL contain after the assignment?

What's actually happening? An error? Nothing returned?

Tamar

RE: combine three records to one with a sql select()

(OP)
Hi,

Error: "Command contains unrecognized phrase/keyword"

Regards,

Koen

RE: combine three records to one with a sql select()

You get this error when executing the lcSQL = ... line, right?
You can't have single quotes within a string delimited by single quotes.

A simplified version of your error:

CODE

lcSQL = 'Select a+' '+b from Table' 

This has two string literals in this line:
1. 'Select a+'
2. '+b from Table'

And there is a space in between them. Let's say you had these strings in two variables x and y, then in short your code is:

CODE

lcSQL = x y 
Do you see what the parser doesn't see a valid phrase in there? Just because your string separation with a space is so short it doesn't look like the end of the string to you, the parser still strictly interprets the same string delimiter the string starts with as the end. There is no parsing in the way "Oh, the user meant it differently". You start a string with a single quote? Fine, the next single quote the parser encounters is the end of that string. Even if no operator follows, but the next single quote string delimiter is starting the next string, which is a phrase error, the parser will not get back into string mode parsing and mend its interpretation, this is simple and strict.

In general it helps to set up your syntax coloring to show strings red, but in this case, the small gap between two strings will not be noticeable by simple syntax coloring.

There is a simple way to get done with such errors in case of complex code like SQL or HTML, where you likely need to use all of VFPs string delimiters single quote, double quote and square brackets within the string: Use TEXT..ENDTEXT

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: combine three records to one with a sql select()

(OP)
Olaf,
Thanks, indeed with

CODE --> vfp

Text...Endtext 
no problem it works.
Regards,
Koen

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close