Default value in existing schema | Community
Skip to main content
Level 3
Dec 26, 2018 7:30 AM UTC
Solved

Default value in existing schema

Hi,

For example, I have an existing schema with 10 data in it. one of the attribute is "rank"

<attribute label="rank" name="rank" type="long"/>

Now i want to assign default value for rank as "3" where there is no value in it. (means rank as "3" for existing values where rank is null or 0 and rank as 3 for future updating data where rank will be blank)

So if i make change as  <attribute label="rank" name="rank" type="long" sqlDefault="3"/> , all the existing values became "3". But i need null or 0 values to become 3.

so what should i need to do?

Thanks in advance,

ParthaSarathy.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Adhiyan
AdhiyanAccepted solution
Employee
Jan 2, 2019 1:54 PM UTC

Hi Partha,

You need to switch on SQL injection from the serverconf.xml file by making the allowSQLInjection attribute to true.

There should be a section like below in the security zone where you can add the parameter in Red.

<securityZone allowDebug="false" allowHTTP="false" allowSQLInjection="true" label="Public Network"

                name="public">

Regards,

Adhiyan

3 replies

Adhiyan
AdhiyanAccepted solution
Employee
Jan 2, 2019 1:54 PM UTC

Hi Partha,

You need to switch on SQL injection from the serverconf.xml file by making the allowSQLInjection attribute to true.

There should be a section like below in the security zone where you can add the parameter in Red.

<securityZone allowDebug="false" allowHTTP="false" allowSQLInjection="true" label="Public Network"

                name="public">

Regards,

Adhiyan

Translate
Partha18Author
Level 3
Dec 27, 2018 5:54 AM UTC

i am getting this error when i tried to update database structure..

Translate
Adhiyan
Employee
Dec 26, 2018 5:12 PM UTC

Hi Partha,

I think you can use SQL calculated fields here . Something like:

<attribute expr="[SQLDATA[case when iRank = 0 THEN '3' when iRank is NULL THEN '3' ELSE 'Specified'

END]]" label="rank" name="rank" type="long"/>

Or you can delete the existing data and and reload the schema with the updated condition for sqlDefault=3 , then while uploading all the values which are not specified (like 0 or Null ) will be 3.

Regards,
Adhiyan

Translate