Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Char vs Varchar2 and NULL

Re: Char vs Varchar2 and NULL

From: Programming <sysdev_at_mb.sympatico.ca>
Date: 1998/09/08
Message-ID: <35F58BC8.5076@mb.sympatico.ca>#1/1

HI,

VARCHAR is actually a STRUCTURE/RECORD.

It has two components,

	array 	(.arr) and
	length	(.len)

You have to be careful when using these variables to set the length.

So, typically, in embedded SQL programs in C.

	SELECT ...
	INTO :varchar_variable	
	...

varchar_variable.arr[varchar_variable.len] = '\0';

However, a char variable is just an array of char.

I hope that this might be of some help.

Rodger

> Declare
> V Varchar2(3);
> C Char(3);
> Begin
> V := Null;
> C := V;
> DBMS_Output.Put_Line
> ('Char = |' || C || '| (Set from NULL varchar2');
> V := '';
> C := V;
> DBMS_Output.Put_Line
> ('Char = |' || C || '| (Set from zero-length varchar2');
> End;
> /
>
> The output looks like this:
> Char = || (Set from NULL varchar2
> Char = | | (Set from zero-length varchar2
> The second value is three spaces!
>
> Apparently, there is a difference between NULL and Zero-Length
> values in Varchar2 fields.
Received on Tue Sep 08 1998 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US