Solved

PostgreSQL, array value must start with '{'

Posted on 2008-09-30
2
1,136 Views
Last Modified: 2012-05-05
I need to execute the following PostgreSQL statement:
   select ('{'0'}'::varchar[]) as "content", .......
The column content is of type array. It does not exist in this particular table and needs to be initialized.

In the beginning I was getting  "array value must start with '{' ". Then I added curly braces and tried experimenting, but it still does not work. How can the query be fixed?

0
Comment
Question by:msosno
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
Comment Utility
testdb=> select ARRAY['0'] as content;
 content
---------
 {0}
(1 row)
0
 
LVL 22

Expert Comment

by:earth man2
Comment Utility
your curly brackets did not work because you terminate the array constant with the second apostrophe ie before the 0.  Use double quotes within the curly bracket

select x.content[2] from (select '{"0","21","32"}'::text[] as content) as x;
 content
---------
 21
(1 row)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now