0

I have a question regarding stored procedure so I have this procedure saved:

CREATE OR REPLACE PROCEDURE WELTESADMIN.TOTALFABRICATION
    (SUBCONT IN VARCHAR, PROJECT IN VARCHAR, TOTALFABRICATIONRESULT OUT NUMBER) AS
BEGIN
    SELECT FABRICATION.MARKING + FABRICATION.CUTTING + FABRICATION.ASSEMBLY + FABRICATION.WELDING + 
            FABRICATION.DRILLING + FABRICATION.FINISHING
    INTO TOTALFABRICATIONRESULT
    FROM FABRICATION
    WHERE SUBCONT_ID = SUBCONT 
        AND PROJECT_NAME = PROJECT;
END;

And im processing that in PHP such as,

    $subcontValue = "RIYANTO";
    $projectValue = "PROCESSHOUSE";

    $sql = "BEGIN TOTALFABRICATION(:SUBCONT, :PROJECT); END;";
    $stmt = oci_parse($conn, $sql);

    oci_bind_by_name($stmt, ":SUBCONT", $subcontValue);
    oci_bind_by_name($stmt, ":PROJECT", $projectValue);
    oci_define_by_name($stmt, "TOTALFABRICATIONRESULT", $result);

    oci_execute($stmt);

    echo $result;

I am sure that all the variables supplied are correct, connection is ok and processable in SQL PLUS instead, im getting this error in the php side,

Warning: oci_execute(): ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'TOTALFABRICATION' ORA-06550: line 1, column 7: PL/SQL: Statement ignored in C:\xampp\htdocs\WeltesInformationCenter\newEmptyPHP.php on line 39

1 Answer 1

1

Your procedure has actually three parameters (two IN and one OUT):

CREATE OR REPLACE PROCEDURE WELTESADMIN.TOTALFABRICATION
    (SUBCONT IN VARCHAR, 
     PROJECT IN VARCHAR, 
     TOTALFABRICATIONRESULT OUT NUMBER) AS

So, from PHP, you should write that:

    $sql = "BEGIN TOTALFABRICATION(:SUBCONT, :PROJECT, :TOTALFABRICATIONRESULT); END;";
    #                                                  ^^^^^^^^^^^^^^^^^^^^^^^

And bind that output parameter to some variable:

oci_bind_by_name($stmt, "TOTALFABRICATIONRESULT", $result, 300);
#                                                          ^^^
#                                                        maxlength

Please note that according to the documentation:

You must specify maxlength when using an OUT bind so that PHP allocates enough memory to hold the returned value.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.