Reputation: 7377
In oracle when we write a procedure we do it like this :
COUNT_START:= LL_COUNT;
WHILE LL_COUNT > 0 LOOP
IF LL_COUNT > 20 THEN
COUNT_START := 20;
ELSE
COUNT_START := LL_COUNT;
LL_COUNT := 0;
END IF;
I am writing a procedure in 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
After I execute my query I want to do a LOOP and to assign values, how to do that in sybase
Upvotes: 1
Views: 6003
Reputation: 6651
Loops are pretty basic in TSQL:
while boolean_expression
statement
If your statement is more than 1 line, then you can enclose it in begin/end statements;
while aStatementIsTrue
begin
update myTable
set myCol = "whatever"
select someOtherThing
end
More details can be found in the Sybase T-SQL User's Guide.
Upvotes: 2