Add Boolean Field with Default True to LANSA File

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 687
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Add Boolean Field with Default True to LANSA File

Post by jyoung » Tue Jun 02, 2020 3:34 am

I have a LANSA built File that I am trying to add a Boolean field to with the default value of TRUE so that EVERY EXISTING RECORD in the File will be set to True.
IsEnabled.PNG
IsEnabled.PNG (12.51 KiB) Viewed 520 times
File.PNG
File.PNG (33 KiB) Viewed 520 times
However when I compile the Table with Rebuild / Drop and Load the Field is always (0) False.
Table.PNG
Table.PNG (7.43 KiB) Viewed 520 times
How do I make the IsEnabled Field default to True (1)?

I tried using 1 for the default value, but it changes to +1 and still default to 0.

Thanks,
Joe

atostaine
Posts: 526
Joined: Wed Jan 20, 2016 7:38 am

Re: Add Boolean Field with Default True to LANSA File

Post by atostaine » Wed Jun 03, 2020 1:34 am

I would bet that LANSA uses SQL or CPYF under the covers and does not go through the OAM. That means that you would have to set your own default for existing records.

Art
Art Tostaine

jyoung
Posts: 687
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Add Boolean Field with Default True to LANSA File

Post by jyoung » Wed Jun 03, 2020 2:59 am

That means setting the ASQN attribute which also means having to check for NULL or True for EVERY QUERY.

Ugh.

Was hoping to not have to do that, but it seems like the only way.

Thanks Art.

atostaine
Posts: 526
Joined: Wed Jan 20, 2016 7:38 am

Re: Add Boolean Field with Default True to LANSA File

Post by atostaine » Wed Jun 03, 2020 3:07 am

After you recreate the file why can't you fix the records? Are you doing this as part of a production job or development?

Can't you run an update file set isAdmin = true after?
Art Tostaine

jyoung
Posts: 687
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Add Boolean Field with Default True to LANSA File

Post by jyoung » Wed Jun 03, 2020 4:56 am

I can and will probably do that instead of trying to do some dynamic where clause.
The issue is that this is in production and we have automated deployments so we will kick this off at night when no one is on the system. At which point I will have to log in from home and run the update script.

Its more steps that would be completely unnecessary if it honored the default value like it should.

soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: Add Boolean Field with Default True to LANSA File

Post by soa » Wed Jun 03, 2020 2:52 pm

To me this is quite clearly a defect and should be reported as such.

Post Reply