segunda-feira, 18 de fevereiro de 2013

Erro no INSERT em tabela com campo IDENTITY


Ao tentar inserir um valor em uma tabela com campo identity diretamente, será necessário ligar o atributo identity_insert, e também informar explicitamente a lista de campos, ou seja, o comando a seguir, sem a lista explícita vai gerar o erro "An explicit value for the identity column in table 'table_name' can only be specified when a column list is used and IDENTITY_INSERT is ON";

INSERT nome_tabela VALUES (Valor1, Valor2, etc)

Pois neste caso é imperativo que se informa a lista de campos, deste jeito:

INSERT nome_tabela(Campo1, Campo2, etc) VALUES (Valor1, Valor2, etc).

Para ligar e desligar o atributo:
SET IDENTITY_INSER ON BANCO.DBO.TABELA ON|OFF

Não sei se a lista de campos é uma questão de versão do banco, mas no SQL Server 2008 foi necessário informá-la. Bom trabalho a todos.

sexta-feira, 8 de fevereiro de 2013

TNS Protocol Adapter Erro

[PT-BR]
Um dos motivos deste erro é que o sqlplus não consegue identificar o ORACLE_SID, e fica sem saber em qual Instância de banco efetuar o login. 
A solução mais simples que achei na web para meu caso foi configurar a variável de ambiente citadas:

c:>set ORACLE_SID=

O nome da variável pode estar em qualquer combinação de caixa (alta, baixa ou mista).

[ENU]
One of the causes of this error is the fact that sqlplus cannot identify the oracle_sid value, and cannot decide which instance to log in.
The simpler solution I`ve found on the web for my actual case was to set up the environment variable cited above:

c:>set ORACLE_SID=

The variable name can be typed in any combination of case.