Announcement

Collapse
No announcement yet.

How insert on a SQL grid WHERE clause hiding values

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How insert on a SQL grid WHERE clause hiding values

    Hello,
    I got to hide the view of data to some users based on row column values (Sales DIVISIONS) which they can access or not.
    These info are recorded on users master data field Division.
    I set Division field as text DOUBLE SELECT to choose more than one
    On grid I want that rules permit or not to see data based on Division of singular row.

    The data of division field are recorded on field as array HHD1;HHD3......

    How can write the where clause on SQL ?
    I think I have to use IN

    WHERE user.division IN ('{division}')

    The problem is that the sintax of IN clause is ('Value01', 'Value02'....)
    not using the ; as in the field value

    In SC it's wrong becouse it write the IN clause like that ---> IN (HHD1;HHD3) and it don't work at all....

    Have you got a sample to enlight me how to write the where clause ?

    Thanks


    This is a sample to understand better my problem
    $sql = "SELECT
    priv_admin,
    active,
    name,
    email,
    area
    FROM sec_users
    WHERE login = 'admin'
    AND pswd = 'admin' ";

    sc_lookup(rs, $sql);
    echo {rs[0][4]};

    RESULT IS ---> HHD1;HHD3
    Last edited by giovannino; 12-16-2016, 08:25 AM.

  • #2
    For whom interested I founded , after many tests, a kind of solution . It's not so stilish... but in some way it works ;-))

    $sql = "SELECT
    priv_admin,
    active,
    name,
    email,
    area
    FROM sec_users
    WHERE login = 'fabio'
    AND pswd = '*****";
    sc_lookup(rs, $sql);


    $sql_area="SELECT GROUP_CONCAT( area ) FROM `area` ";
    sc_lookup(rs_area, $sql_area);


    if ({rs[0][4]} == '' ) //All divisions
    {[usr_area] = "'" . str_replace(',',"','",{rs_area[0][0]}) . "'" ;}
    else {
    [usr_area] = "'" . str_replace(';',"','",{rs[0][4]}) . "'" ; //Selected on master data
    }

    echo [usr_area];

    Comment

    Working...
    X