Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Nesting level or loop within level for CTAS

BeefStuJun 22 2020 — edited Jun 24 2020

I have the following statement, which works.

<html>

    CREATE TABLE t AS

    SELECT level AS id,   

    CASE round(dbms_random.value(1,2))

            WHEN 1 THEN 'Y'

            WHEN 2 THEN 'N'

         END AS val1

    FROM   dual

   CONNECT BY level <= 5;

</html>

Is there a way to nest level statements or stick a loop within a level statement to create a 7 or N byte string of 'Y' or 'N', which has  a column called val1 with a value like this 'YYNNYNY

Comments
Post Details
Added on Jun 22 2020
18 comments
404 views