Call Oracle function in Laravel?

1

I made all the configuration to connect in Oracle, it connects, but I want to make an query inside a function, but it is giving the following error message:

  

QueryException in Connection.php line 729:       oci_bind_by_name (): ORA-01036: illegal variable name / number (SQL: SELECT function (': login') FROM DUAL)

The query I'm trying to do is like this:

public function login()
{
    $login = Request::input('login');
    $var = DB::connection('oracle1')
        ->select("SELECT funcao(':login') FROM DUAL", 
                           array( "login" => $login));    
    return 'Resultado: '.$var;
}

If having with question (?)

DB::connection('oracle1')
        ->select("SELECT funcao('?') FROM DUAL", 
                           array( "login" => $login));

The message gives a small change:

  

oci_bind_by_name (): ORA-01036: illegal variable name / number (SQL: SELECT function ('CARLOS.BRITO') FROM DUAL)

    
asked by anonymous 18.10.2017 / 20:40

1 answer

0

I discovered the problem:

I've changed

->select("SELECT funcao(':login') FROM DUAL", 
                           array( "login" => $login));

To

->select("SELECT funcao(':login') FROM DUAL", 
                           array( $login));

Looking like this:

public function login()
{
    $login = Request::input('login');
    $var = DB::connection('oracle1')
        ->select("SELECT funcao(':login') FROM DUAL", 
                           array( $login));    
    return 'Resultado: '.$var;
}

That worked.

Thanks to those who were willing to help me.

    
19.10.2017 / 21:27