Skip to main content
Nelson Schroth
Participating Frequently
Jul 26, 2024 4:09 PM UTC

Multiple Selects from Basic program

I noticed that when I executed two select statements in a basic program, the 2nd one does NOT utilize the results from the first one:

CMD1='SELECT FILE WITH ATTR1 EQ "Y"''

EXECUTE CMD1

CMD2-'SORT FILE F1 F2 F3 F4'

EXECUTE CMD2

But, if I combine them it works:

MULTI.CMD=CMD1:@AM:CMD2

EXECUTE MULTI.CMD

Problem: is there a way to keep the 2nd command from running if the CMD1 finds 0 records?



------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------

    6 replies

    Doug Averch
    Inspiring
    Jul 26, 2024 4:49 PM UTC

    I noticed that when I executed two select statements in a basic program, the 2nd one does NOT utilize the results from the first one:

    CMD1='SELECT FILE WITH ATTR1 EQ "Y"''

    EXECUTE CMD1

    CMD2-'SORT FILE F1 F2 F3 F4'

    EXECUTE CMD2

    But, if I combine them it works:

    MULTI.CMD=CMD1:@AM:CMD2

    EXECUTE MULTI.CMD

    Problem: is there a way to keep the 2nd command from running if the CMD1 finds 0 records?



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    EXECUTE CMD2:' REQUIRE.SELECT'



    ------------------------------
    Doug Averch
    Owner
    U2 Logic
    ------------------------------

    Doug Averch Owner https://www.u2logic.com/
    Shawn Waldie
    Jul 26, 2024 4:55 PM UTC

    I noticed that when I executed two select statements in a basic program, the 2nd one does NOT utilize the results from the first one:

    CMD1='SELECT FILE WITH ATTR1 EQ "Y"''

    EXECUTE CMD1

    CMD2-'SORT FILE F1 F2 F3 F4'

    EXECUTE CMD2

    But, if I combine them it works:

    MULTI.CMD=CMD1:@AM:CMD2

    EXECUTE MULTI.CMD

    Problem: is there a way to keep the 2nd command from running if the CMD1 finds 0 records?



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    In Unidata, you could conditionally execute the second one only if either @SYSTEM.RETURN.CODE or SYSTEM(11) is greater than or equal to 1:

    CMD1='SELECT FILE WITH ATTR1 EQ "Y"''

    EXECUTE CMD1

    IF @SYSTEM.RETURN.CODE GE 0 THEN

    CMD2-'SORT FILE F1 F2 F3 F4'

    EXECUTE CMD2

    END



    ------------------------------
    Shawn Waldie
    enterprise application developer
    Rocket Forum Shared Account
    Los Angeles CA US
    ------------------------------
    Manu Fernandes
    Inspiring
    Jul 27, 2024 6:15 AM UTC

    I noticed that when I executed two select statements in a basic program, the 2nd one does NOT utilize the results from the first one:

    CMD1='SELECT FILE WITH ATTR1 EQ "Y"''

    EXECUTE CMD1

    CMD2-'SORT FILE F1 F2 F3 F4'

    EXECUTE CMD2

    But, if I combine them it works:

    MULTI.CMD=CMD1:@AM:CMD2

    EXECUTE MULTI.CMD

    Problem: is there a way to keep the 2nd command from running if the CMD1 finds 0 records?



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    Hello Nelson

    Have a look to EXECUTE / RTNLIST / PASSLIST

    I hope this help. 



    ------------------------------
    Manu Fernandes
    ------------------------------
    Nelson Schroth
    Participating Frequently
    Jul 29, 2024 8:38 AM UTC

    EXECUTE CMD2:' REQUIRE.SELECT'



    ------------------------------
    Doug Averch
    Owner
    U2 Logic
    ------------------------------

    Doug,

    Explain 'RETURN.SELECT'.  not in any UniVerse manuals and I am not sure how to utilize it.

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------
    Nelson Schroth
    Participating Frequently
    Jul 29, 2024 8:42 AM UTC

    Doug,

    Explain 'RETURN.SELECT'.  not in any UniVerse manuals and I am not sure how to utilize it.

    Nelson



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    SORRY - REQUIRE.SELECT.

    is this an option for EXECUTE?



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------
    Nelson Schroth
    Participating Frequently
    Jul 29, 2024 9:15 AM UTC

    SORRY - REQUIRE.SELECT.

    is this an option for EXECUTE?



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------

    my problem was a missing space after the quote and before the REQUIRE.SELCT.

    thanks for the tip!



    ------------------------------
    Nelson Schroth
    president
    C3CompleteShop LLC
    Harrison OH US
    ------------------------------