ORA-1405 Calling PL/SQL Procedure or Function from Pro*C

(Doc ID 99731.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version 9.2.0.8 and later
Precompilers - Version 9.2.0.8 and later
Information in this document applies to any platform.
***Checked for relevance on 23-Dec-2013***

Symptoms

Calling a PL/SQL block from a Pro*C application gives following error:

ORA-1405 Fetched column value is NULL

However, there is no reference to the FETCH statement within the code shown below

connect scott/tiger

CREATE OR REPLACE PROCEDURE test_proc                                                      
       (p_param1 IN VARCHAR2,                      
        p_param2 IN VARCHAR2,                         
        p_param3 IN OUT NUMBER,                                                
        p_param4 IN OUT VARCHAR2) AS                                           
BEGIN
null;                                                                           
END test_proc;                                                           
/

 

#include <string.h>
#include <stdio.h>
#include <stdlib.h> 

EXEC SQL INCLUDE sqlca;

void sql_error();
int main()
{

        /*Setting the user and password for database login*/
        char  *username = "scott/tiger";

        /*Parameters to pass to pl/sql procedure*/
        char p1[10];
        char p2[10];
        int  p3;
        char p4[10];

        /*Initializing variables*/
        memset(p1,'\0',sizeof(p1));
        memset(p2,'\0',sizeof(p2));
        p3 = 0;
        memset(p4,'\0',sizeof(p4));
        
        /*Registering sql_error() as the error handler*/
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE Error--\n");
 
        /*Connecting to database*/
EXEC SQL CONNECT :username;

printf("\ncalling procedure\n");
        EXEC SQL EXECUTE
          BEGIN
             test_proc(:p1,:p2,:p3,:p4);
          END;
        END-EXEC;

printf("Success! \n");
}
void
sql_error(msg)
char *msg;
{
   char err_msg[128];
   int buf_len,msg_len;

   EXEC SQL WHENEVER SQLERROR CONTINUE;

   printf("\n%s\n",msg);
   buf_len = sizeof(err_msg);
   sqlglm(err_msg,&buf_len,&msg_len);
   printf("%.*s\n",msg_len,err_msg);

   EXEC SQL ROLLBACK RELEASE;
   exit(1);
}



Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms