Vikas Bhardwaj
Vikas Bhardwaj

Reputation: 73

INSERT with alias name is not working on PostgreSQL

SQL Query on PostgreSQL:

insert into TOKEPOOLAMT (TOKEPOOLAMT.TOKEPOOLAMTID,TOKEPOOLAMT.TOKERULEID)
values (151, 176);

Giving error:

com.edb.util.PSQLException:
ERROR: column "tokepoolamt" of relation "tokepoolamt" does not exist

But:

insert into TOKEPOOLAMT (TOKEPOOLAMTID,TOKERULEID) values (151, 176);

is working fine.

Can anybody explain why alias name with column in insert statement not working?

Upvotes: 0

Views: 1173

Answers (1)

Erwin Brandstetter
Erwin Brandstetter

Reputation: 657912

There are no aliases involved here. Your error is that column names in the column list of an INSERT command cannot be table-qualified. @pozs already provided the fitting quote from the manual in his comment.

I don't think it's an issue of case. I tried with both the cases.

That's missing the point. In Postgres, identifiers are folded to lower case unless double-quoted. If you double-quoted a name at creation time you preserved a case sensitive spelling and need to double-quote for the rest of the object's life - unless it was a legal, lower-case name to begin with, then quoting won't make a difference. Details:

Upvotes: 3

Related Questions