how to update values in database

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

how to update values in database

Postby mskv1309 » Tue Jun 12, 2012 10:49 pm

In my code I want to update values in database. What I need to do is, I am having two buttons event in two forms
a. In formA event is to create a new record and saved the information such as id, start time, so on.
b. In formB I need to add rest of information such as stop time, time difference between start and stop time.
In form B I am using plugins.rawSQL() to update existing data, but it throws error: TypeError: rawSQL is not a function, it is org.mozilla.javascript.NativeJavaObject.
Do I really need to use plugins.rawSQL() to update the record. Is there any other way where I can add form b data in existing record. Please suggest.
mskv1309
 
Posts: 41
Joined: Thu Apr 26, 2012 10:05 pm

Re: how to update values in database

Postby omar » Sun Jun 24, 2012 2:51 pm

I don't know what it is that you are trying to do exactly but normally you would create two forms based on the same table.

1. In formA to create a new record and fill some fields:

Code: Select all
foundset.newRecord();
foundset.fieldname1 = 'value1';
foundset.fieldname2 = 'value2';


2. In formB if it is based on the same table the same record will be the active one. If not lookup the correct record first. Then update the rest of the fields:

Code: Select all
foundset.fieldname3 = 'value3';
foundset.fieldname4 = 'value4';


You don't have to use the rawSQL plugin for that. The record will be save automatically if all the required fields are filled. Of course if you want to explicitly save the record you can do that as well.

Omar
Intrasoft, Founder
Omar van Galen
omar@intrasoft.nl
+31-(0)6-21234586
Servoy Developer
omar
 
Posts: 377
Joined: Sat Feb 12, 2011 4:51 pm
Location: Intrasoft, The Netherlands

Re: how to update values in database

Postby hardina09 » Mon Jun 25, 2012 10:43 pm

Thanks both of you. Good info
hardina09
 
Posts: 62
Joined: Tue Apr 24, 2012 9:46 pm


Return to How To

Who is online

Users browsing this forum: No registered users and 7 guests

cron