Call Oracle function in Laravel?

Asked

Viewed 503 times

1

I did all the configuration to connect on Oracle, it connects, but I want to make a query within 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 funcao(':login') FROM DUAL)

The appointment I’m trying to make 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;
}

Having a question mark (?)

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

The message gives a little change:

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

  • Tried to query without simple Apas in placeholder (login or ?)?

  • Same message.

  • DB::connection('oracle1')->select("SELECT funcao(?) FROM DUAL", array($login)); or DB::connection('oracle1')->select("SELECT funcao(:login) FROM DUAL", array(":login" => $login)); makes the same mistake?

  • 2

    Yes, it only changed that one came with the login informed and the other with the parameter only, but I found out! In the array, I only informed the variable and it worked out so: ...select("SELECT funcao(?) FROM DUAL", array( $login )

  • @adventistaam if you can put your comment as answer to your own question, then tick how answer it is good to do this so your question has an answer. all right!

1 answer

0


I found the problem:

Changed

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

To

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

Thus remaining:

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

Ai worked.

Thank you to those who were willing to help me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.