Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Procedures - Creating

Author  Topic 

dlmagers10
Starting Member

48 Posts

Posted - 2010-11-30 : 00:49:39

I am trying to write a stored procedure in PL/SQL or T-SQL that will change the price of a part with a given part_num.

I am thinking (but not sure of myself)

create procedure usp_chg_price
@price decimal(6,2),
@partnum char(3)
as
update part
set price = @price
where part_num = @partnum;

To execute it would be this.

exec usp_chg_price '2695','AT94'

By any chance does this look right to you the viewer?

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-11-30 : 03:03:55
I feel it is correct.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-30 : 03:13:07
Have you tested it out (on a dev/test database)? Does it do what you expected?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

dlmagers10
Starting Member

48 Posts

Posted - 2010-11-30 : 10:22:26
Yes it worked but when I run the execution

exec usp_chg_price '2695','AT94'


it tells me that there are 0 rows affected.
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-11-30 : 11:32:36
--Are you getting any records for below select statement ?
Select * from part where part_num = 'AT94'

Make sure that you are looking into correct database because I have seen many times when people are looking into wrong database.
Go to Top of Page
   

- Advertisement -