Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PostgreSQL, array value must start with '{'

Posted on 2008-09-30
2
Medium Priority
?
1,148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 22

Accepted Solution

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

Expert Comment

by:earth man2
ID: 22618566
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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

715 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