Re: ORA-01405: fetched column value is NULL

From: Charles Wolfe <cwolfe_at_popd.ix.netcom.com>
Date: 1996/08/21
Message-ID: <321BB00D.30D8_at_popd.ix.netcom.com>#1/1


Benjamin,

You don't mention what language your programs are written in (so, I'll assume it's C).

There are 3 fairly straightforward approaches for dealing with the situation you describe.

  1. The easiest -- set the parameter DBMS in your proc.mk file to DBMS=v6. Then no error is returned for NULL column fetches without indicator variables.
  2. In the SELECT statement when you define your cursor use the NVL function to specify a non-null default value for null fetches:
	EXEC SQL DECLARE mycursor CURSOR FOR
		SELECT column1, NVL(column2,0.0)
		FROM table... 

3. Use indicator variables to test for null column fetches:

	e.g.
		char	namevar[50];
		float	salary_var;
		short	salind;

		EXEC SQL DECLARE emp_cursor CURSOR FOR
			SELECT name, salary
			FROM emp...
                           .
                           .
                           .
		EXEC SQL OPEN emp_cursor;
		EXEC SQL FETCH emp_cursor INTO :namevar, 
			:salary_var:salind;

		if (salind == -1)
			salary_var = 5000.00;

		and so on...

hope this helps,

regards

Chuck  

-- 

*****************************************************************************
*
* Chuck Wolfe Phone: (703)838-9720
* Manager e-mail: cwolfe_at_ix.netcom.com
(Home)
* NDC Group, Inc cwolfe_at_ndcinc.com
(Work)
* 625 Slaters Lane,
* Suite 102
* Alexandria, VA 22314
*
* All the usual discalimers apply, except where otherwise indicated...
****************************************************************************
Received on Wed Aug 21 1996 - 00:00:00 CEST

Original text of this message