Search:
www.rocket99.com : Technical Guides Sybase Oracle UNIX Javascript


Technical Guides
Sybase
Oracle
UNIX
Javascript




After Work

Highlife Adventures
The best club in Chicago
for Chicago Singles is Highlife Adventures!


Jersey Girl Shirts
Are you looking for a
Jersey Girl T-Shirt ?



Kyoto Sushi
in Chicago, on Lincoln Ave.
Moody's Pub
in Chicago, has great burgers
Skylark
in Chicago, on Halsted .. excellent Friday fish fry!


Sybase » Transact-SQL » Coding »

Transact SQL: Conditionals

     




Conditional statements allow branching within stored procedures in a fashion
similar to other languages, like Visual Basic. The example below returns the
matching invoice if a non-zero value is passed to it, otherwise it raises an error.


create procedure proc_rtv_invoice (@inv_id numeric(8,0) as

if @inv_id > 0
select inv_id, inv_date, sales_rep_id
from invoice
where inv_id = @inv_id
else
raiserror 99999 'Error: invalid invoice #'

return
go


Another example, which illustrates the begin and end constructs


create procedure proc_rtv_invoice (@inv_id numeric(8,0)) as

declare @date datetime

if @inv_id > 0
begin
select @date = getdate()

select inv_id, inv_date, sales_rep_id,@date
from invoice
where inv_id = @inv_id
end
else
raiserror 99999 'Error: invalid invoice #'

return
go

Note how the variable @date was declared, and given a value.








Sybase : Related Topics

Sybase : Transact-SQL : Transact SQL: numeric functions
Sybase : Transact-SQL : Transact SQL: string functions
Sybase : Transact-SQL : Transact SQL: date/time functions
Sybase : Transact-SQL : Transact SQL: misc functions
Sybase : Transact-SQL : Transact SQL: looping constructs
Sybase : Transact-SQL : Transact SQL: Cursors
Sybase : Transact-SQL : Transact SQL: Complex Updates
Sybase : Transact-SQL : Transact SQL: Finding duplicate rows in a table
Sybase : Transact-SQL : Using Temporary Tables
Sybase : Transact-SQL : Inner/Outer Joins
Sybase : Transact-SQL : Isolation Levels
Sybase : Transact-SQL : Reporting: SQL Performance and Tuning
Sybase : Transact-SQL : Case Statement
Sybase : Transact-SQL : Date processing: stripping time from datetime
Sybase : Transact-SQL : Safely delete a large number of rows without blowing the t-log
Sybase : Transact-SQL : Transact SQL: date/time formats
Sybase : Transact-SQL : Creating a stored procedure
Sybase : Transact-SQL : Custom query plans
Sybase : Transact-SQL : Rowcount setting - limiting result sets
Sybase : Transact-SQL : Ranking Data - with Duplicates
Sybase : Transact-SQL : Forcing an index in a query
Sybase : Transact-SQL : Median Calculation, with pure SQL
Sybase : Transact-SQL : Lead and Lag with pure SQL

Sybase Web Site
Sybase Mobile Web Site
Oracle Web Site





Site Index About this Guide to Sybase, Oracle, and UNIX Contact Us Advertise on this site




Copyright © 2008 Citisoft Inc All Rights Reserved.