postgresql-9.4

How to add a key to a JSON array value?

别来无恙 提交于 2019-12-13 02:42:38
问题 I am new to Postgres and using version 9.4. I have a query returning a json column. How can I add a key to a JSON array value ? My query: select array_to_json(array_agg(t)) from (select DISTINCT ON(city,state)latitudes,longitudes,city,state from zips where city ilike 'ORL%' order by city,state,ziptype desc limit 10) t; The output is like: [{"latitudes": 31.22,"longitudes": -103.91,"city": "Orla","state": "TX"}, ... However, I would like to name it such as: ["Locations": [{"latitudes": 31.22,

couldn't get a connection to the database - Postgres Job Scheduling issued (Windows based machine)

假装没事ソ 提交于 2019-12-12 17:08:18
问题 I search in the internet about this issue. But couldn't find a proper answer. This link is bit closer to the solution, but it is not worked for me. I scheduled a job in pgadmin. but the job is always got failed due to "couldn't get a connection to the database" error. When creating a job using PGAdmin, initially it is asked name, job class, host agent etc... In first stage I left blank for the field "Host Agent". (My schedule works in every minute) PGAdmin right side panel has a tab called

Postgresql user defined c function issues

匆匆过客 提交于 2019-12-12 05:14:40
问题 I have installed postgresql in my ubuntu 14.04 with apt-get command.. postgresql 9.4 libpg 9.4.8 I want to add a user defined c function for dynamic loading. I have my c file and sql function file ready as per specification but main problem is that c file contain header lines like.. #include "postgres.h" #include <string.h> #include "fmgr.h" i have my folder on Desktop but there is no postgers.h or fmgr.h file.. I dont know where to find source file on my system but i have downloaded whole

Using LIKE operator for array of objects inside jsonb field in PostgreSQL

冷暖自知 提交于 2019-12-12 04:18:04
问题 Is it possible to use LIKE operator for single key/value inside array of objects for jsonb field in PostgreSQL 9.4? For example I have: id | body ------------------------------------------------------------ 1 | {"products": [{"name": "qwe", "description": "asd"}, {"name": "zxc", "description": "vbn"}]} I know, I can get a product with something like this: select * from table where 'body'->'products' @> '[{"name": "qwe"}]'::jsonb The question is: can I get this product if I don't know full

PostgreSQL: How to SUM attributes including a JSONB field, and retain table shape?

北城以北 提交于 2019-12-12 04:05:55
问题 I am working with Postgres 9.4. I have a table with a JSONB field: Column │ Type │ Modifiers ─────────────────┼──────────────────────┼──────────────────────────────────────────────────────────────────── id │ integer │ not null default practice_id │ character varying(6) │ not null date │ date │ not null pct_id │ character varying(3) │ astro_pu_items │ double precision │ not null astro_pu_cost │ double precision │ not null star_pu │ jsonb │ I want to retrieve the summed values by date of

POSTGRESQL - ERROR: could not load library pgafis.so : undefined symbol: lfsparms_V2

假装没事ソ 提交于 2019-12-12 03:25:55
问题 I'm using PGAFIS library for fingerprint matching. For this i have installed postgresql and having some user defined c functions. PGAFIS contain makefile, .control file, sql and unpacked sql file everything I have compiled and pgafis.so file for the same and everyfile is on right location. In my PGAdmin-III when i run CREATE EXTENSION pgafis it gives me following error: ERROR: could not load library "/usr/lib/postgresql/9.4/lib/pgafis.so": /usr/lib/postgresql/9.4/lib/pgafis.so: undefined

Postgres - Cent OS. After machine crash, Posgtres Database updated Wrongly using Fsync

醉酒当歌 提交于 2019-12-12 02:36:13
问题 I am using Centos 6 and PostgresSQL 9.4. In my configuration file , fsync and full_page_writes options were enabled. Some point , My machine got crashed and restarted. After that, i checked my database, all the entries are wrongly updated. My entire databse is fully changed. I read about fsync, it will automatically recover the data at consistent point. But why My database is getting wrongly updated???. And also i need which time my postgres server got shutdown and restarted ?? Then which

How generate gap rows between dates in postgresql

浪子不回头ぞ 提交于 2019-12-12 02:19:03
问题 I have a table that store payments. I need to merge the days a payment was made and when not. So I will have something like: DeudaId Date Value 1 2016-01-01 $100 <- This come from a table 1 2016-01-02 $0 <- This was calculated 1 2016-01-03 $0 <- This was calculated 1 2016-01-04 $100 <- This come from a table I have this imperative solution, but is too slow for my case: CREATE OR REPLACE FUNCTION build_dates2() RETURNS TABLE (id INTEGER, cobrador_id INTEGER, fecha DATE) LANGUAGE plpgsql

Rails and Postgresql Migration change column type

孤者浪人 提交于 2019-12-11 14:49:58
问题 I need to change the column type from time to datetime in rails.I cant't change the column type.It show this error "rake aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::DatatypeMismatch: ERROR: column "fun_from" cannot be cast automatically to type timestamp without time zone HINT: Specify a USING expression to perform the conversion. : ALTER TABLE "general_infos" ALTER COLUMN "fun_from" TYPE timestamp/home/PCA/db/migrate/20150730102811_change_data

Exception : org.postgresql.util.PSQLException: ERROR: syntax error at or near “call”

隐身守侯 提交于 2019-12-11 08:45:06
问题 I am working on a application in which hibernate and postgresql and giving the following error org.postgresql.util.PSQLException: ERROR: syntax error at or near "call" Can someone tell me where I am going wrong. I am using Postgres 9.4. HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not get next sequence value type Exception report message Request processing failed; nested exception is org.hibernate.exception