Why do I get the following error? I need to implement hook_views_query_alter() to change the value of delta of the field that form a relationship.

As I posted in change delta value, the code is the following one.

   function supermama_misc_views_query_alter($view, $query) {
     $view-&gt;$query-&gt;table_queue['field']['join']-&gt;extra[2]['value'] = 1;
   }


It gives me the following error: 


  Fatal error: Cannot access empty property


The same error appears if I use the following code.

    function supermama_misc_views_post_build($view) {
      if ($view-&gt;name == 'gallery_images') {
        $view-&gt;$query-&gt;table_queue['field']['join']-&gt;extra[2]['value'] = 1;
      }
    }


What's wrong with the code? How do I bypass the error?
Thanks a lot molot 

the problem was a wrong implementation to the views hooks as this post

and hook_views_query_alter

This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. MODULENAME.views.inc must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified.