Curl Global Community

Full Version: Curl execute Oracle database procedure
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.

I already have:
- Curl sample connected to Oracle database.
- Oracle database have some procedure and function.

Let's assume I created procedure in Oracle name PR_SELECT_DATA:
Code:
CREATE PROCEDURE PR_SELECT_DATA (TOTAL_RECORD OUT NUMBER) AS    
    BEGIN
        SELECT
            COUNT(*)    
        INTO
            TOTAL_RECORD
        FROM
            TOP_SALES_CUSTOMERS;    
    END;
/


Now I want to execute this procedure in Curl code, I expect something like:
Code:
connection.executeProcedure("PR_SELECT_DATA ");
connection.executeFunction("FUNCTION_NAME ");

I have tried:
Code:
{let statement:String =
     {
        String
            "DECLARE TOTAL_RECORD NUMBER;"         , "BEGIN        PR_SELECT_DATA (TOTAL_RECORD);        END;" }
}
{connection.execute "SH", statement}
but no luck.

I searched in this forum, no luck again.
Can anyone help me?
I don't think Curl' ConnectedRecordSet supports stored procedure.
To do this, you need to create your own ConnectedRecordSet together with a server-side program/API to help you execute such a database procedure.
(04-18-2017, 08:52 AM)tdeng Wrote: [ -> ]I don't think Curl' ConnectedRecordSet supports stored procedure.
To do this, you need to create your own ConnectedRecordSet together with a server-side program/API to help you execute such a database procedure.
I found the way to execute store procedure and function Oracle.

To execute Procedure:
Code:
{let rs:RecordSet=
    {connection.create-record-set "DATABASE_NAME", "call PROCEDURE_NAME()"}
}

I have tried procedure with update statement and it successful.

To call Function:
Code:
{let rs:RecordSet=
    {connection.create-record-set "DATABSE_NAME","SELECT FUNCTION_NAME() AS ABC FROM DUAL"}
}
{rs.load}

{for r:Record in rs do
    {outfmt {format "%s, ", r["ABC"]}}
}

It will show return value of function in CURL console.
WOW, Congratulations! That's cool, and new to me Smile
Thank you for sharing your information with us!