Re: [SQL] How to right justify text in psql?

2013-05-17 Thread Ian Lawrence Barwick
2013/5/18 Brian Sherwood : > I am running postgresql 9.2. > > I am assuming it would be a function of psql to right justify text, but I > can't find any way to do this. > > Is there a way to right justify just one text column? If you mean have the psql client right-justify a particular text column

Re: [SQL] How to right justify text in psql?

2013-05-17 Thread Jov
the column type info can be found in information_schema.column view. jov 在 2013-5-17 下午11:27,"Brian Sherwood" 写道: > I am running postgresql 9.2. > > I am assuming it would be a function of psql to right justify text, but I > can't find any way to do this. > > Is there a way to right justify just

Re: [SQL] How to split an array-column?

2013-03-18 Thread Andreas
Thanks for the pointer. It got me half way. This is the solution: select distinct id, unnest ( string_to_array ( trim ( array_column, ';' ), ';' ) ) from import; Am 18.03.2013 20:24, schrieb Venky Kandaswamy: You can try select id, unnest(array_col) from table __

Re: [SQL] How to split an array-column?

2013-03-18 Thread Venky Kandaswamy
You can try select id, unnest(array_col) from table Venky Kandaswamy Principal Engineer, Adchemy Inc. 925-200-7124 From: pgsql-sql-ow...@postgresql.org [pgsql-sql-ow...@postgresql.org] on behalf of Andrea

Re: [SQL] How to reject overlapping timespans?

