| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

01-10-12, 07:51
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 13
|
|
|
Update Store Procedure
|
|
Hi
The current update store procedure that I have updates a list of input provided, but it there are fields that are left blank, they are being updated as null in the database.
I'm having a trouble creating a store procedure that will just update the provided fields only.
Please Help
Thanks
|
|

01-10-12, 08:40
|
|
Lost Boy
|
|
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
|
|
If the procedure doesn't work what you want, it is probably because you wrote it incorrectly. As you didn't provide code, tables, data, etc., it is difficult to guess what might be wrong. A blind guess: WHERE clause is a culprit.
|
|

01-10-12, 08:44
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 546
|
|
|
|
Quote:
Originally Posted by stahorse1
I'm having a trouble creating a store procedure that will just update the provided fields only.
|
Have you considered using proper WHERE clause to UPDATE only rows with "the provided fields only"?
|
|

01-10-12, 09:50
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 13
|
|
I have lot of fields, that might be updated on the run time. Now I'm struggling with a query for that, run time update.
My current update would look like this:
create or replace PROCEDURE SP_UPD_EXCEPTION_LOG
(
p_ExceptionID IN INTEGER,
p_DateTimeStamp IN DATE,
p_Code IN VARCHAR2,
p_Description IN VARCHAR2,
p_Information IN VARCHAR2,
p_ApplicationID IN INTEGER,
p_rowID OUT NUMBER
)
AS
BEGIN
UPDATE "ExceptionsLog"
SET
"DateTimeStamp" = SYSDATE,
"Code" = p_Code,
"Description" = p_Description,
"Information" = p_Information,
"ApplicationID" = p_ApplicationID
WHERE "ExceptionID" = p_ExceptionID;
END SP_UPD_EXCEPTION_LOG;
but now if a user might update only two fields from that code, others are updated as null.
|
|

01-10-12, 10:02
|
|
Registered User
|
|
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
|
|
>but now if a user might update only two fields from that code, others are updated as null.
so you need to modify the procedure to do as you desire.
try using IF ... THEN
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
|
|

01-10-12, 11:35
|
|
Lead Application Develope
|
|
Join Date: Jun 2004
Location: Liverpool, NY USA
Posts: 2,222
|
|
Code:
create or replace PROCEDURE SP_UPD_EXCEPTION_LOG
(
p_ExceptionID IN INTEGER,
p_DateTimeStamp IN DATE,
p_Code IN VARCHAR2,
p_Description IN VARCHAR2,
p_Information IN VARCHAR2,
p_ApplicationID IN INTEGER,
p_rowID OUT NUMBER
)
AS
BEGIN
UPDATE "ExceptionsLog"
SET
"DateTimeStamp" = SYSDATE,
"Code" = nvl(p_Code,"Code"),
"Description" = nvl(p_Description,"Description"),
"Information" = nvl(p_Information,"Information"),
"ApplicationID" = nvl(p_ApplicationID,"ApplicationID")
WHERE "ExceptionID" = p_ExceptionID;
END SP_UPD_EXCEPTION_LOG;
__________________
Bill
You do not need a parachute to skydive. You only need a parachute to skydive twice.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|