Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

SQL insert newline / linefeed

EcoStruxure Geo SCADA Expert Forum

Schneider Electric support forum about installation, configuration, integration and troubleshooting of EcoStruxure Geo SCADA Expert (ClearSCADA, ViewX, WebX).

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 
  • Home
  • Schneider Electric Community
  • Remote Operations
  • EcoStruxure Geo SCADA Expert Forum
  • SQL insert newline / linefeed
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
sbeadle
Kirk sbeadle Kirk
307
AndrewScott
Admiral AndrewScott
95
BevanWeiss
Spock BevanWeiss
89
AdamWoodlandToo
Lt. Commander AdamWoodlandToo
36
View All
Related Products
product field
Schneider Electric
EcoStruxureโ„ข Geo SCADA Expert

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to EcoStruxure Geo SCADA Expert Forum
Solved
BevanWeiss
Spock BevanWeiss
Spock

Posted: โ€Ž2020-03-03 04:56 PM . Last Modified: โ€Ž2023-05-03 12:16 AM

0 Likes
5
7009
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-03 04:56 PM . Last Modified: โ€Ž2023-05-03 12:16 AM

SQL insert newline / linefeed

Ok, I can't believe I couldn't just find the answer to this.

 

I'm trying to add a new line in an SQL string, and getting complaints from the QP about the brackets when trying to use CHR(10).

 

So far the things I've tried...

CHR(10), CHAR(10), ASCII(10), $L, $0A, \n

 

The help really wasn't much help on this.

 

It's such a simple thing, and I'm sure I've done it before without much problem.

I don't think it's a bug, but for the record it's ClearSCADA 2017 May 2018 update.

 

Help please ๐Ÿ™‚


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Labels
  • Labels:
  • SCADA
  • Tags:
  • sql
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
sbeadle
Kirk sbeadle Kirk
Kirk

Posted: โ€Ž2020-03-04 01:44 AM

In response to Anonymous user
0 Likes
1
6981
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-04 01:44 AM

There's no way in the SQL syntax to insert a new line as a literal.

 

The \n sequence in a column name is one of the special trips in column names to alter the appearance in lists - in this case a multi-row column header. (See help  Core Reference > Coding > SQL Guide > SELECT Clause)

 

Others are the ~ prefix (fix column in view), _ prefix (hide column) and > prefix (right-justify column content).

 

Also, there's a way to change the colour of a value according to an RGB value expression (See help  Core Reference > Lists > Custom Lists > Lists in Which only the Entries in Particular Columns Change Color).

 

I said there's no way, but there always is!

You can create a data table with a row and column containing a \n using a script, then join to that table in queries to output a new line where needed. While ViewX will display a '.' for it, the SQL Export driver will write that new line in.

Sample c# code:

using ClearScada.Client;
// etc etc, and put user and pass into strings
var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);
ClearScada.Client.Simple.Connection connection = new ClearScada.Client.Simple.Connection("Utility");
connection.Connect(node);
using (var spassword = new System.Security.SecureString())
{
  foreach (var c in pass) { spassword.AppendChar(c); }
  connection.LogOn(user, spassword);
}
ClearScada.Client.Simple.DBObject NewlineTable = connection.GetObject("Test General.Newline");
Object[] p1 = new Object[0];
int record = (int)NewlineTable.InvokeMethod("AddRecord", p1);
Object[] p2 = new Object[3];
p2[0] = "String";
p2[1] = record;
p2[2] = "\n";
NewlineTable.InvokeMethod("SetValue", p2);

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 5
AdamWoodland
AdamWoodland Schneider Alumni (Retired)
Schneider Alumni (Retired)

Posted: โ€Ž2020-03-03 11:18 PM . Last Modified: โ€Ž2020-03-03 11:27 PM

0 Likes
4
6997
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-03 11:18 PM . Last Modified: โ€Ž2020-03-03 11:27 PM

\n works in the column header, not the content, e.g.

 

SELECT
'Hello' || '\n' || 'Bevan'
FROM
CROOTGROUP

 

Can't work it out either, pretty sure you used to be able to do something. $n is for logic (and tooltips apparently)

Reply

Link copied. Please paste this link to share this article on your social media post.

BevanWeiss
Spock BevanWeiss
Spock

Posted: โ€Ž2020-03-03 11:40 PM

In response to AdamWoodland
0 Likes
3
6991
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-03 11:40 PM

I'm somewhat glad that puts two of us in the same boat as not quite knowing the solution (right now).

I really feel this would have been an issue sooner if it just wasn't possible though.  Like I really recall having done this several times before, and that like CHR(10) 'just worked'... but it clearly doesn't (at least not for me anymore).

 

