Book a Demo

Author Topic: SQL Update on Notes with Carriage Returns  (Read 3809 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
SQL Update on Notes with Carriage Returns
« on: September 21, 2018, 12:53:21 am »
Hi,

I'm getting via  SQL query the t_connectortag.NOTES content that I need to copy to other records via a SQL update. I'm getting issues in the result as the Carriage Returns are not properly maintained.
I have a variable newNotes = node.selectSingleNode("./NOTES").Text that I use in
updateSQL = "update t_connectortag set notes = '"&newNotes&"' ....

Any idea on how to sort this out?

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SQL Update on Notes with Carriage Returns
« Reply #1 on: September 21, 2018, 06:09:04 am »
Just a guess: EA uses a proprietary format for notes. IIRC it's partially HTML. Try changing the CR to an &-format or try using the Repository.GetFieldFromFormat to convert the text first.

q.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: SQL Update on Notes with Carriage Returns
« Reply #2 on: September 21, 2018, 05:12:22 pm »
I found a way that works ok:

newNotes= Replace(newNotes,chr(13),VbCrLf)
newNotes= Replace(newNotes,chr(10),VbCrLf)


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: SQL Update on Notes with Carriage Returns
« Reply #3 on: September 21, 2018, 08:22:34 pm »
Now you have 2 new lines instead of one.

*NIX and M$DOS came up with 2 different ways to separate lines: CR (code 13) and LF (code 10) or LF and CR. I never remember which variant is used where, but still both insist on theirs being the only correct way. Now when exchanging files between both worlds you either need smart editors (the ones I use come up with a warning when opening an "unusual formatted" file) or you have to programmatically change it. So it should rather be something like
Code: [Select]
newNotes= Replace(newNotes,chr(10)+chr(13),VbCrLf)
(not used to VB but the + is meant as string concatenation)

q.

mehmeteraymuslu

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: SQL Update on Notes with Carriage Returns
« Reply #4 on: September 26, 2018, 12:30:35 am »
I have been adding quotation marks to desired info, they are working wonders. That is best solution I could find so far.   :)