Curl Global Community
Curl execute Oracle database procedure - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: Curl execute Oracle database procedure (/showthread.php?tid=1447)



Curl execute Oracle database procedure - NamDH - 04-14-2017

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?


RE: Curl execute Oracle database procedure - tdeng - 04-18-2017

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.


RE: Curl execute Oracle database procedure - NamDH - 04-21-2017

(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.


RE: Curl execute Oracle database procedure - tdeng - 04-21-2017

WOW, Congratulations! That's cool, and new to me Smile
Thank you for sharing your information with us!