Interesting-Field NULL

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Fri, 20 Aug 2004 11:33 am

Check this out ... Create a view with a NULL field.
The field is recorded with VARCHAR2 (0). This proves that NULL = VARCHAR2 (0) ...:-)

Code: Select all
SQL> CREATE OR REPLACE VIEW VIEW_NULL AS
  2  SELECT
  3    NULL CAMPO_NULL
  4  FROM DUAL;

View created.

SQL> DESC VIEW_NULL;
Name                            Null?    Type
------------------------------- -------- ----
CAMPO_NULL                               VARCHAR2(0)

SQL>
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Mon, 23 Aug 2004 7:10 am

Disagree, null is null, Null is not equal to a varchar2 (0);

Check this out
Code: Select all
SQL> declare
  2  a varchar2(0) default null;
  3  begin
  4  null;
  5  end;
  6  /
a varchar2(0) default null;
           *
ERRO na linha 2:
ORA-06550: linha 2, coluna 12:
PLS-00215: Restrições do comprimento das cadeias de car. devem estar dentro do
intervalo (1 .. 32767)
Complementing ... because the Null is a number then?

Code: Select all
  1  CREATE OR REPLACE VIEW VIEW_NULL AS
  2      SELECT
  3        NULL CAMPO_NULL
  4        ,TO_NUMBER(NULL) CAMPO_NULL_NUMERICO
  5* FROM DUAL
SQL> /

Vista criada.

SQL> DESC VIEW_NULL;
Nome                                      Nulo?    Tipo
----------------------------------------- -------- ----------------------------
CAMPO_NULL                                         VARCHAR2
CAMPO_NULL_NUMERICO                                NUMBER
charlesmafra
Location: Angola

Charles Mafra
Oracle Developer

Poston Mon, 23 Aug 2004 8:15 am

Interesting this topic ... (It seems those lessons in philosophy where debate \"what is nothing\")

But not wanting to put more fuel on the fire, see the PL below:
Code: Select all
THO> DECLARE
  2    A VARCHAR2(10);
  3  BEGIN
  4    A:='';
  5    IF A IS NULL
  6    THEN DBMS_OUTPUT.PUT_LINE('Esse é null!');
  7    END IF;
  8  END;
  9  /

PL/SQL procedure successfully completed.

THO> SET SERVEROUTPUT ON
THO> /
Esse é null!

PL/SQL procedure successfully completed.

THO>
But I agree with charlesmafra. I also think that NULL is NULL. (this example I quoted above does not change my opinion).
tfg
Location: Novo Hamburgo - RS

Poston Mon, 23 Aug 2004 12:24 pm

As you can see in your example, if we take the assignment that you did, keep saying that \"\" is null.

Because the variable is initialized with null automatically ... write the varchar2 (10); equals the varchar2 (10): = null; and like the varchar2 (10) default null;

Code: Select all
  1  DECLARE
  2        A VARCHAR2(10);
  3      BEGIN
  4        --A:='';
  5        IF A IS NULL
  6        THEN DBMS_OUTPUT.PUT_LINE('Esse é null!');
  7        END IF;
  8*     END;
SQL> /
Esse é null!

Procedimento de PL/SQL concluído com êxito.

SQL>
When you did \": = ''\" you don't assign a blank space, you just opened and closed quotes, agree with me that this is not \"nothing\" or is Null.
charlesmafra
Location: Angola

Charles Mafra
Oracle Developer


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: Google [Bot] and 7 guests