edit [message #305172] |
Sun, 09 March 2008 23:34 |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
in forms i retrieving data using select statement.particular record displayed.I want to changes the data.Then i used
update command.the record is updated simaltaneously same record inserted.plz send the solution plz(coding).very urgent
|
|
|
Re: edit [message #305232 is a reply to message #305172] |
Mon, 10 March 2008 03:42 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
varosh81 | i used update command.
|
Did you try to use UPDATE_RECORD built-in instead?
[EDIT, after realizing I was talking nonsense]
It seems that this is a DATA block (not a CONTROL block) you are selecting this record into. If so, why do you use a SELECT statement to fetch a record? Why don't you do that by a simple EXECUTE QUERY?
Because, the way you do it, SELECT creates a "new" record whose items' values you change and, after committing changes, a new - updated - record is saved into the database. The original one remains as it was (i.e. you got it wrong - you didn't simultaneously save the same record. Actually, there was nothing simultaneous at all - insert only (i.e. NO update!)).
[Updated on: Mon, 10 March 2008 03:48] Report message to a moderator
|
|
|
Re: edit [message #305253 is a reply to message #305172] |
Mon, 10 March 2008 04:24 |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
HOW TO USE UPDATE_RECORD?
i TRIED THE ABOVE QUERY BUT
FOLLOWING ERROR DISPLAYED
ERROR(UPDATE_RECORD)VALID ONLY ON_UPDATE TRIGGER
WHAT I DO SIR
WHERE I DECLARE ON_UPDATE TRIGGER?HOW TO CALL THAT TRIGGER
RAISE WHEN BUTTON PRESSED ?
|
|
|
Re: edit [message #305323 is a reply to message #305253] |
Mon, 10 March 2008 07:41 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
As I've already said: I was talking nonsense (i.e. disregard UPDATE_RECORD). Didn't want to delete it (perhaps someone had already seen it and, possibly, replied to it).
What I meant to say was: if you can, get rid of populating a block with a SELECT statement - use built-in Forms functionality called execute query to fetch records.
If you want to use SELECT, don't do that into a database block. Make it a control block instead (i.e. it doesn't have a table underneath). You'll then have to write an UPDATE statement in order to update the desired record in a table (make sure you don't change primary key values! It is a bad habit!) and take care that you'll update really and only the desired record. INSERT will be easier (relatively) - you'll still have to code it, as well as DELETE.
I'd strongly suggest you to return to option 1 - database block.
|
|
|