Skip to main content
Dale Kelley
Participating Frequently
Aug 18, 2022 10:41 AM UTC

Performing a SELECT with LIKE and alpha in the key

I have a couple of programs that select .pdf files based on the key of a
record in the bridge file. Most of these keys are numeric with a
hyphen, i.e. 123-01. Left of the dash is the road number and to the
right a sequential number for the bridge. One of the roads got split by
annexation and a left over section of road 84 was made 84A and contained
a bridge, 84A-01. PERFORM "SSELECT BRGDOC WITH @ID LIKE ":BRGKEY:"..."
has worked great until this bridge. From TCL to get the document list
SSELECT BRGDOC WITH @ID LIKE "'BRGKEY'..." is the format that works. To
do this from a PERFORM I need 3 sets of quotes and I haven't been able
to come up with a working statement. Does anyone have a suggestion?

    5 replies

    Jonathan Smith
    Rocketeer
    Aug 18, 2022 11:19 AM UTC
    I have a couple of programs that select .pdf files based on the key of a
    record in the bridge file. Most of these keys are numeric with a
    hyphen, i.e. 123-01. Left of the dash is the road number and to the
    right a sequential number for the bridge. One of the roads got split by
    annexation and a left over section of road 84 was made 84A and contained
    a bridge, 84A-01. PERFORM "SSELECT BRGDOC WITH @ID LIKE ":BRGKEY:"..."
    has worked great until this bridge. From TCL to get the document list
    SSELECT BRGDOC WITH @ID LIKE "'BRGKEY'..." is the format that works. To
    do this from a PERFORM I need 3 sets of quotes and I haven't been able
    to come up with a working statement. Does anyone have a suggestion?
    Dave,

    If I understood your problem correctly

    LIST CMBOARD 15:50:58 18 Aug 2022 1
    CMBOARD...

    84-01
    84A-01
    2 records listed

    :SSELECT CMBOARD WITH @ID LIKE "84..."

    2 records selected to list 0.

    >CLEARSELECT
    :SSELECT CMBOARD WITH @ID LIKE "84A..."

    No data retrieved from current (S)SELECT statement.
    :

    And it is the second select you is causing you the problem.

    The LIKE statement is ECL type U works with the syntax attribute LIKE [string | pattern]

    So the 84A is being interpreted by the parser as looking for a pattern of 84 alpha characters.

    The following should work for you to avoid any confusion with the parser

    SSELECT CMBOARD WITH @ID LIKE "'84'..."

    2 records selected to list 0.

    >CLEARSELECT
    :SSELECT CMBOARD WITH @ID LIKE "'84A'..."

    1 records selected to list 0.

    >CLEARSELECT

    The LIKE operator is designed to work like the matches operator

    I hope this helps or to be completely accurate to get each one separately.

    :SELECT CMBOARD WITH @ID LIKE "'84-'..."

    1 records selected to list 0.

    >CLEARSELECT
    :SELECT CMBOARD WITH @ID LIKE "'84A-'..."

    1 records selected to list 0.

    >CLEARSELECT
    :

    In a program

    001: BRGKEY = "84A"
    002: PARTKEY = DQUOTE(SQUOTE(BRGKEY : "-") : "...")
    003: STMT = "SSELECT CMBOARD WITH @ID LIKE " : PARTKEY
    004: CRT STMT
    005: EXECUTE STMT
    006: CLEARSELECT
    *--: FIBR
    Filed "T45" in file "BP".

    Compiling Unibasic: BP\\T45 in mode 'u'.
    compilation finished
    SSELECT CMBOARD WITH @ID LIKE "'84A-'..."

    1 records selected to list 0.


     

    ​​​

    ------------------------------
    Jonathan Smith
    UniData ATS
    Rocket Support
    ------------------------------
    Rocket Software - Senior Principal Technical Support Engineer - UniData ATS
    Tyrel Marak
    Participating Frequently
    Aug 19, 2022 7:33 AM UTC
    I have a couple of programs that select .pdf files based on the key of a
    record in the bridge file. Most of these keys are numeric with a
    hyphen, i.e. 123-01. Left of the dash is the road number and to the
    right a sequential number for the bridge. One of the roads got split by
    annexation and a left over section of road 84 was made 84A and contained
    a bridge, 84A-01. PERFORM "SSELECT BRGDOC WITH @ID LIKE ":BRGKEY:"..."
    has worked great until this bridge. From TCL to get the document list
    SSELECT BRGDOC WITH @ID LIKE "'BRGKEY'..." is the format that works. To
    do this from a PERFORM I need 3 sets of quotes and I haven't been able
    to come up with a working statement. Does anyone have a suggestion?
    Hi Dale,

    I'm not sure if this is UniVerse or UniData, but in UniVerse, you can use \\, " or ' as quote characters in a BASIC program, so you can do something like...

    PERFORM \\SSELECT BRGDOC WITH @ID LIKE \\"'\\:BRGKEY:\\'..."\\

    When I first started in multi-value, I was the new kid in the shop and I discovered the back-slash quote in the programming reference.  None of the older programmers knew about it and just hated to see it in my programs.  They tried to get me to stop using back-slash as a quote character ... but I stuck to my guns ... and now I can pass it on to you :-).​  I hope it helps.

    ------------------------------
    Tyrel Marak
    Technical Support Manager
    Aptron Corporation
    Florham Park NJ US
    ------------------------------
    Dale Kelley
    Participating Frequently
    Aug 19, 2022 7:47 AM UTC
    Hi Dale,

    I'm not sure if this is UniVerse or UniData, but in UniVerse, you can use \\, " or ' as quote characters in a BASIC program, so you can do something like...

    PERFORM \\SSELECT BRGDOC WITH @ID LIKE \\"'\\:BRGKEY:\\'..."\\

    When I first started in multi-value, I was the new kid in the shop and I discovered the back-slash quote in the programming reference.  None of the older programmers knew about it and just hated to see it in my programs.  They tried to get me to stop using back-slash as a quote character ... but I stuck to my guns ... and now I can pass it on to you :-).​  I hope it helps.

    ------------------------------
    Tyrel Marak
    Technical Support Manager
    Aptron Corporation
    Florham Park NJ US
    ------------------------------
    Wow! Thank you Tyrel. Digging into reference material, the rest of us
    seldom or never do it. I'm going to try your solution and Jonathon's.
    Great information.
    Dale
    Dale Kelley
    Participating Frequently
    Aug 19, 2022 10:10 AM UTC
    Hi Dale,

    I'm not sure if this is UniVerse or UniData, but in UniVerse, you can use \\, " or ' as quote characters in a BASIC program, so you can do something like...

    PERFORM \\SSELECT BRGDOC WITH @ID LIKE \\"'\\:BRGKEY:\\'..."\\

    When I first started in multi-value, I was the new kid in the shop and I discovered the back-slash quote in the programming reference.  None of the older programmers knew about it and just hated to see it in my programs.  They tried to get me to stop using back-slash as a quote character ... but I stuck to my guns ... and now I can pass it on to you :-).​  I hope it helps.

    ------------------------------
    Tyrel Marak
    Technical Support Manager
    Aptron Corporation
    Florham Park NJ US
    ------------------------------
    Tyrel,

    Your solution worked beautifully. One slight correction, I knew an odd
    number of \\'s would have problems. The one that works : \\SSELECT BRGDOC
    WITH @ID LIKE "'\\:BRGKEY:\\'..."\\

    Thanks again, Dale


    On 08/19/2022 06:34 AM, Tyrel Marak via Rocket Forum wrote:
    > Hi Dale, I'm not sure if this is UniVerse or UniData, but in UniVerse,
    > you can use \\, " or ' as quote characters in a BASIC program, so you
    > can...
    > Invite your colleagues to join the Rocket Forum and grow our expert
    > network.
    > ------------------------------------------------------------------------
    > Rocket Software
    >
    >
    > Rocket U2 | UniVerse & UniData
    >
    >
    >
    > Post New Message Online
    >
    > Invite your colleagues to join the Rocket Forum and grow our expert
    > network. Share this link.
    >
    > Re: Performing a SELECT with LIKE and alpha in the key
    >
    >
    > Reply to Group Online
    >
    > Reply to Group
    >
    >
    >
    > Tyrel Marak
    >
    >
    > Aug 19, 2022 7:33 AM
    > Tyrel Marak
    >
    >
    >
    > Hi Dale,
    >
    > I'm not sure if this is UniVerse or UniData, but in UniVerse, you can
    > use \\, " or ' as quote characters in a BASIC program, so you can do
    > something like...
    >
    > PERFORM \\SSELECT BRGDOC WITH @ID LIKE \\"'\\:BRGKEY:\\'..."\\
    >
    > When I first started in multi-value, I was the new kid in the shop and
    > I discovered the back-slash quote in the programming reference. None
    > of the older programmers knew about it and just hated to see it in my
    > programs. They tried to get me to stop using back-slash as a quote
    > character ... but I stuck to my guns ... and now I can pass it on to
    > you :-).??? I hope it helps.
    >
    > ------------------------------
    > Tyrel Marak
    > Technical Support Manager
    > Aptron Corporation
    > Florham Park NJ US
    > ------------------------------
    >
    > *Reply to Group Online
    > *
    > *View Thread
    > *
    > *Recommend
    > *
    > *Forward
    > *
    > *Flag as Inappropriate
    > *
    > *Post New Message Online
    > *
    >
    Dale
    Tyrel Marak
    Participating Frequently
    Aug 19, 2022 1:58 PM UTC
    Tyrel,

    Your solution worked beautifully. One slight correction, I knew an odd
    number of \\'s would have problems. The one that works : \\SSELECT BRGDOC
    WITH @ID LIKE "'\\:BRGKEY:\\'..."\\

    Thanks again, Dale


    On 08/19/2022 06:34 AM, Tyrel Marak via Rocket Forum wrote:
    > Hi Dale, I'm not sure if this is UniVerse or UniData, but in UniVerse,
    > you can use \\, " or ' as quote characters in a BASIC program, so you
    > can...
    > Invite your colleagues to join the Rocket Forum and grow our expert
    > network.
    > ------------------------------------------------------------------------
    > Rocket Software
    >
    >
    > Rocket U2 | UniVerse & UniData
    >
    >
    >
    > Post New Message Online
    >
    > Invite your colleagues to join the Rocket Forum and grow our expert
    > network. Share this link.
    >
    > Re: Performing a SELECT with LIKE and alpha in the key
    >
    >
    > Reply to Group Online
    >
    > Reply to Group
    >
    >
    >
    > Tyrel Marak
    >
    >
    > Aug 19, 2022 7:33 AM
    > Tyrel Marak
    >
    >
    >
    > Hi Dale,
    >
    > I'm not sure if this is UniVerse or UniData, but in UniVerse, you can
    > use \\, " or ' as quote characters in a BASIC program, so you can do
    > something like...
    >
    > PERFORM \\SSELECT BRGDOC WITH @ID LIKE \\"'\\:BRGKEY:\\'..."\\
    >
    > When I first started in multi-value, I was the new kid in the shop and
    > I discovered the back-slash quote in the programming reference. None
    > of the older programmers knew about it and just hated to see it in my
    > programs. They tried to get me to stop using back-slash as a quote
    > character ... but I stuck to my guns ... and now I can pass it on to
    > you :-).??? I hope it helps.
    >
    > ------------------------------
    > Tyrel Marak
    > Technical Support Manager
    > Aptron Corporation
    > Florham Park NJ US
    > ------------------------------
    >
    > *Reply to Group Online
    > *
    > *View Thread
    > *
    > *Recommend
    > *
    > *Forward
    > *
    > *Flag as Inappropriate
    > *
    > *Post New Message Online
    > *
    >
    Dale,

    Oops ... a typo.  Thanks for the update.  Glad you got it figured out.

    Have a good one :-)

    ------------------------------
    Tyrel Marak
    Technical Support Manager
    Aptron Corporation
    Florham Park NJ US
    ------------------------------