AndreaNobili
AndreaNobili

Reputation: 43057

Why this simple insert query can't work?

I am not so into database and I have some problem implementing a simple insert query (on an Oracle db) in a table named CODA_TX that have the following structure:

describe CODA_TX
Nome                 Nullo    Tipo           
-------------------- -------- -------------- 
PK_CODA              NOT NULL NUMBER(10)     
FK_TIPO_DOC                   NUMBER(4)      
FK_PIVA_MITTENTE              VARCHAR2(16)   
FK_CDZZ                       VARCHAR2(4)    
DATA_IN                       DATE           
FK_STATO             NOT NULL NUMBER(2)      
DATA_OUT                      DATE           
NUM_DOC                       VARCHAR2(35)   
CANALE                        VARCHAR2(3)    
SIZE_XML                      NUMBER(10)     
FK_PIVA_DESTINATARIO          VARCHAR2(20)   
INDIRIZZAMENTO                VARCHAR2(100)  
SIGNATURE                     VARCHAR2(1)    
PRG_CONSERVAZIONE             NUMBER(10)     
MIT_DATA_CONS                 DATE           
MIT_LOTTO_CONS                VARCHAR2(50)   
DES_DATA_CONS                 DATE           
DES_LOTTO_CONS                VARCHAR2(50)   
SEGNALAZIONE                  VARCHAR2(4000) 
IDOC_NUM                      NUMBER         
CODICE_UFFICIO_PA             VARCHAR2(6)    
IDENTIFICATIVO_SDI            NUMBER(12)     
NOME_FILE_SDI                 VARCHAR2(50)

So I have implemented this insert query to create a new record. As you can see I specify some field that have to be valorized, the not specified I think that should automatically setted to null (is it correct?):

insert into 
  CODA_TX (PK_CODA, 
           FK_TIPO_DOC, 
           FK_PIVA_DESTINATARIO, 
           DATA_IN, 
           FK_STATO, 
           DATA_OUT, 
           CANALE, 
           SIZE_XML, 
           FK_PIVA_MITTENTE) 
   values(70045, 
           5, 
           01392380547, 
           Thu May 21 16:33:40 CEST 2015, 
           2, 
          Thu May 21 16:33:40 CEST 2015, 
           WEB, 
           554, 
           01392380547)

The problem is that performing this query I obtain this error message:

Bind variable "33" non dichiarata (NOT DECLARED)
0 righe inserito.

What it exactly means? What am I missing? How can I fix this issue?

Tnx

Upvotes: 1

Views: 102

Answers (1)

Lalit Kumar B
Lalit Kumar B

Reputation: 49112

Thu May 21 16:33:40 CEST 2015

That is neither string nor date.

Your DATA_IN and DATA_OUT column data types are DATE, and date cannot have timezone.

  • Add single quotation marks to first make it a literal.
  • Use TO_DATE with proper FORMAT MODEL to convert the literal into date.
  • Remove the timezone element, or first change the data type of your column to TIMESTAMP.

Seems like you did not put any effort to research and understand anything from my answer to your previous question.

WEB

You must always enclose the string values within single-quotation marks.

For example,

'WEB'

01392380547

NUMBER cannot start with zero. Since you declared it as VARCHAR2 data type, enclose it within single-quotation marks

The most important problem is that, your values doesn't match with the columns. For example, the third last value Thu May 21 16:33:40 CEST 2015 is mapped to column CANALE. However, the column is described as:

CANALE VARCHAR2(3)

So, you have basic problems with your simple insert query.

Upvotes: 4

Related Questions