Ok. I'm not *entirely* sure what you're asking for. Let me restate your request, just to make sure.
You want to update a record in micros.dev_def where the obj_num = 100. Just to make sure, this is the *only* field you are selecting against - in other words, and record with obj_num = 100 will be updated in the same way, and no other records will be updated.
You want to update this table so that the lan_node_seq is equal to the lan_node_seq from micros.lan_node_def where ip_addr = 192.168.100.100
If the above description is correct, *and* there is a unique constraing on micros.lan_node_def.ip_addr, *then* the following should work:
<code>
UPDATE micros.dev_def
SET lan_node_seq = (SELECT lan_node_seq FROM micros.lan_node_def WHERE ip_addr = '192.168.100.100')
WHERE obj_num = 100
</code>
That should work, barring typos. However, if the SELECT part of the query returns more than one row, or no rows, you are screwed. :-)
Another (and probably better) way to do it is programatically, where you would run the 'SELECT' part of the query, and see what you get.
If you get exactly one, then run an UPDATE query, replacing the (SELECT ...) part with a bind var (?), and you're done.
If you get 0 or more than one, the application should return an error of some sort.
This is the way I would do it, unless I was absolutely certain that I would get back exactly one result from the SELECT.
|