Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pretext in Select-Sql

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

What is the usage of the below mentioned highlighted, I checked in Help but could'nt got properly.

TEXT TO lcSQL NOSHOW PRETEXT 12
SELECT DISTINCT location FROM SrMast WHERE pcode = mpcode AND salesman = msalesman INTO CURSOR tLocation ORDER BY location nofilter
ENDTEXT

Thanks

Saif
 
The NOSHOW means that the text won't be displayed on the background screen. This is what you want. NOSHOW should always be present with TEXT / ENDTEXT.

PRETEXT 12 means that any blank lines or extra line feeds in the text will be ignored. There's no reason to have this in the code you have shown. In general, you should leave out PRETEXT in these cases.

Despite the title of your thread, these settings have got nothing to do with SQL. They are related to the TEXT / ENDTEXT construct. It just happens you are using that construct to store a SQL command.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
NOSHOW is self explanatorys, if you remove it. You will get text written on screen, you won't want that.
PRETEXT can be used in two ways, the simpler case, not used here, is simply a string prefixed before every line, eg ">" would casue > to appear before each line.

The numeric value and it's meaning is given in the help:

Value (Additive), Description
1, Eliminate spaces before each line.
2, Eliminate tabs before each line.
4, Eliminate carriage returns, for example, blank lines, before each line.
8, Eliminate line feeds.

So 12 is combining 8 and 4. In this case this makes no difference, but in case you'd make use of another clause, namely TEXTMERGE, further text could be merged into the text, eg try:

Code:
lcText = "Hello,"+chr(13)+chr(10)+"World!"
TEXT TO lcResult NOSHOW TEXTMERGE PRETEXT 12
<<lcText>>
ENDTEXT
? lcText
? lcResult

The real benefit of TEXT ENDTEXT is, if you have multiline texts in combination with parts of the text being such textmerge expressions <<expression>>, which then are substituted with their result at runtime.

The benefit of PRETEXT 12 is, you may write an SQL Statement in multiple lines, readable, but the textmerge removes any linefeeds and wht later executes is shorter a few bytes, this way. It's not a very important thing, but it helps you write statements without using line continuation semicolons and so you won't forget them.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top