OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/ODBC

V2.0.9
  • Overview
  • Driver installation and configuration
    • Prepare for the installation
    • Install and configure the ODBC driver for Linux
    • Install and configure OceanBase Connector/ODBC for Windows
  • User guide
    • Basic operations
    • Enable logging
    • Get REF CURSOR data type
    • Scalar function escape
    • Call Function
  • Reference information
    • API functions in OceanBase Connector/ODBC
    • Data types in OceanBase Connector/ODBC
    • Error codes in OceanBase Connector/ODBC
  • FAQ
    • Query timeout
    • Chinese garbled characters
    • Common OceanBase ODBC installation and configuration issues and solutions
  • 600.version-release-records
    • 9900.V2.0
      • OceanBase Connector/ODBC V2.0.9
      • OceanBase Connector/ODBC V2.0.8
      • OceanBase Connector/ODBC V2.0.7
      • OceanBase Connector/ODBC V2.0.6

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/ODBC
  3. V2.0.9

Call Function

Last Updated:2026-09-04 08:24:40

OceanBase Connector/ODBC supports the Call Function command. The syntax is as follows:

{call func_name()}

During execution, the Call Function command is converted to the following statement:

BEGIN
func_name()
END;

Here is an example:

ODBC_TEST(test_func_normal)
{
  SQLRETURN ret = 0;
  SQLLEN outLen = 0;
  char *createpl = "create or replace function query_bench(str in varchar2) RETURN varchar2 IS\n"
    " l_rst    varchar2(100);\n"
    "begin\n"
    "  l_rst:='1234455';\n"
    "  RETURN l_rst;\n"
    "end query_bench;";

  CHECK_STMT_RC(Stmt, ret = SQLPrepare(Stmt, (SQLCHAR*)createpl, (SQLINTEGER)strlen((char*)createpl)));
  CHECK_STMT_RC(Stmt, ret = SQLExecute(Stmt));
  CHECK_STMT_RC(Stmt, ret = SQLFreeStmt(Stmt, SQL_CLOSE));
  SQLEndTran(SQL_HANDLE_DBC, Connection, SQL_COMMIT);

  SQLRETURN rcode;
  char *pCall = (char*)"{ ? = call QUERY_BENCH(?)}";
  char buf1[100] = { 0 };
  char buf2[100] = { 0 };
  SQLLEN inOut = SQL_NTS;

  rcode = SQLPrepare(Stmt, (SQLCHAR*)pCall, strlen(pCall));
  CHECK_STMT_RC(Stmt, rcode);
  rcode = SQLBindParameter(Stmt, 1, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, buf1, 100, &inOut);
  rcode = SQLBindParameter(Stmt, 2, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, buf2, 100, &inOut);
  rcode = SQLExecute(Stmt);
  CHECK_STMT_RC(Stmt, rcode);
  printf("buf2=%s\n", buf1);
  return OK;
}

Previous topic

Scalar function escape
Last

Next topic

API functions in OceanBase Connector/ODBC
Next