Interesting that '\n' works in the column header.  I would have hoped it was consistent within the Query Processor on the whole.  But I guess not.

 

@sbeadle  / @Anonymous user  help please ๐Ÿ™‚


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Reply

Link copied. Please paste this link to share this article on your social media post.

Anonymous user
Not applicable

Posted: โ€Ž2020-03-03 11:54 PM

In response to BevanWeiss
0 Likes
2
6987
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-03 11:54 PM

CHR(10) is supported in expressions, so that might be what you're remembering.

 

I don't think there is a way to do what you're after but will defer to Steve.

Reply

Link copied. Please paste this link to share this article on your social media post.

sbeadle
Kirk sbeadle Kirk
Kirk

Posted: โ€Ž2020-03-04 01:44 AM

In response to Anonymous user
0 Likes
1
6982
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-04 01:44 AM

There's no way in the SQL syntax to insert a new line as a literal.

 

The \n sequence in a column name is one of the special trips in column names to alter the appearance in lists - in this case a multi-row column header. (See help  Core Reference > Coding > SQL Guide > SELECT Clause)

 

Others are the ~ prefix (fix column in view), _ prefix (hide column) and > prefix (right-justify column content).

 

Also, there's a way to change the colour of a value according to an RGB value expression (See help  Core Reference > Lists > Custom Lists > Lists in Which only the Entries in Particular Columns Change Color).

 

I said there's no way, but there always is!

You can create a data table with a row and column containing a \n using a script, then join to that table in queries to output a new line where needed. While ViewX will display a '.' for it, the SQL Export driver will write that new line in.

Sample c# code:

using ClearScada.Client;
// etc etc, and put user and pass into strings
var node = new ClearScada.Client.ServerNode(ClearScada.Client.ConnectionType.Standard, "127.0.0.1", 5481);
ClearScada.Client.Simple.Connection connection = new ClearScada.Client.Simple.Connection("Utility");
connection.Connect(node);
using (var spassword = new System.Security.SecureString())
{
  foreach (var c in pass) { spassword.AppendChar(c); }
  connection.LogOn(user, spassword);
}
ClearScada.Client.Simple.DBObject NewlineTable = connection.GetObject("Test General.Newline");
Object[] p1 = new Object[0];
int record = (int)NewlineTable.InvokeMethod("AddRecord", p1);
Object[] p2 = new Object[3];
p2[0] = "String";
p2[1] = record;
p2[2] = "\n";
NewlineTable.InvokeMethod("SetValue", p2);
Reply

Link copied. Please paste this link to share this article on your social media post.

BevanWeiss
Spock BevanWeiss
Spock

Posted: โ€Ž2020-03-04 02:08 AM

In response to sbeadle
0 Likes
0
6978
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: โ€Ž2020-03-04 02:08 AM

Thanks Steve,

I like the effort with the workaround, but I really don't like the workaround still.

I've just sent off an email to Tech Support to raise an enhancement for it.  I think it would make sense to have the CHR() function available, likely also the ASCII() function.  Although I only care about the CHR() right now, so that's all I had in my request.

 

I was almost going to suggest, perhaps updating to a more recent 'syntax' of SQL, like ANSI SQL:2011... but I've just had a quite peruse of the standard docs for the updated versions.  They're horrible.  So I think extensions to ANSI-92 is the most sensible way.

 

For examples of why I consider it horrible (for ClearSCADA use anyway)...

CONSTRUCT
INSERT <pattern> // add new vertices and edges
MERGE <pattern> // add existing and deduplicate elements
MERGE GRAPH <graph> // add all elements from <graph>
DELETE <elements> // delete elements
DETACH DELETE <elements> // delete vertices with their edges
...
RETURN [COPY OF] GRAPH // return projected graph

 

 

FROM friends
MATCH (a:Person)-[:TRAVELLED_TOGETHER]-(b:Person)
WHERE a.age = b.age
AND a.country = $country
AND b.country = $country
FROM census($country)
MATCH SHORTEST (a)-[:BORN_IN|MOVED_TO*]->(p)<-[:BORN_IN|MOVED_TO*]-(b)
MATCH (p)-[:LOCATED_IN]->(c:City)
RETURN a.age AS age, c.name AS city, count(*) AS pairs GROUP BY age

 I think it starts to get a bit meta for typical SCADA works..


Lead Control Systems Engineer for Alliance Automation (VIC).
All opinions are my own and do not represent the opinions or policies of my employer, or of my cat..
Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

ย 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings ยฉ 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of