Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Format of Select statement inside Insert..??
Format of Select statement inside Insert..?? [message #33748] Sat, 10 September 2011 14:00 Go to next message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Hi,

I have two tables Master and Slave.
I should access value of KEY_1 generated in Master table in slave table.. How to achieve this..?
I tried with the statement
SQL & Insert(SLAVE) (KEY_1,'Select (KEY_1) .From(MASTER)');
and i got some junk value than the required ..
Is the above Statement correct..??

table1.sch:

TABLE_ ( MASTER )
INT_ ( KEY_1 ) PRIMARY_KEY AUTO_INCREMENT
STRING_ ( DATA, 20 ) PRIMARY_KEY
END_TABLE


TABLE_ ( SLAVE )
INT ( KEY_1 )
INT_ ( MKEY ) PRIMARY_KEY AUTO_INCREMENT
STRING_ ( TYPE, 40 )
END_TABLE
Re: Format of Select statement inside Insert..?? [message #33749 is a reply to message #33748] Sat, 10 September 2011 15:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
I hope this should work:

SQL & Insert(SLAVE) (KEY_1, Select (KEY_1) .From(MASTER).AsValue());
Re: Format of Select statement inside Insert..?? [message #33751 is a reply to message #33749] Sat, 10 September 2011 15:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Of course, it might not be doing what you expect...

I guess you cannot reliably get the last generated key with subsequent select (because some other client can generate another one).

Mirek

[Updated on: Sat, 10 September 2011 15:07]

Report message to a moderator

Re: Format of Select statement inside Insert..?? [message #33754 is a reply to message #33748] Sat, 10 September 2011 17:48 Go to previous message
Monty.mvh is currently offline  Monty.mvh
Messages: 31
Registered: July 2011
Location: Bangalore
Member
Thanks mirek...
I will try this..
Previous Topic: EditField and Sqlite...
Next Topic: console + sql + unicode or utf
Goto Forum:
  


Current Time: Sun Jun 16 07:47:30 CEST 2024

Total time taken to generate the page: 0.02070 seconds