在程序sybase中循环

时间:2013-11-01 10:30:28

标签: tsql sybase sybase-ase

在我们编写程序的oracle中,我们这样做:

  

COUNT_START:= LL_COUNT;
  何时LL_COUNT> 0 LOOP
       IF LL_COUNT> 20那天         COUNT_START:= 20;
          ELSE
       COUNT_START:= LL_COUNT;
       LL_COUNT:= 0;
      万一;

我正在sybase中编写一个过程:

  CREATE PROCEDURE P_RDS_EOD_ARCH_PURGE
  v_test numeric(10,0)

 AS

 BEGIN

 DECLARE @ID VARCHAR(200)
 DECLARE @NAME VARCHAR(200)
 DECLARE @TYPE VARCHAR(200)
 DECLARE @SQL_TXT VARCHAR(255)


 SELECT @ID   = '1' 
 SELECT @NAME = 'P_TEST'
 SELECT @TYPE = 'SELECT'

 SELECT @SQL_TXT ='RANDOM QUERY'

 EXECUTE @ID, @NAME , @TYPE, @SQL_TXT

执行查询后,我想做 LOOP 并分配值,如何在sybase中执行此操作

1 个答案:

答案 0 :(得分:2)

循环在TSQL中非常基础:

while boolean_expression 
  statement

如果您的语句超过1行,则可以将其括在begin / end语句中;

while aStatementIsTrue
begin 
   update myTable
   set myCol = "whatever"

   select someOtherThing
end

更多详细信息,请参阅Sybase T-SQL User's Guide