Subject Re: [firebird-support] Syntax for replacing a record using using UPDATE in stored procedure
Author Helen Borrie
At 12:11 AM 26/02/2005 +0000, you wrote:

>Hi,
>I am trying to code the following stored procedure, and I need to allow
>it to have an input parameter for the UserId, and then get it to
>"replace" that record with the data that is passed to it.
>Is this close?

Nope.

First, you don't need to write a stored procedure for a perfectly
conventional update operation The DSQL statement for updating your user
record (assuming UserID is the primary key and Id is some other kind of
value) would be:

update "Users" /* quoted identifiers!! - Yuck! */
set
Id = ?,
DisplayName = ?,
Email = ?,
Extension = ?,
Deleted = ?
where UserID = ?

If your programming interface doesn't support replaceable parameters, it's
time to look for a programming interface that's not brain-dead.

Still, your executable SP would look something like this:

SET TERM ^;
CREATE PROCEDURE Replace_User (
UserId INTEGER,
Id INTEGER,
DisplayName VARCHAR(50),
Email VARCHAR(255),
Extension VARCHAR(100),
Deleted CHAR(1),
)
AS
BEGIN
update "Users"
set
"Id" = :Id,
"DisplayName" = :DisplayName,
"Email" = :Email,
"Extension" = :Extension,
"Deleted" = :Deleted
where UserId = :UserID;
END
^
SET TERM ;^

EXECUTE PROCEDURE Replace_User (99, 144, 'Joe Blow',
'jblow@...', 'Now is the time for all good men etc.', 'F')

./hb