Sort by

recency

|

1182 Discussions

|

  • + 0 comments

    SET SERVEROUTPUT ON; DECLARE v_var NUMBER := 20; BEGIN -----block WHILE v_var > 0 LOOP DBMS_OUTPUT.PUT_LINE(LPAD('* ', v_var * 2, '* ')); ---print v_var := v_var - 1; END LOOP; END; /

  • + 0 comments

    DELIMITER //

    CREATE PROCEDURE PrintStars() BEGIN DECLARE count INT DEFAULT 20;

    WHILE count > 0 DO
        SELECT REPEAT(' * ', count);
        SET count = count - 1;
    END WHILE;
    

    END //

    DELIMITER ;

    -- To execute the procedure: CALL PrintStars();

  • + 0 comments

    DELIMITER // CREATE PROCEDURE pattern() BEGIN DECLARE count INT; set count = 20;

    WHILE count > 0 DO
        SELECT repeat('* ', count) AS Message;
        SET count = count - 1;
    END WHILE;
    

    END // DELIMITER ;

    CALL pattern();

  • + 0 comments

    MySQL

    WITH RECURSIVE numbers AS ( SELECT 20 AS n UNION ALL SELECT n - 1 FROM numbers WHERE n > 1 ) SELECT REPEAT('* ', n) AS pattern FROM numbers;

  • + 0 comments

    declare @pointer int set @pointer = 20 while (@pointer <> 0) begin select(replicate('* ', @pointer)) set @pointer = @pointer-1 end