Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Unable to invoke HSQLDB datetime default value.

    In the code below I am trying to store the current timestamp into a record when it is updated. I looked for an easier way without success.

    My ploy was to put a null value into the dynamicform field. This, I figured, would invoke the DEFAULT CURRENT_TIMESTAMP in the database. My reasoning was that this happened when I created a new record, both the CREATED and MODIFIED columns were set correctly. (The table DDL is below.)

    I tried putting just the word null into the Default Value for the MODIFIED field. This was interpreted as a string. I tried that because I saw somewhere that calling setValue(null) reverts a field to its default value.

    Is there a way I can get a real *null* value into the datetime field, just like a new record would have?

    Your expertise would be appreciated. I need to do this all over.

    FormItem.defaultValue [IRW] type:any, defaultValue: null

    Value used when no value is provided for this item. Note that whenever this item's value is cleared programmatically (for example via item.setValue(null)), it will be reverted to the defaultValue. Developers should use the DynamicForm.values object if their intention is to provide an initial value for a field in a form rather than a value to use in place of null.
    I bring your attention to the statement: LicenseDetailForm.getItem("MODIFIED").setValue(null);

    The context is below, near the end.

    Code:
    if (!window.LicenseDetailForm) {
    	var message = "Component ID \"LicenseDetailForm\", target of action \"Clear Values\" does not exist";
    	isc.Log.logWarn(message);
    	if (isc.designTime) { isc.say(message); }
    }
    var d = new Date();
    var dt = d.getTime();
    var dts = d.toUSShortDateTime();
    if (LicenseDetailForm.newLogEntry) {
    	if (LicenseDetailForm.newLogEntry != null) {
    		var logValue = LicenseDetailForm.getValue("DESC");
    		if (logValue == null) { 
    			LicenseDetailForm.setValue("DESC",(dts + ": " + LicenseDetailForm.newLogEntry + ".")); 
    		} else { 
    			LicenseDetailForm.setValue("DESC",(dts + ": " + LicenseDetailForm.newLogEntry + ".\n" + logValue)); 
    		}
    		LicenseDetailForm.newLogEntry = null;
            }
    }
    LicenseDetailForm.getItem("SaveButton").setDisabled(true);
    LicenseDetailForm.getItem("MODIFIED").setValue(null);
    LicenseDetailForm.saveData();
    LicenseDetailForm.changesPending = false;
    Code:
    CREATE TABLE License(
    		LicenseID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 101, INCREMENT BY 1),
    		LicenseName VARCHAR(16),
    		Enabled BOOLEAN DEFAULT TRUE,
    		StartDate DATE,
    		ExpireDate DATE,
    		LicenseType VARCHAR(16) NOT NULL,
    		EffectiveDays INT DEFAULT 0,
    		UserCount INT DEFAULT 0,
    		MaximumGB INT DEFAULT 0,
    		PrioritySupport BOOLEAN DEFAULT FALSE,
    		Renewable BOOLEAN DEFAULT TRUE,
    		MonthlyFee FLOAT NOT NULL,
    		QuarterlyFee FLOAT NOT NULL,
    		YearlyFee FLOAT NOT NULL,
    		Desc VARCHAR,
    		Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    		Modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    		
    	CONSTRAINT IDX_LicenseName UNIQUE (LicenseName)
    );
    Last edited by RickBollinger; 15 Jan 2012, 15:33.

    #2
    None of this is necessary, see DataSourceField.type - there are types you can just declare that automatically insert timestamps.

    Comment


      #3
      These creatorTimestamp and modiferTimestamp selections are not available in VB. I entered them into the DS on the appropriate fields and they were accepted when I dropped a field on the dynamicform with the correct name of the DS field.

      I was worried that I would have to recreate the whole dynamic form by dropping the DS on it to pick up the changes.

      Thanks.

      Comment


        #4
        Declaring creatorTimeStamp and modifierTimeStamp types seems to get the right values.

        The problem in the display fields is that they don't show as a datetime type. I only see the date portion.

        The good news is that I am building out the app with more tabs and forms. There is still a lot to learn.

        Thanks.

        Comment


          #5
          I corrected the creatorTimestamp and modifierTimestamp types in the datasource and I get the datetime values I want.

          Now I know the location of the Firefox spell checker dictionary. Somehow the 'S' in timestamp got capitalized.

          Worked like magic.

          Thanks.

          Comment

          Working...
          X