how to insert null instead of 0 for integer data type?

Hi all,

Im using scriptcase v8 and oracle as database. When creating a form, i will have items withe integer data type via front end (number in oracle back end). but there are occasions where i don’t need this field to be filled yet. i would just like to submit the form and make the field null.

Currently, every time i leave the item and do not key anything, it will automatically insert value 0. How can i just leave it null and do not enter any value? there must be setting anywhere.

Thanks :smiley:

You need to tell the database field in the RDBMS itself (via Database Builder or some other tool) to allow NULL for that field.

null is allowed. my db can accept null…problem is scriptcase keeps inserting value 0 for any integer fields if it is not filled or hidden. i just want to keep it null instead of it inserting 0 value.

General Setting for the field:
Scroll down to Database Value and set Insert and Update to Null.

If you want to do it by yourself: onBeforeInsert/onBeforeUpdate

if(empty({your_int_field}))
{
{your_int_field} = ‘Null’;
}

jsb

I had same problem with SC, i created a trigger in table on before insert i valide if is zero then asign value null.

Is this still the best method to resolve this issue? I too have INT field type in a MySQL db that I have set to allow NULL, but script case wants to put 0 in the field. If I created this trigger that set 0 to NULL then I could never actually have a value of 0, which I want to allow. I need to set NULL what it is… a field that has not been assigned a value yet should be NULL. Other than changing the INT to a VARCHAR in MySQL is there another way to resolve this?

Thanks for any suggestions!

The problem of NULL has existed for a very long time on the choice and the way to approach it, I chose for a very long time to privilege a field of type varchar and to assign it the value ‘-’, so we can always analyze the fields both int and var, the interesting thing about this option is that we eliminate all the polemics of NULL, anyway the analyzed field is not necessarily the fields that we will display in a report, if not that to differentiate it we go through a trim of the field to isolate any space that would distort the return of requests, and yet my applications are used in the school environment and provide newsletters, evaluations, statistics based on this kind of constraint, good luck in the domain of NULL,