I have the following data: ID CLASS VALUE 1 NHB 700905.7243 1 HBW 164216.1311 1 HBO 700905.7243 2 NHB 146023.3792 2 HBW 89543.2972 2 HBO 82152.072 3 NHB 1409818….
Tag: postgresql
Why isn’t SQLAlchemy creating serial columns?
SQLAlchemy is generating, but not enabling, sequences for columns in postgresql. I suspect I may be doing something wrong in engine setup. Using an example from the SQLAlchemy tutorial (http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html): With this script, the following table is generated: However, a seq…
How to do a batch commit in plpgsql?
When I do the below function, some errors occurs: Here is my sample code. So could anyone give me a sample of how to finish my job as the above code? I’m using PostgreSQL 9.2. Answer In general, I think there are three approaches you can take: Do without. Just let the whole thing be committed at once, l…
Postgres Error: More than one row returned by a subquery used as an expression
I have two separate databases. I am trying to update a column in one database to the values of a column from the other database: UPDATE customer SET customer_id= (SELECT t1 FROM dblink(‘port=5432, …
Postgres syntax error at or near “IF”
I am new to postgres and I am working on an assignment of mine. I had to create a table with only 1 column and, then I was given this statement to run in on pgadmin III: when I run this I get this error: syntax error at or near “IF” I have already take a look at this 38.6.2.
Optimize performance for queries on recent rows of a large table
I have a large table: CREATE TABLE “orders” ( “id” serial NOT NULL, “person_id” int4, “created” int4, CONSTRAINT “orders_pkey” PRIMARY KEY (“id”) ); 90% of all requests are about orders from the …
Postgres time with time zone equality
I’m having some trouble with time with time zone equalities in Postgres. timestamp with time zone equality works how I would expect it to, where if the times are the same after normalizing the …
Order By Date ASC with Spring Data
I try to make an application with Spring-Data-JPA on a table in order by ASC but it gives me an error: Invalid derived query! No property asc found for type java.util.Calendar Why ? List …
Concatenate string in statement that assigns a variable in PostgreSQL
I am trying to convert SQL Server procedure to PostgreSQL. In the SQL Server procedure There are statements like below SET @val = ‘(‘ + @someval + ‘)’ So in postgresql I wrote as below SET val …
Insert multiple rows in one table based on number in another table
I am creating a database for the first time using Postgres 9.3 on MacOSX. Let’s say I have table A and B. A starts off as empty and B as filled. I would like the number of entries in column all_names in table B to equal the number for each names in table A like table B below. Thus names