How to insert a select row in another table?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

How to insert a select row in another table?

Postby cuoredisardegna@tiscali.i » Sat Apr 17, 2004 5:30 pm

Could someone help me?

I. After a search i see in a form called "clients" a number of rows: each one for one different client.

II. At this point i would select one of this rows and insert it in another field called "myclient" of another form called sales?.

III. Is it possible? If yes, how to do?

Tanks in advance

Gianni Pinna.
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby IT2Be » Sat Apr 17, 2004 8:23 pm

Sure this is possible, you would have to write a method to:

- create a new record in the other table;
- copy the fields you want to be copied into the new table;

That's all...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Jan Aleman » Sat Apr 17, 2004 9:13 pm

Do you just want to copy the client ID or an entire row? Are you having two table that have the same columns? If yes than you might want to have a close look at your database model first.

You can create new rows on another form very easily. In the method on that form navigate to the form you want to create the record on click on it's controller object and doubleclick the newRecord item. Once you have that you can start setting data by doubleclicking the dataproviders on the desitination form typing = then clicking the dataproviders you want assigned to them on your original form.
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

How to insert a select row in another table?

Postby cuoredisardegna@tiscali.i » Sun Apr 18, 2004 8:09 am

Dear Mr. Jan Aleman,

many tanks for your prompt replay and luminous distinction.
The matter is as later on. It is ordered according to form later on:

Form.clients
-Table.clients
-fields: -clientsID
-name
-address
-phone
-etc...

Form.sales
-Table.sales
-fields: -number
-date
-client_name |
-client_ID > I am interested to put in a row of sales
-client_address | only 3 fields of 1 row clients.
-item
-etc...


The origin of problem was this: that an operator wich is working on the Form.sales, when he arrives to client have the possibility of made 2 quickly:
1. To choose one of clients whose name starts vith “string%” [ The Forum helped me in this];
2. Insert with a click in the form.sales and in the table.sales, not all the choosed row of clients, but only 3 (some) filelds of clients..
Please Mr. Aleman, i am beginning with Servoy and Jscript and my knowledge is rudimentary. Kyndly could you write code?
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari

Postby Jan Aleman » Sun Apr 18, 2004 11:20 am

Create a method on the form clients that looks like this:

forms.sales.controller.newRecord()
forms.sales.clientID = clientID
//repeat the line above for each column you want to move
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Post subject: How to insert a select row in another table?

Postby cuoredisardegna@tiscali.i » Sun Apr 18, 2004 12:38 pm

Dear Mr Aleman,

i hope You'l find replay for any problem of Your life as soon as You kindly answered me. I will test immediatly.

Happy Sunday
Best regards
Gianni Pinna
cuoredisardegna@tiscali.i
 
Posts: 151
Joined: Sun Feb 29, 2004 10:35 pm
Location: Sassari


Return to Programming with Servoy

Who is online

Users browsing this forum: Google [Bot] and 17 guests