postgresql-9.2

How do i create postgres to oracle dblink?

馋奶兔 提交于 2019-12-09 12:20:09
问题 How do I create dblink in postgres 9.2 ? I want to be able to use it using @ link in oracle? I am using postgres 9.2 64bit. DBlink is from postgres 9.2 to Oracle 11g. 回答1: If you need to access postgresql FROM Oracle: http://dbaspot.wordpress.com/2013/05/29/how-to-access-postgresql-from-oracle-database/ If you need to access Oracle FROM postgresql: http://pgxn.org/dist/oracle_fdw/ 来源: https://stackoverflow.com/questions/18998225/how-do-i-create-postgres-to-oracle-dblink

42501: INSUFFICIENT PRIVILEGE ERROR while querying in Postgresql

社会主义新天地 提交于 2019-12-08 17:02:28
问题 I am trying to query a database table in postgresql, but every time I run the below query it gives me the INSUFFICIENT PRIVILEGE error. What possibly could be the reason for such permission denied error. Also, I am using pgadmin tool in windows to connect the database which is in Linux environment. Below is the query I am running > > SELECT appid,hash > FROM app > WHERE appid=1; While running the same query I am getting the below Error ERROR: permission denied for relation app **********

How do I create a function in PostgreSQL using evolutions in the Play framework?

我们两清 提交于 2019-12-08 16:21:12
问题 With the Play Framework 2.1 I have the following SQL defined in my evolution: CREATE OR REPLACE FUNCTION idx(myArray anyarray, myElement anyelement) RETURNS int AS $$ SELECT i FROM ( SELECT generate_series(array_lower(myArray,1),array_upper(myArray,1)) ) g(i) WHERE myArray[i] = anyElement LIMIT 1; $$ LANGUAGE sql IMMUTABLE; When I execute the evolution, I get the following error: We got the following error: ERROR: unterminated dollar-quoted string at or near "$$ SELECT i FROM ( SELECT

Installing newest version of Rails 4 with Postgres - The PGconn, PGresult, and PGError constants are deprecated

大城市里の小女人 提交于 2019-12-08 15:53:33
问题 I'm not able to find this warning on Google so asking Stackowerflower's help. I want to install Rails 4.2.8 on fresh Centos 7 box. Postgres version is 9.2.18. Ruby version is 2.3.4. When Rails is installed I configure config/database.yml file as usual and pretty sure that database.yml file is ok to connect to DB successfully. Postgres is already running for other apps successfully and fresh role is created for this app. In the next step there is an actual issue: [user@server dir]$ rake db

query a json key in postgres json field

百般思念 提交于 2019-12-08 07:42:33
问题 Say I have in Postgres stored in JSON field called “data” like this { "CUSTA": { "name": "Customer A", }, "CUSTB": { "name": "Customer B", }, "CUSTC": { "name": "Customer C", } } How can I query to return the record that contains the key “CUSTA” ? or even better the value of “CUSTA” which is "name": "Customer A" trying to do something like this but obviously i cant use the keyword key SELECT * FROM invoices WHERE data->>key = 'CUSTA'; 回答1: select '{ "CUSTA": { "name": "Customer A" }, "CUSTB":

Postgres.app upgrade, now Rails app won't start

一曲冷凌霜 提交于 2019-12-07 15:50:07
问题 I just upgraded my Postgres.app to latest version (9.2.4.1) am now unable to start my Rails app using Foreman or Rails server. /Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg.rb:4:in `require': dlopen(/Users/memoht/Sites/myapp/.gem/ruby/1.9.3/gems/pg-0.15.1/lib/pg_ext.bundle, 9): Library not loaded: @executable_path/../lib/libssl.1.0.0.dylib (LoadError) Referenced from: /Applications/Postgres.app/Contents/MacOS/lib/libpq.dylib Reason: image not found - /Users/memoht/Sites

Syntax for row_to_json with sqlalchemy

人走茶凉 提交于 2019-12-07 13:22:51
问题 I would like to figure out how to use Postgres' (9.2) row_to_json with SqlAlchemy. However I haven't been able to come up with any working syntax. details_foo_row_q = select([Foo.*] ).where(Foo.bar_id == Bar.id ).alias('details_foo_row_q') details_foo_q = select([ func.row_to_json(details_foo_row_q).label('details') ]).where(details_foo_row_q.c.bar_id == Bar.id ).alias('details_foo_q') I would ideally like to not to have to type out each and every field from the table model if possible. Got

How to create hibernate criteria with DISTINCT in this case

拜拜、爱过 提交于 2019-12-07 13:08:28
问题 I am using hibernate criteria to create postgres query: criteria.addOrder(Order.asc(property).ignoreCase()).setProjection( Projections.distinct(Projections.property("name"))); which generates sql similar to below: select DISTINCT name from table1 order by lower( name) asc; and when this sql gets executed gives below error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list I know this is something against the postgres rule, but when i looked into the error, i found

alter column from time with time zone to timestamp

痴心易碎 提交于 2019-12-07 10:22:03
问题 I am having trouble changing a column called end_date in a table called key_request from time with time zone to timestamp in my Postgres database . I have tried using the following code: alter table key_request alter column end_date type timestamp with time zone using end_date::timestamp with time zone I keep getting the following error: ERROR: cannot cast type time with time zone to timestamp with time zone Any idea of how I can adjust this query to work? 回答1: I woul do this in a series of

PostgreSQL 9.2.4 (Windows 7) - Service won't start, “could not load pg_hba.conf”

落爺英雄遲暮 提交于 2019-12-06 22:02:44
问题 I am trying to get Postgres 9.2.4 to run as a service on Windows 7. After installing postgres, the service was running fine. However, after setting postgres up as a server for another program, the service stopped running. When I try to start the service now, I get a message saying : "The postgresql-x64-9.2 - PostgreSQL Server 9.2 service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs." When I try running the