0

I want to insert a row "India", "Aditya Birla Capital Ltd", "INE674K01013", "INR", "ADTB","Aditya Birla Capital" to table shares."shareNames". This is the postgresql code:

INSERT INTO shares."shareNames" ("country", "full_name", "isin_code", "currency", "symbol", "stock_name") 
VALUES ("India", "Aditya Birla Capital Ltd", "INE674K01013", "INR", "ADTB","Aditya Birla Capital")
RETURNING *;

What I expected

I expected that shares."shareNames" would have a row like :

country|full_name               |isin_code   |currency|symbol|stock_name 
India  |Aditya Birla Capital Ltd|INE674K01013|INR     |ADTB  |Aditya Birla Capital

Actual result

Instead:

ERROR:  column "India" does not exist
LINE 3: VALUES ("India", "Aditya Birla Capital Ltd",
                ^
SQL state: 42703
Character: 125

Request: Please help me fix this problem!

0

2 Answers 2

4

In PostgreSQL the double quoting used only for DB entities names like table, column names. For escape strings use single quotes like:

INSERT INTO shares."shareNames" (
    "country", "full_name", "isin_code", "currency", "symbol", "stock_name"
) VALUES (
   'India', 'Aditya Birla Capital Ltd', 'INE674K01013', 'INR', 'ADTB', 'Aditya Birla Capital'
)
RETURNING *;
Sign up to request clarification or add additional context in comments.

2 Comments

ERROR: malformed array literal: "Aditya Birla Capital Ltd" LINE 4: 'India', 'Aditya Birla Capital Ltd', 'INE674K01013', 'INR... ^ DETAIL: Array value must start with "{" or dimension information. SQL state: 22P02 Character: 134
It is not working, thanks anyway
1

try like below

INSERT INTO shares."shareNames" ("country", "full_name", "isin_code", "currency", "symbol", "stock_name") 
VALUES ('India', 'Aditya Birla Capital Ltd', 'INE674K01013', 'INR', 'ADTB','Aditya Birla Capital')
RETURNING *;

5 Comments

ERROR: malformed array literal: "Aditya Birla Capital Ltd" LINE 2: VALUES ('India', 'Aditya Birla Capital Ltd', 'INE674K01013',... ^ DETAIL: Array value must start with "{" or dimension information. SQL state: 22P02 Character: 125
It is not working
Ok i will check it
Thanks anyway for your help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.