Sybase Process Control

Source: Internet
Author: User
Tags sybase

1. Variable Declaration and assignment

Global variables are predefined by the system and begin with the symbol @@ 打头

A local variable declaration uses the Declare statement, which must begin with a symbol @ followed by an identifier.

Declare @ variable name data type [, @ variable name data type, ...]

Variable assignment using the SELECT statement, the value of the unassigned variable is null.

Example:

Declare @msg Char (50)

Select @msg = ' How are '

Select @msg =emp_name from employee

Where emp_id=12345678

2. SQL statement block

Begin

Statement block/* SQL statements executed in multiple sequential order * *

End

3. Conditional statement

An If condition expression

Statement (block)

Else

Statement (block)

Example:

if (select Max (id) from sysobjects) <50

No user-created object in print ' Database

Else

Select Name,type,id from sysobjects where id>50

4. Loop statement

While condition expression

Statement (block)

Two special circular control statements:

Continue Execute Next loop

Break Exit Current Loop

Example:

while (select Avg. (price) from titles) >$20

Begin

Update titles Set PRICE=PRICE/2

If (select AVG (price) from titles) <$40

Break

Else

Continue

End

5. Other control statements

◇return Statement--an unconditional end to the current procedure and a State value that can be returned to the caller: return[integer expression]

◇print statement

◇raiseerror statement

◇waitfor statement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.