Question: The MySQL Stored Procedure was:

```
     BEGIN
     set @sql=_sql;
     PREPARE stmt FROM @sql; 
     EXECUTE stmt;
     DEALLOCATE PREPARE stmt;
     set _ires=LAST_INSERT_ID();
     END$$

```

I tried to convert it to:

```
     BEGIN  
     EXECUTE _sql;
     SELECT INTO _ires CURRVAL('table_seq');
     RETURN;
     END;

```

I get the error:

```
SQL error:

ERROR:  relation "table_seq" does not exist
LINE 1: SELECT CURRVAL('table_seq')
                       ^
QUERY:  SELECT CURRVAL('table_seq')
CONTEXT:  PL/pgSQL function "myexecins" line 4 at SQL statement
In statement:
SELECT myexecins('SELECT * FROM tblbilldate WHERE billid = 2')

```

The query used is for testing purposes only. I believe this function is used to get the row id of the inserted or created row from the query. Any Suggestions?

Answer: 
You can add an option 'expression' to the configuration. Normally it gets a "$user" as argument. So you can do something like:

```
array('allow',
   'actions'=>array('index','update', 'create', 'delete'),
   'expression'=> '$user->isAdmin',
),

```

Note that I haven't tested this but I think it will work.

Take a look [here](http://www.yiiframework.com/doc/api/1.1/CAccessControlFilter) for the rest.
Well it won't work because it knows Yii::app()->user as a CWebUser Instance and you developed the UserIdentity class so it would say 'CWebUser and its behaviors do not have a method or closure named "isAdmin"'! To use expressions like $user->isAdmin your should set isAdmin property throw the setState command which would use session to save that usually in authentication method so it would be something like this:

```
class UserIdentity extends CUserIdentity
{
    public function authenticate() 
    {
        //your authentication code

        //using your functions like $level=$this->isTeacher();
        //or $level=$this->isAdmin();
        $this->setState('isAdmin',$level);
    }
}

```

and now in the user controller in accessRules method you can have expressions

```
public function accessRules()
{
    return array(
        array('allow',
            'actions'=>array('action1','action2',...),
            'expression'=>'$user->isAdmin',
            //or Yii::app()->user->getState('isAdmin'),
        ),
        //...
    );
}

```