2013-02-17 Thread Ben Morrow
Quoth maps...@gmx.net (Andreas): > Am 17.02.2013 19:20, schrieb Andreas Kretschmer: > > Andreas hat am 17. Februar 2013 um 18:02 geschrieben: > >> I need to store data that has a valid timespan with start and enddate. > >> > >> objects ( id, name, ... ) > >> object_data ( object_id referencs objec

Re: [SQL] How to reject overlapping timespans?

2013-02-17 Thread Andreas
Am 17.02.2013 19:20, schrieb Andreas Kretschmer: Andreas hat am 17. Februar 2013 um 18:02 geschrieben: I need to store data that has a valid timespan with start and enddate. objects ( id, name, ... ) object_data ( object_id referencs objects(id), startdate, enddate, ... ) nothing special, yet

Re: [SQL] How to reject overlapping timespans?

2013-02-17 Thread Andreas Kretschmer
Andreas hat am 17. Februar 2013 um 18:02 geschrieben: > Hi, > > I need to store data that has a valid timespan with start and enddate. > > objects ( id, name, ... ) > object_data ( object_id referencs objects(id), startdate, enddate, ... ) > > nothing special, yet > > How can I have PG reject a

Re: [SQL] How to put multiples results in just one column

2013-01-31 Thread Pavel Stehule
2013/1/31 Nei Rauni Santos : > Thank you Pavel, > > I could do that like this: > > > select p.id, > > ( select array_accum (( > room_name, room_id, room_group_name, room_group_id, room_order, > availability_min, price_amount, price_min, price_avg, price_balcony_amount, > price_balcony_avg, capacity

Re: [SQL] How to put multiples results in just one column

2013-01-31 Thread Nei Rauni Santos
Thank you Pavel, I could do that like this: select p.id, ( select array_accum (( room_name, room_id, room_group_name, room_group_id, room_order, availability_min, price_amount, price_min, price_avg, price_balcony_amount, price_balcony_avg, capacity, deposit_required, breakfast_included, room_mi

Re: [SQL] How to put multiples results in just one column

2013-01-31 Thread Pavel Stehule
Hello select (fce(..)).column from ... or select column from fce() Regards Pavel Stehule 2013/1/31 Nei Rauni Santos : > Hi, > > The problem is, I'm working in a list of hotels which should have > availability of rooms and list the hotel and its rooms on the application. > > I have this functio

Re: [SQL] How to access multicolumn function results?

2013-01-23 Thread Tom Lane
Andreas writes: > SELECT some_fct( some_id ) FROM some_other_table; > How can I split this up to look like a normal table or view with the > column names that are defined in the RETURNS TABLE ( ... ) expression of > the function. The easy way is SELECT (some_fct(some_id)).* FROM some_o

Re: [SQL] How to generate drop cascade with pg_dump

2013-01-09 Thread Adrian Klaver
On 01/08/2013 01:53 PM, Emi Lu wrote: Hello, May I know how to generate drop table cascade when pg_dump a schema please? E.g., pg_dump -h db_server -E UTF8 -n schema_name -U schema_owner --clean -d db_name >! ~/a.dmp In a.dmp, I'd like to get: drop table t1 cascade; drop table t2 cascade;

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-13 Thread Igor Neyman
From: saikiran mothe [mailto:saikiran.mo...@gmail.com] Sent: Saturday, November 10, 2012 10:14 PM To: pgsql-sql@postgresql.org Subject: How to compare two tables in PostgreSQL Hi, How can i compare two tables in PostgreSQL. Thanks, Sai Here is simple sql to show data in table1, but not in ta

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Allan Kamau
ad of > creating files and compare them. (got that from Joe Celko ;) ) > > > > -- > Date: Mon, 12 Nov 2012 11:00:32 +0300 > Subject: Re: [SQL] How to compare two tables in PostgreSQL > From: kamaual...@gmail.com > To: pgsql-sql@postgresql.o

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Devrim GÜNDÜZ
Hi, On Sun, 2012-11-11 at 08:43 +0530, saikiran mothe wrote: > How can i compare two tables in PostgreSQL. http://pgfoundry.org/projects/pg-comparator/ Open source, under active development. Regards, -- Devrim GÜNDÜZ Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com Postg

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Willem Leenen
According to Dr Google, this tool may suit your needs: http://www.sqlmanager.net/en/products/postgresql/datacomparer?gclid=CImMsbmLybMCFQRc3godNgQAdQ For business use only $133. Date: Mon, 12 Nov 2012 11:00:32 +0300 Subject: Re: [SQL] How to compare two tables in PostgreSQL From

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Willem Leenen
I would try to stick to SQL solutions as much as possible, instead of creating files and compare them. (got that from Joe Celko ;) ) Date: Mon, 12 Nov 2012 11:00:32 +0300 Subject: Re: [SQL] How to compare two tables in PostgreSQL From: kamaual...@gmail.com To: pgsql-sql@postgresql.org

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-12 Thread Allan Kamau
If you would like to compare their contents perhaps this may help. Write a select statement containing the fields for which you would like to compare data for, you may want to leave out fields whose values are provided by default for example fields populated from sequence object and/or timestamp fi

Re: [SQL] How to compare two tables in PostgreSQL

2012-11-11 Thread Rob Sargentg
On 11/10/2012 08:13 PM, saikiran mothe wrote: Hi, How can i compare two tables in PostgreSQL. Thanks, Sai Compare their content or their definition? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sq

Re: [SQL] How to make this CTE also print rows with 0 as count?

2012-10-06 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of air > Sent: Saturday, October 06, 2012 8:48 AM > To: pgsql-sql@postgresql.org > Subject: [SQL] How to make this CTE also print rows with 0 as count? > > I have a CTE based qu

Re: [SQL] HOw to convert unicode to string

2012-10-01 Thread Jasen Betts
On 2012-09-23, Abhijit Prusty -X (abprusty - UST Global at Cisco) wrote: > --_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hi, > > I have a query in oracle like this mentioned below >

Re: [SQL] How to solve the old bool attributes vs pivoting issue?

2012-06-27 Thread Samuel Gendler
On Wed, Jun 27, 2012 at 7:26 PM, David Johnston wrote: > On Jun 27, 2012, at 21:07, Andreas wrote: > > > You should look and see whether the hstore contrib module will meet your > needs. > > http://www.postgresql.org/docs/9.1/interactive/hstore.html > > hstore is certainly an option, as are the

Re: [SQL] How to solve the old bool attributes vs pivoting issue?

2012-06-27 Thread David Johnston
On Jun 27, 2012, at 21:07, Andreas wrote: > Hi > > I do keep a table of objects ... let's say companies. > > I need to collect flags that express yes / no / don't know. > > TRUE / FALSE / NULL would do. > > > Solution 1: > I have a boolean column for every flag within the companies-table.

Re: [SQL] How to limit access only to certain records?

2012-06-24 Thread Dickson S. Guedes
2012/6/24 Craig Ringer : > As far as I know PostgreSQL does not currently offer native facilities for > row-level access control (except possibly via SEPostgreSQL > http://wiki.postgresql.org/wiki/SEPostgreSQL_Introduction). Yes. Row-level access was in SEPostgreSQL's drafts but after many discuss

Re: [SQL] How to limit access only to certain records?

2012-06-23 Thread Craig Ringer
On 06/22/2012 07:36 PM, Andreas wrote: Hi, is there a way to limit access for some users only to certain records? e.g. there is a customer table and there are account-managers. Could I limit account-manager #1 so that he only can access customers only acording to a flag? What you describe is

Re: [SQL] How to limit access only to certain records?

2012-06-22 Thread hari . fuchs
Andreas writes: > Hi, > > is there a way to limit access for some users only to certain records? > > e.g. there is a customer table and there are account-managers. > Could I limit account-manager #1 so that he only can access customers > only acording to a flag? Maybe something like the followin

Re: [SQL] How to limit access only to certain records?

2012-06-22 Thread Jayadevan M
HI, > > is there a way to limit access for some users only to certain records? > > e.g. there is a customer table and there are account-managers. > Could I limit account-manager #1 so that he only can access customers > only acording to a flag? > > Say I create a relation cu_am ( customer_id,

Re: [SQL] How to limit access only to certain records?

2012-06-22 Thread Jov
no,I think there is no such way. what about create view for the user you want to limit,and revoke select privilege from the base table ? 2012/6/22 Andreas > Hi, > > is there a way to limit access for some users only to certain records? > > e.g. there is a customer table and there are account-ma

Re: [SQL] How to limit access only to certain records?

2012-06-22 Thread Andreas Kretschmer
Andreas wrote: > Hi, > > is there a way to limit access for some users only to certain records? > > e.g. there is a customer table and there are account-managers. > Could I limit account-manager #1 so that he only can access customers > only acording to a flag? Yea, it's possible. Write funct

Re: [SQL] how to use schema with data type

2012-06-12 Thread Craig Ringer
On 06/13/2012 08:46 AM, John Fabiani wrote: I have tried to use a user defined data type I created within a schema. But I could not figure it out. CREATE OR REPLACE FUNCTION xchromasun._chromasun_totals(date) RETURNS SETOF xchromasun.weekly_mpr AS CREATE OR REPLACE FUNCTION xchromasun._chrom

Re: [SQL] How to use hstore

2012-06-04 Thread Jan Eskilsson
Hi Sergey Thats exacly what i was looking for, thanks a million ! Best regards Jan Eskilsson 2012/6/5 Sergey Konoplev : > On Mon, Jun 4, 2012 at 4:08 PM, Jan Eskilsson wrote: >> My problem is that i would like to be able to retrieve a group of >> records from the hstore table and present them

Re: [SQL] How to use hstore

2012-06-04 Thread Sergey Konoplev
On Mon, Jun 4, 2012 at 4:08 PM, Jan Eskilsson wrote: > My problem is that i would like to be able to retrieve a group of > records from the hstore table and present them in a grid so I would > like to convert the hstore records back to the original table format. > In the manual i found an example

Re: [SQL] How to group by similarity?

2012-04-24 Thread Trinath Somanchi
Hi- With respect similarity, its a costly operation on CPU based on the cycles of checking the keyword. Two words are said to be similar when atleast 2 or more consecutive characters are at the same. The more the consecutive characters are the same the more level of similarity. It would look sim

Re: [SQL] How to html-decode a html-encoded field

2012-04-12 Thread Jasen Betts
On 2012-04-10, JORGE MALDONADO wrote: > --000e0ce0d2ee43edb104bd553408 > Content-Type: text/plain; charset=ISO-8859-1 > > I have a table with a varchar field, such a field is HTML ENCODED. So, for > example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE > T''S" (double quotes are not part

Re: [SQL] How to html-decode a html-encoded field

2012-04-10 Thread Pavel Stehule
Hello see http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#Function_for_decoding_of_url_code Regards Pavel Stehule 2012/4/10 JORGE MALDONADO : > I have a table with a varchar field, such a field is HTML ENCODED. So, for > example, the string "PLAIN WHITE T'S" is saved as "PLAIN WHITE T''S" > (dou

Re: [SQL] how to write cursors

2012-04-04 Thread Pavel Stehule
Hello use a refcursors http://www.postgresql.org/docs/9.1/static/plpgsql-cursors.html Regards Pavel Stehule 2012/4/4 La Chi : > hi every one > > i have created this simple function which returns a column of table , i have > used simple SELECT statement , i simply want to know how can i achieve

Re: [SQL] how to concatenate in PostgreSQL

2012-03-27 Thread Steve Crawford
, March 26, 2012 9:08 PM *Subject:* Re: [SQL] how to concatenate in PostgreSQL On 03/24/2012 04:43 AM, Rehan Saleem wrote: hi , how can we concatinate these lines and execute sql command In what? Psql? A PL/pgSQL function. C/Java/PHP/Python/Perl/Erlang/Lua? setsql = 'select user,use

Re: [SQL] how to concatenate in PostgreSQL

2012-03-26 Thread Steve Crawford
On 03/24/2012 04:43 AM, Rehan Saleem wrote: hi , how can we concatinate these lines and execute sql command In what? Psql? A PL/pgSQL function. C/Java/PHP/Python/Perl/Erlang/Lua? setsql = 'select user,username, firstname ' set sql += ' lastname, cardno from table1 where userid=' +

Re: [SQL] how to concatenate in PostgreSQL

2012-03-26 Thread Robins Tharakan
Hi, Probably you're looking for these set of articles. http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#Microsoft_SQL_Server The second article (by Ethan) has good small hints for things such as the query that you ask in this thread, when migrating from MSSQL to P

Re: [SQL] how to concatenate in PostgreSQL

2012-03-24 Thread Allan Kamau
On 3/24/12, Andreas Kretschmer wrote: > Rehan Saleem wrote: > >> hi , >> how can we concatinate these lines and execute sql command >> >>set sql = 'select user,username, firstname ' >> set sql += ' lastname, cardno from table1 where userid=' + 5 > > sql = sql || ' bla fasel'; > > ||

Re: [SQL] how to concatenate in PostgreSQL

2012-03-24 Thread Andreas Kretschmer
Rehan Saleem wrote: > hi , > how can we concatinate these lines and execute sql command > >set sql = 'select user,username, firstname ' > set sql += ' lastname, cardno from table1 where userid=' + 5 sql = sql || ' bla fasel'; || is the concat - Operator. Andreas -- Really, I

Re: [SQL] How To Create Temporary Table inside a function

2012-03-02 Thread Samuel Gendler
On Fri, Mar 2, 2012 at 3:49 AM, Philip Couling wrote: > Hi Rehan > > I suggest attempting to drop the table before you create the temp table: > DROP TABLE IF EXISTS table1; > > See: > http://www.postgresql.org/docs/current/static/sql-droptable.html > > > Also if you're using an actual TEMP table,

Re: [SQL] How to shrink database in postgresql

2012-03-02 Thread Mario Marín
2012/2/29 Pavel Stehule : > Hello > > the most similar tool in pg is "VACUUM FULL" statemet; Hello, From: http://wiki.postgresql.org/wiki/VACUUM_FULL "Many people, either based on misguided advice on the 'net or on the assumption that it must be "better", periodically run VACUUM FULL on their tab

Re: [SQL] How To Create Temporary Table inside a function

2012-03-02 Thread Philip Couling
Hi Rehan I suggest attempting to drop the table before you create the temp table: DROP TABLE IF EXISTS table1; See: http://www.postgresql.org/docs/current/static/sql-droptable.html Also if you're using an actual TEMP table, PostgreSQL can automatically drop the table or just empty it once the t

Re: [SQL] How to shrink database in postgresql

2012-02-29 Thread Pavel Stehule
Hello the most similar tool in pg is "VACUUM FULL" statemet; Regards Pavel Stehule 2012/2/29 Rehan Saleem : > hi , > how can i shrink database in postgresql here is a MS-SQL store procedure > which shrinks the database. how same task can be achieved in postgresql. > > ALTER PROCEDURE [dbo].[sp_

Re: [SQL] How to convert SQL store procedure to Postgresql function

2012-02-28 Thread Leif Biberg Kristensen
Tirsdag 28. februar 2012 12.56.46 skrev Rehan Saleem : > hi , > whats wrong with this function , i am getting syntax error which is syntax > error at or near "+=" LINE 13: set sql += ' bpoverlap, centredistance You can't concatenate that way in plpgsql. Instead of "set sql +=" try with just "||

Re: [SQL] How to convert SQL store procedure to Postgresql function

2012-02-28 Thread Rehan Saleem
ce<>'') set sql += ' and (centredistance<=' + centre_distance + ' or ' + centre_distance + '=1) ' set sql += ' order by chr_u, start_u' exec(sql) end; $BODY$ language plpgsql; Fr

Re: [SQL] How to convert SQL store procedure to Postgresql function

2012-02-28 Thread Rehan Saleem
; $BODY$ language plpgsql; From: Filip Rembiałkowski To: Rehan Saleem Cc: "pgsql-sql@postgresql.org" Sent: Tuesday, February 28, 2012 3:36 PM Subject: Re: [SQL] How to convert SQL store procedure to Postgresql function On Tue, Feb 28, 2012 at

Re: [SQL] How to convert SQL store procedure to Postgresql function

2012-02-28 Thread Filip Rembiałkowski
On Tue, Feb 28, 2012 at 9:50 AM, Rehan Saleem wrote: > hi , > how can i convert this sql store procedure to postgresql function , i shall > be very thankful to you, as i am new to postgresql and i dont know how to > handle this kind of store procedure in postgresql Most people handle this with u

Re: [SQL] How to split up phone numbers?

2012-02-23 Thread Jasen Betts
On 2012-02-20, Andreas wrote: > Hi, > is there a way to split up phone numbers? several. I wouldn't trust a computer to do any of them. > I know that's a tricky topic and it depends on the national phone number > format. > I'm especially interested in a solution for Germany, Swizerland and Aust

Re: [SQL] How to split up phone numbers?

2012-02-21 Thread Tim Landscheidt
(anonymous) wrote: > is there a way to split up phone numbers? > I know that's a tricky topic and it depends on the national > phone number format. > I'm especially interested in a solution for Germany, Swizerland and Austria. > I've got everything in a phone number column that makes hardly sense

Re: [SQL] How to split up phone numbers?

2012-02-20 Thread Filip Rembiałkowski
At 2012-02-20 15:50, Andreas wrote: Hi, is there a way to split up phone numbers? I know that's a tricky topic and it depends on the national phone number format. I'm especially interested in a solution for Germany, Swizerland and Austria. I've got everything in a phone number column that mak

Re: [SQL] How to Return Table From Function

2012-01-22 Thread Rob Sargentg
On 01/22/2012 06:09 AM, Rehan Saleem wrote: hi , i have created this function CREATE OR REPLACE FUNCTION totaloverlapcount(user_id integer , bg integer ,center_distance integer) RETURNS varchar AS $$ DECLARE percentage record; BEGIN select fname, lname, count(userid) totalcount ,100.00*co

Re: [SQL] How to Return Table From Function

2012-01-22 Thread Pavel Stehule
Hello 2012/1/22 Rehan Saleem : > hi , i have created this function > > CREATE OR REPLACE FUNCTION totaloverlapcount(user_id integer , bg integer > ,center_distance integer) > RETURNS varchar AS $$ > > DECLARE percentage record; > BEGIN > > > > select fname, lname, count(userid) totalcount > ,100.0

Re: [SQL] how to return whole table from Function not just the id integer column

2012-01-19 Thread Samuel Gendler
On Thu, Jan 19, 2012 at 1:57 AM, Rehan Saleem wrote: > hi , > > how can i return the whole user table from this function not just the id . > thanks > > Chapter 39, specifically 39.3, of the postgresql documentation provides all of the information necessary to answer this question. If, after rea

Re: [SQL] How to implement Aggregate Awareness?

2011-11-07 Thread Little, Douglas
- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Olgierd Michalak Sent: Monday, November 07, 2011 1:25 PM To: Craig Ringer Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] How to implement Aggregate Awareness? > Simply put, when Transparent (to the re

Re: [SQL] How to implement Aggregate Awareness?

2011-11-07 Thread Olgierd Michalak
> Simply put, when Transparent (to the reporting tool) Aggregate Navigator > recognizes that a query would execute faster using aggregates, it > automatically rewrites the query so that the database hits the smaller > aggregates rather than larger detail tables upon which the small > aggregates are

Re: [SQL] How to implement Aggregate Awareness?

2011-11-05 Thread Craig Ringer
On 11/05/2011 05:03 AM, Olgierd Michalak wrote: Simply put, when Transparent (to the reporting tool) Aggregate Navigator recognizes that a query would execute faster using aggregates, it automatically rewrites the query so that the database hits the smaller aggregates rather than larger detail t

Re: [SQL] how to use explain analyze

2011-10-27 Thread Brent Dombrowski
On Oct 25, 2011, at 7:12 AM, alan wrote: > I'm new to postgres and was wondering how to use EXPLAIN ANALYZE > > Can I use the output from ANALYZE EXPLAIN to estimate or predict the > actual time > it would take for a given query to return? > > I ask because I'm writing a typical web app tha

Re: [SQL] How to write sql to access another odbc source.

2011-10-25 Thread Craig Ringer
On 19/10/11 22:08, Rich wrote: > I have a mumps database with an ODBC connection so I can write queries > from other databases. How can I write a sql in Postgresql to access > this table to use in my Postgresql reports? Use dbi-link to make an ODBC connection to the other database. Either copy th

Re: [SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Craig Ringer
On 10/21/2011 09:36 PM, Emi Lu wrote: Good morning, Is there a way to temporally disabled foreign key constraints something like SET FOREIGN_KEY_CHECKS=0 When population is done, will set FOREIGN_KEY_CHECKS=1 If you really, really want to do this you can do it by disabling the triggers tha

Re: [SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Thomas Kellerer
Emi Lu wrote on 21.10.2011 15:36: Good morning, Is there a way to temporally disabled foreign key constraints something like SET FOREIGN_KEY_CHECKS=0 When population is done, will set FOREIGN_KEY_CHECKS=1 Thanks a lot! Emi You can define the FKs as "DEFERRABLE INITIALLY IMMEDIATE". Then a

Re: [SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Emi Lu
Not really, sorry :( What I am looking for is no DB structure changes. But only disabling foreign key constraint check/verify for period of time and then recover it. Similar to mysql's "set FOREIGN_KEY_CHECKS = true/false" Emi On 10/21/2011 10:58 AM, Oliveiros d'Azevedo Cristina wrote: S

Re: [SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Oliveiros d'Azevedo Cristina
Something like ALTER TABLE t_yourtable DROP CONSTRAINT and then ALTER TABLE t_yourtable ADD FOREIGN KEY ? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Friday, October 21, 2011 2:36 PM Subject: [SQL] how to temporally disable foreign key constraint check Good m

Re: [SQL] How to write query to access another odbc source

2011-10-19 Thread Rich
I have references to dblink. I just installed 9.1.1.1 on windows server 2008 R2 and did a search on the file dblink.sql and cannot find it. I used the one click installer from enterprisedb. 1. Where is the dblink.sql file or does it not exist anymore and the integration into postgresql has chan

Re: [SQL] How to write query to access another odbc source

2011-10-19 Thread pasman pasmański
Hi. If you have 9.1, then exist foreign wrapper odbc_fdw, you may try it. 2011/10/19, Rich : >> >> I have a mumps database with an ODBC connection so I can write queries >> from >> this database. How can I write a sql in Postgresql to access this >> database >> to use in my Postgresql reports? >

Re: [SQL] How to write query to access another odbc source

2011-10-19 Thread Scott Marlowe
On Wed, Oct 19, 2011 at 9:19 AM, Rich wrote: >> I have a mumps database with an ODBC connection so I can write queries >> from this database.  How can I write a sql in Postgresql to access this >> database to use in my Postgresql reports? dblink lets one pg server access another via SQL, dbilink

Re: [SQL] how to calculate differences of timestamps?

2011-09-27 Thread Steve Crawford
On 09/26/2011 06:31 PM, Andreas wrote: How could I calculate differences of timestamps in a log-table? Table log ( user_id integer, login boolean, ts timestamp ) So login = true would be a login-event and login = false a logout. Is there a way to find the matching login/logout to calculate the

Re: [SQL] how to calculate differences of timestamps?

2011-09-26 Thread Tim Landscheidt
(anonymous) wrote: > How could I calculate differences of timestamps in a log-table? > Table log ( user_id integer, login boolean, ts timestamp ) > So login = true would be a login-event and login = false a logout. > Is there a way to find the matching login/logout to > calculate the difference?

Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Andreas
Am 01.07.2011 04:17, schrieb Tim Landscheidt: besides the regexp_replace() solution mentioned by Charlie and Steve, you can also use TRANSLATE(): | tim=# SELECT TRANSLATE('a{b''c"d!f', '{}()''",;.:!', ''); nice, 2 solutions for 1 problem. :) my replace...replace... was a wee bit tedious ;)

Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Tim Landscheidt
(anonymous) wrote: > how can I remove a set of characters in text-columns ? > Say I'd like to remove { } ( ) ' " , ; . : ! > Of course I can chain replace ( replace ( replace ( replace > ( ... , '' ) and replace the chars one by one against > an empty string ''. > There might be a more elega

[SQL] Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Charlie
Would regexp_replace(src_str, '[\{\}\[\]\(\)\.', '') at http://www.postgresql.org/docs/9.0/static/functions-string.html help? - Reply message - From: "Andreas" Date: Thu, Jun 30, 2011 4:28 pm Subject: [SQL] How to remove a set of characters in text-columns ? To: Hi, how can I re

Re: [SQL] How to remove a set of characters in text-columns ?

2011-06-30 Thread Steve Crawford
On 06/30/2011 12:28 PM, Andreas wrote: Hi, how can I remove a set of characters in text-columns ? Say I'd like to remove { } ( ) ' " , ; . : ! Of course I can chain replace ( replace ( replace ( replace ( ... , '' ) and replace the chars one by one against an empty string ''. There might

Re: [SQL] How to realize ROW_NUMBER() in 8.3?

2011-05-03 Thread Andreas Kretschmer
Emi Lu wrote: > Thank you for the info. > > I found a simple way: > == > [1] create SEQUENCE tmp start 7820; > [2] > insert into desti_table_name > select nextval('tmp'), >c1, c2... ... cN > from t1 left join t2... ... tn > where ... ... > > Jus

Re: [SQL] How to realize ROW_NUMBER() in 8.3?

2011-05-03 Thread Emi Lu
Thank you for the info. I found a simple way: == [1] create SEQUENCE tmp start 7820; [2] insert into desti_table_name select nextval('tmp'), c1, c2... ... cN from t1 left join t2... ... tn where ... ... Just for people using 8.3, this is mimic r

Re: [SQL] How to realize ROW_NUMBER() in 8.3?

2011-04-20 Thread Oliveiros d'Azevedo Cristina
If your table is not terribly big, you can try something like SELECT a.col1,a.col2, COUNT(*) as row_number FROM yourTable a,yourTable b WHERE a.col1 >= b.col1 -- I'm assuming col1 is primary key GROUP BY a.col1,a.col2 ORDER BY row_number This is pure SQL, should work in every version... Bes

Re: [SQL] How to realize ROW_NUMBER() in 8.3?

2011-04-20 Thread Vibhor Kumar
On Apr 20, 2011, at 9:15 PM, Emi Lu wrote: > ROW_NUMBER() is only ready in 8.4. For 8.3, is there a simple way to get > row_number > select row_number(), col1, col2... > FROM tableName Following is a link of deepsz which has a way of implementation of rownum. http://www.depesz.com/index.php/

Re: [SQL]How to transform table rows into Colum?

2011-03-17 Thread Richard Albright
you can also generate a crosstab table using the sign function you can check out the link below ( its a sqlite tutorial, but the same idea will work for pg too ) http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html On 03/09/2011 12:16 PM, Eric Ndengang wrote: Hi Guys, I have the fo

Re: [SQL]How to transform table rows into Colum?

2011-03-09 Thread Dmitriy Igrishin
Hey Eric, 2011/3/9 Eric Ndengang > Hi Guys, > I have the following table: > > Name Value rang salary > > name1 value1 12500 > name2 value2 22600 > name3 value 3 3300 > > and want to obtain the following result: > > name1 name2 name3

Re: [SQL] How to checking the existance of constraints for a table?

2011-02-04 Thread bricklen
On Wed, Feb 2, 2011 at 12:40 PM, creationw wrote: > > Hello, > > I have a sample table describe as follows, anyone knows how to checking the > existence of a constraint? > > oviddb=# \d myTable > >  Column  |   Type   | Modifiers > -+--+--- >  orderid | smallint | not null

Re: [SQL] How to workaround DROP CONSTRAINT [ IF EXISTS ] in Postgres version 8.1?

2011-02-04 Thread Viktor Bojović
use function which searches through this tables: -pg_constraint -pg_trigger On Wed, Feb 2, 2011 at 11:21 PM, creationw wrote: > > Hello, > > > I found that DROP CONSTRAINT [ IF EXISTS ] is available in Postgres 9.1 > http://developer.postgresql.org/pgdocs/postgres/sql-altertable.html > http://de

Re: [SQL] how to get row number in select query

2011-01-31 Thread Emi Lu
Ok, before 8.4, there I can use row_number(). For 8.3 + display tag + order by integer + paging based on pageBean ArrayList alist; In Bean.java, added: private int rec_num; in main .action java: for(int i=0 ; i Piotr Czekalski, 27.01.2011 16:21: Gentelmen, I follow this thread and I don't

Re: [SQL] how to get row number in select query

2011-01-27 Thread Thomas Kellerer
Piotr Czekalski, 27.01.2011 16:21: Gentelmen, I follow this thread and I don't exactly get an idea of yours, but isn't is as simple as (example: table "web.files" contains one column named "fileurl" ): select row_number() over(), X.fileurl from (select fileurl from web.files order by fileurl) X

Re: [SQL] how to get row number in select query

2011-01-27 Thread Piotr Czekalski
Gentelmen, I follow this thread and I don't exactly get an idea of yours, but isn't is as simple as (example: table "web.files" contains one column named "fileurl" ): select row_number() over(), X.fileurl from (select fileurl from web.files order by fileurl) X The only disadvantage is that

Re: [SQL] how to get row number in select query

2011-01-27 Thread Oliveiros d'Azevedo Cristina
Hi Oliveiros, Howdy! If it is to order in ascendent fashion by, say, lname, one possibility would be SELECT COUNT(b.*) as row_number, a.lname,a.gname FROM "Table1" a, "Table2" b WHERE a.lname >= b.lname GROUP BY a.lname,a.gname ORDER BY row_number If you want to order by gname just chang

Re: [SQL] how to get row number in select query

2011-01-27 Thread Emi Lu
Hi Oliveiros, If it is to order in ascendent fashion by, say, lname, one possibility would be SELECT COUNT(b.*) as row_number, a.lname,a.gname FROM "Table1" a, "Table2" b WHERE a.lname >= b.lname GROUP BY a.lname,a.gname ORDER BY row_number If you want to order by gname just change the WHERE c

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
If it is to order in ascendent fashion by, say, lname, one possibility would be SELECT COUNT(b.*) as row_number, a.lname,a.gname FROM "Table1" a, "Table2" b WHERE a.lname >= b.lname GROUP BY a.lname,a.gname ORDER BY row_number If you want to order by gname just change the WHERE clause according

Re: [SQL] how to get row number in select query

2011-01-26 Thread Oliveiros d'Azevedo Cristina
Hi, Lu Ying. How do you define which row is #1 ? And #2 ? E.g. Ordered by lname? Or gname...? Best, Oliveiros - Original Message - From: "Emi Lu" To: Sent: Wednesday, January 26, 2011 4:11 PM Subject: [SQL] how to get row number in select query Good morning, For postgresql 8.3

Re: [SQL] How to convert string to integer

2010-12-15 Thread Viktor Bojović
On Wed, Dec 15, 2010 at 11:23 AM, venkat wrote: > Dear All, > > How do i convert string to int > > select SUM(pan_1) from customers1 where name='101' > > When i run the above query i m getting "function sum(character varying) > does not exist".. > > Please anyone can guide me.. > > Thanks > >

Re: [SQL] How to convert string to integer

2010-12-15 Thread Pavel Stehule
Hello you can use a ::int for converting to integer. Or better - you can alter column to integer. It will be faster and more correct. Regards Pavel Stehule 2010/12/15 venkat : > Dear All, >   How do i convert string to int > select SUM(pan_1) from customers1 where name='101' > When i run the ab

Re: [SQL] How to Convert Integer to Serial

2010-10-28 Thread venkat
ohhh,, sorry... It was wrong post..sorry again... On Fri, Oct 29, 2010 at 10:30 AM, Shoaib Mir wrote: > On Fri, Oct 29, 2010 at 3:48 PM, venkat wrote: > >> Dear All, >> >> I want to convert integer datatype to serial datatype.. is that >> possible.Please let me know. >> >> > I don't think ALT

Re: [SQL] How to Convert Integer to Serial

2010-10-28 Thread Shoaib Mir
On Fri, Oct 29, 2010 at 3:58 PM, venkat wrote: > Dear All, > > I got the solution... Here is my query > > ALTER TABLE DemoTable ALTER gid TYPE INT2; > > > Are you sure that you have converted here to a SERIAL type? -- Shoaib Mir http://shoaibmir.wordpress.com/

Re: [SQL] How to Convert Integer to Serial

2010-10-28 Thread Shoaib Mir
On Fri, Oct 29, 2010 at 3:48 PM, venkat wrote: > Dear All, > > I want to convert integer datatype to serial datatype.. is that > possible.Please let me know. > > I don't think ALTER TABLE will let you do that... so the best way to achieve the same is: - Create a sequence for the column (set th

Re: [SQL] How to Convert Integer to Serial

2010-10-28 Thread venkat
Dear All, I got the solution... Here is my query ALTER TABLE DemoTable ALTER gid TYPE INT2; Thanks again On Fri, Oct 29, 2010 at 10:18 AM, venkat wrote: > Dear All, > > I want to convert integer datatype to serial datatype.. is that > possible.Please let me know. > > Thanks and Rega

Re: [SQL] How to search for a part of a number

2010-10-25 Thread Harald Fuchs
In article <4cc4d3e2.7090...@gmx.net>, Andreas writes: > Hi, > I'm wondering if there was a clever way to find parts of a numeric > string in another table. > There is a table that holds city-codes and city-names. City-code would > be the part of a phone number that identifies the city. > Over he

Re: [SQL] How to collect text-fields from multiple rows ?

2010-10-16 Thread Thomas Kellerer
Andreas wrote on 16.10.2010 05:23: Hi, how can I collect text-fields from multiple rows into one output row? I'd like to do an equivalent to the aggregate function SUM() only for text. The input is a select that shows among other things a numerical column where I would like to group by. The te

Re: [SQL] How to get geometry enabled Tables form Postgresql/postgis

2010-07-29 Thread venkat
Dear Lee, Perfect Its working fine Thanks alot.. Thanks and Regards, Venkat On Fri, Jul 30, 2010 at 1:43 AM, Lee Hachadoorian < lee.hachadoor...@gmail.com> wrote: > All geometric columns in all spatially enabled tables appear in the table > public.geometry_columns, defined as: > > CRE

Re: [SQL] How to get geometry enabled Tables form Postgresql/postgis

2010-07-29 Thread Lee Hachadoorian
All geometric columns in all spatially enabled tables appear in the table public.geometry_columns, defined as: CREATE TABLE public.geometry_columns (   f_table_catalog character varying(256) NOT NULL,   f_table_schema character varying(256) NOT NULL,   f_table_name character varying(256) NOT N

Re: [SQL] how to escape _ in select

2010-07-29 Thread Thomas Kellerer
Wes James, 28.07.2010 19:35: I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't working. ( http://www.postgresql.org/docs/8.3/static/functions-matching.html ) The text bet

Re: [SQL] how to escape _ in select

2010-07-28 Thread Dmitriy Igrishin
Hey James, Because in future releases the default value of the "standard_conforming_strings" parameter will change to "on" for improved standards compliance. You should use string constants with C-Style escapes. Please, see http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNT

  1   2   3   4   5   6   7   8   9   >