473,566 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to put in a multi-line string without quotes on each line?

sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.

Thanks!

Dean

Jun 3 '06 #1
5 15163

"dean" <de*********@ya hoo.com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.


No.

- Dennis
Jun 3 '06 #2
In article <1149348708.643 640.258530
@i39g2000cwa.go oglegroups.com> , de*********@yah oo.com
says...
sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.


I'm not sure it's any improvement in readability, but you
can do something like this:

sSQL = "\
update SELECTED_NODES \
set LABEL_S = 'Y' \
where NODE_I in \
( \
select NODE_I \
from \
( \
select ONODE_I NODE_I from link \
union all \
select DNODE_I NODE_I from link \
) all NODES \
group by NODE_I \
having count(*) > 2 \
)";

This can lead to problems though -- in particular,
inserting white-space between the back-slash and the new-
line can cause a bit of a problem.

My advice would be to read the query in from an external
file instead.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 3 '06 #3
dean wrote:
sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.

Thanks!

Dean


This topic may be compiler dependent, I don't know...

The best I could do without getting compile errors was:

const char * sqla =
"update SELECTED_NODES \
set LABEL_S = 'Y' \
where NODE_I in \
( \
select NODE_I \
from \
( \
select ONODE_I NODE_I from link \
union all \
select DNODE_I NODE_I from link \
) ALL_NODES \
group by NODE_I \
having count(*) > 2 \
)" ;

All the above example does is eliminate the leading quote on each
line, but you still must have the trailing backslash on every
line but the last. Also, the final string contains ALL of the blanks
that appear at the beginning of each line.

I'd stay with your original approach; it's easier to read and puts
fewer blanks in the string.

Larry
Jun 3 '06 #4
dean wrote:
sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.

Thanks!

Dean


Put it in a file and read it at run time.

Ben
Jun 4 '06 #5
dean wrote:
sSQL =
" update SELECTED_NODES "
" set LABEL_S = 'Y' "
" where NODE_I in "
" ( "
" select NODE_I "
" from "
" ( "
" select ONODE_I NODE_I from link "
" union all "
" select DNODE_I NODE_I from link "
" ) ALL_NODES "
" group by NODE_I "
" having count(*) > 2 "
" ) ";

Is there a super-quote I can add at the start of that statement, so I
don't need all the double quotes on each line? Something like /* and */
but for strings and not comments.


That pattern is called PerniciousIngro wnSql. You are asking how to make the
SQL easier to in-grow.

Instead, consider writing a simple system that generates SQL with streams,
like this:

stringstream q;
update(q, selectedNodesTa ble);
q << "set LABEL_S = 'Y'";
q << "where NODE_I in "
selectNode_I(q) ;

I pushed some of your strings into simple functions. As you write more SQL,
you will re-use these simple functions. If your program grows very complex,
that suite of simple functions will start to work as a "persistenc e layer".

But if you program does not grow complex (a good thing), then they won't.
They will just keep helping you write SQL statements that don't duplicate
all their contents everywhere.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 4 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
14564
by: OutsiderJustice | last post by:
Hi All, I can not find any information if PHP support multi-thread (Posix thread) or not at all, can someone give out some information? Is it supported? If yes, where's the info? If no, is it possible to make doing multi-thread stuff? Thanks. YF
37
4846
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours, Pujo
4
4642
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
0
4916
by: Ganbold | last post by:
Hi, I'm new to multi-threaded programming and reading the book "Programming with POSIX Threads" and trying to understand concepts and coding. What I'm trying to do is to rewrite mysql client application (which calculates ISP dial-up customers' billing) into multi-threaded version.
3
3114
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application there. There is performance degradation. The usual performance of the application on MP machine is better than that of uni processor machine....
6
4873
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on a table called COURSES. This table has 2 fields CATEGORY_ID, COURSE_NAME. The CATEGORY_ID is a FK in COURSES and a PK in CATEGORIES. I want...
3
3283
by: kathy | last post by:
I have a general question. If I write a application using any language(C/C++/C#/VB). How to make sure it only has one instance running? What I need to write in source code? If multi-instances run. Is any data confilct exsisted? Assuming I put the .exe in shared network drive and the multi-instances run on different PC. How about the...
0
2305
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing Systems (MuCoCoS'08) Barcelona, Spain, March 4 - 7, 2008; in conjunction with CISIS'08. <http://www.par.univie.ac.at/~pllana/mucocos08>...
14
3380
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its libraries are suitable for multi-threaded programming. For people who are fond of portable C programming, what's the best way to go about...
4
7320
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s vs. 0.3s for the single-dimensional array. (I know initializing is not necessary in this simple example,
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.