|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to SET NULL as String when calling a Update Query |
« View previous topic :: View next topic » |
Author |
Message
|
apmohan |
Posted: Fri Mar 12, 2021 4:55 am Post subject: How to SET NULL as String when calling a Update Query |
|
|
Apprentice
Joined: 28 Dec 2012 Posts: 27
|
Hello All,
I am writing an ESQL Code to update the Database Table with the provided values,
Request (JSON)
{
"updateEntries": [
{
"seqNo": 9,
"Name": "ABC",
"Age": "25",
"Sex": "MALE",
"City": "XXX"
}
]
}
ESQL Code
Code: |
SET query = 'UPDATE Employee SET NAME = ISNULL('|| ''''||name|| '''' ||',NAME),AGE = ISNULL('|| ''''||age|| '''' ||',AGE),SEX = ISNULL('|| ''''||sex|| '''' ||',SEX) WHERE SEQNO ='||CAST(seqNo AS CHARACTER)||'';
PASSTHRU(query);
|
Issue is when Name is not sent, we need to pass the query as
Quote: |
UPDATE Employee SET NAME = ISNULL(NULL,NAME),AGE = ISNULL('39',AGE),SEX = ISNULL('FEMALE',SEX),CITY= ISNULL('YYY',CITY) WHERE SEQNO = 9; |
So that it wont override the existing value or else it will replace as NULL.
How to Pass NULL in ESQL as when i do COLEASE(name,NULL) doesnt work.
Please 
Last edited by apmohan on Fri Mar 12, 2021 7:06 am; edited 2 times in total |
|
Back to top |
|
 |
bruce2359 |
Posted: Fri Mar 12, 2021 6:21 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Do you mean null or ‘null’ ? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
apmohan |
Posted: Fri Mar 12, 2021 7:01 am Post subject: |
|
|
Apprentice
Joined: 28 Dec 2012 Posts: 27
|
bruce2359 wrote: |
Do you mean null or ‘null’ ? |
I mean NULL only I don't want as String'NULL' |
|
Back to top |
|
 |
bruce2359 |
Posted: Fri Mar 12, 2021 9:10 am Post subject: Re: How to SET NULL as String when calling a Update Query |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
apmohan wrote: |
... when i do COLEASE(name,NULL) doesnt work. |
What do you mean by doesn't work? Does it throw an error? Something else? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
apmohan |
Posted: Fri Mar 12, 2021 3:46 pm Post subject: Re: How to SET NULL as String when calling a Update Query |
|
|
Apprentice
Joined: 28 Dec 2012 Posts: 27
|
bruce2359 wrote: |
apmohan wrote: |
... when i do COLEASE(name,NULL) doesnt work. |
What do you mean by doesn't work? Does it throw an error? Something else? |
Sorry Bruce for not clarifying.. I getting an error that the Variable query is null due to which it is throwing exception.
And when I pass it as COLEASE(name,'NULL') it overwrites the existing value |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|