Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SELECT and UPDATE
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SELECT and UPDATE

 Post Reply Post Reply
Author
the boss View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 January 2003
Location: Saudi Arabia
Status: Offline
Points: 1727
Post Options Post Options   Thanks (0) Thanks(0)   Quote the boss Quote  Post ReplyReply Direct Link To This Post Topic: SELECT and UPDATE
    Posted: 12 July 2003 at 4:19pm

can i use select and update commands in a single stored procedure.. if yes.. what is the appropiate code


Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2003 at 4:59pm
yes, you can
the syntax is the same as the usage in ASP
You can use them and any other SQL statement in a stored procedure.

selects will return a recordset in the order in which the select statements appear in the stored procedure.
Back to Top
stef_nz View Drop Down
Newbie
Newbie


Joined: 15 July 2003
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote stef_nz Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2003 at 2:38am
here is some example code from a stored proc using both select and update - ms sql server styles......

Quote create procedure dbo.UserLogin
@Username nvarchar(100),
@Password nvarchar(50),
@PID int
as
declare @UserId int
declare @SuperUserId int
select @SuperUserId = UserId
from   Users
where  IsSuperUser = 1
select @UserId = null
/* validate the user */
select @UserId = UserId
from   Users
where  Username = @Username
and    Password = @Password
if @UserId is not null
begin
  if @UserId <> @SuperUserId
  begin
    select @UserId = null
 
    select @UserId = Users.UserId
    from   UserPs
    inner join Users on UserPs.UserId = Users.UserId
    where  PID = @PID
    and    Username = @Username
    and    Password = @Password
    and    Authorized = 1
    if not @UserId is null
    begin
      update UserPs
      set    LastLoginDate = getdate()
      where  UserId = @UserId
      and    PID = @PID
    end
  end
end
select 'UserId' = @UserId

GO

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.