Skip to content

Implement LET clause (like in OrientDB) #210

Description

@agershun

Like:

SELECT FROM Profile
LET $city = address.city
WHERE $city.name like '%Saint%"' and
    ( $city.country.name = 'Italy' or $city.country.name = 'France' )

Source

This cluse will be calculated right before wherefn() and selectfn() ( or groupfn()).

Activity

  1. agershun commented on May 20, 2015

    @agershun
    MemberAuthor

    One more crazy idea to extend SQL: I am thinking about two different operators: LET and BEGIN (like in the question from StackOverflow).

    LET will work before WHERE (wherefn()) and BEGIN will work right before or right after SELECT(selectfn()/groupfn()) like:

        SET @c = 0;
        SELECT a, @b, @c 
            FROM one 
            LET @b = a*a          // internal variable only for current line
            WHERE @b > 10 
            BEGIN SET @c = @c + a END;  // own accumulator for selected lines

    or call external procedure for each selected line:

        alasql.fn.myfn = function (r) {
              alasql.vars.b = r.default.a*r.default.a
        };
        alasql('SELECT a, @b FROM one LET myfn() WHERE @b > 10 ');
    
  2. added this to the milestone on May 21, 2015
  3. removed this from the milestone on Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions