by Robert Huber » Sun Apr 09, 2006 7:14 pm
Hi Jan and Johann and all others
I have a very strange behaviour in Servoy 3 Beta 2: The following newRecord statement
// Create new waypoint record (to be filled with data from import, i. e. a record from table import_positions)
forms._waypoints.controller.newRecord();
gives this error: ASA Error -195: Column 'name' in table 'waypoints' cannot be NULL
As the error happens at the statement newRecord, of course there is still nothing in each attribute, these are filled in later in the method as seen below.
After a complete new installing of Servoy Beta 2 the error message just mentions another colum (name), on the original installing it gave the same error on another column!
Best regards, Robert
PS: This is my whole code, which used to work in previous versions:
/*
Title Insert all waypoint records from table import_positions into table waypoints
Authors Robert Huber
Version 0.1, 23.1.2006
Tables import_positions, waypoints
Files -
Debugging application.output();
Description
*/
// set dialog defaults
globals.countryCode = "-"; // - Select Country -
globals.stateId = 0; // - Select State -
globals.sourceId = 0; // - Select Source -
if ( controller.getMaxRecordIndex() > 0 )
{
var noOfRecords = controller.getMaxRecordIndex(); // returns the number of records for this foundset
// Ask for country and state of waypoints
application.showFormInDialog(forms.DialogAddToWaypoints,-1,-1,-1,-1,'Add to Wayppoints',false,false,false);
if ( dialogButtonPressed == 'add' )
{
databaseManager.startTransaction(); // transaction rollback point
for ( var i = 1 ; i <= noOfRecords ; i++ )
{
controller.setSelectedIndex(i);
if ( importrow.substring(0, 1) == '*' )
{
; // do nothing
}
else
{
// Create new waypoint record (to be filled with data from import, i. e. a record from table import_positions)
forms._waypoints.controller.newRecord();
// Split importrow into individual attributes
var attributesArray = importrow.split(',');
// Set columns in table waypoints
var waypointAttributes = attributesArray[4]; // assign waypoint attributes, e. g. AT
var waypointAttributesCheckBoxFormat;
if ( waypointAttributes.length > 1 )
{
waypointAttributesCheckBoxFormat = waypointAttributes.charAt(0) + '\n';
for ( var j = 1 ; j < waypointAttributes.length - 1 ; j++ )
{
waypointAttributesCheckBoxFormat += waypointAttributes.charAt(j) + '\n'; // add new line after each character to get checkbox format
}
waypointAttributesCheckBoxFormat += waypointAttributes.charAt(j); // no new line needed after last character
}
else
{
waypointAttributesCheckBoxFormat = waypointAttributes.charAt(0); // store attribute without a new line (at the end)
}
// Set attributes in table waypoints
forms._waypoints.attributes = waypointAttributesCheckBoxFormat;
forms._waypoints.elevation = attributesArray[3];
forms._waypoints.latitude = attributesArray[1];
forms._waypoints.longitude = attributesArray[2];
forms._waypoints.name = attributesArray[5];
forms._waypoints.remark = attributesArray[6];
forms._waypoints.state_id = globals.stateId;
forms._waypoints.source_id = globals.sourceId;
controller.saveData();
}
}
controller.saveData();
var success = databaseManager.commitTransaction();
if ( success )
{
plugins.dialogs.showInfoDialog('Add to Waypoints','Waypoints successfully to waypoints added!','OK');
}
else
{
plugins.dialogs.showErrorDialog('Add to Waypoints','No waypoints added! (Commit failed)','OK');
databaseManager.refreshRecordFromDatabase(foundset,-1);
}
}
else
{
// cancel pressed, do nothing
}
}
else
{
plugins.dialogs.showWarningDialog('Waypoints', 'No waypoints transfered!');
}