Discussion (17)3
Log in or sign up to continue
Class dc.a Extends %Persistent
{

Property As %String;

ClassMethod Test()
{
  &sql(truncate table dc.a)

  &sql(insert into dc.a(svalues('Hello'))
  ##class(%SQL.Statement).%ExecDirect(,"select * from dc.a").%Display()

  !
  &sql(update dc.set s=s||' world' where %ID=1)
  ##class(%SQL.Statement).%ExecDirect(,"select * from dc.a").%Display()
}

}

USER>##class(dc.a).Test()
ID      s
1       Hello
 
1 Rows(s) Affected
ID      s
1       Hello world
 
1 Rows(s) Affected

Can we see the error number and error text?

Hi Jude
Seems like, to append a string using an update query, use the concatenation operator "||". For example, if you have a column that holds "Hello" and you want to end up with "Hello World", you can write:

UPDATE your_table
SET your_column = your_column || ' world'
WHERE your_condition;

If you're working with pointer fields in InterSystems IRIS (like accessing a property, for example, "PAPER_PAPMI_DR.PAPMI_No") rather than using "->", be sure to use dot notation. So your updated query might look like:

UPDATE SQLUser.PA_Person
SET PAPER_REMARK = PAPER_REMARK || 'abc'
WHERE PAPER_PAPMI_DR.PAPMI_No = '1111'
  AND PAPER_ROWID = '2222'

This method efficiently appends the string to your existing data.

@Jude Mukkadayil in one of your posts here, you mentioned this error:

[SQLCODE: <-415>:<Fatal error occurred within the SQL filer>]

[%msg: <Error occurring during UPDATE in table 'SQLUser.PA_Person': $ZE=<LIST>%SQLUpdate+40^User.PAPerson.1>]

According to this documentation, that could be a runtime error in some trigger code. In your User.PA_Person class's ObjectScript, you probably have a trigger defined that is causing issues for you. If so, can you post the code for the trigger(s) in that class?