Subject Re: setting default value of fields
From Mustansir Ghor <mustan31@hotmail.com>
Date Sun, 07 Jul 2024 04:49:44 -0400
Newsgroups dbase.getting-started

Dear Mervyn Sir, Ken Sir and Heintz

Thank You all for you solutions but in my case I can not use it.

The creation of table has 31 columns (days on month). I am using updateset object  AppendUpdate method to either update or append records. The problem arises when the newly append records for a particular day are done. For these newly added records the other days fields gets null value. Hence for a particular record, to use its fields for calculations becomes difficult.

Best Regards
Mustansir



Mervyn Bick Wrote:

> On 2024/07/06 10:51, Mustansir A Ghor wrote:
> > Dear All
> >
> > Hope all are good.
> >
> > I need to set default value of fields for a new created table programitically, If I use command below, it executes but when I open the same (mODI STRUC) and see the defaulf fields values still shows null.
> >
> > CREATE TABLE XYZ (code char(6) default "", qty numeric(6) default 0)
> >
> > Can anybody enligthen, if we can set default fields values programatically.
> >
> > Best Regards
> > Mustansir
>
> Unfortunately CREATE TABLE is a localSQL command and, unlike "proper"
> SQL, it doesn't support the DEFAULT option for fields.
>
> It should be possible to use functions from the BDE API (which is what
> the table designer in the IDE does behind the scenes) to create a table
> and set default values for fields but digging into the BDE API is not
> for the fainthearted.
>
> As an alternative you can use the rowset's onSave() event handler to
> force values into empty fields.
>
>     function rowset_onSave()
>          if empty(this.fields['code'].value)
>           this.fields['code'].value := " "
>        endif
>         if empty(this.fields['qty'].value)
>            this.fields['qty'].value := 0
>         endif
>        return
>
> Mervyn.
>



Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0