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

[SQL] How to right justify text in psql?

2013-05-17 Thread 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? Thanks Brian

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

2013-03-18 Thread Andreas
:13 PM To: pgsql-sql@postgresql.org Subject: [SQL] How to split an array-column? Hi, I've got a table to import from csv that has an array-column like: import ( id, array_col, ... ) Those arrays look like ( 42, ";4941;4931;4932", ... ) They can have 0 or any number of elements separated b

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

2013-03-18 Thread Venky Kandaswamy
Andreas [maps...@gmx.net] Sent: Monday, March 18, 2013 12:13 PM To: pgsql-sql@postgresql.org Subject: [SQL] How to split an array-column? Hi, I've got a table to import from csv that has an array-column like: import ( id, array_col, ... ) Those arrays look like ( 42, ";4941;4931;4932&qu

[SQL] How to split an array-column?

2013-03-18 Thread Andreas
Hi, I've got a table to import from csv that has an array-column like: import ( id, array_col, ... ) Those arrays look like ( 42, ";4941;4931;4932", ... ) They can have 0 or any number of elements separated by ; So I'd need a result like this: 42, 4941 42, 4931 42, 4932 How would I get this?

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

[SQL] How to reject overlapping timespans?

2013-02-17 Thread Andreas
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 data record where the new start- or enddate lies between the start- or

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

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

2013-01-31 Thread 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 function which already is used to get the rooms available select cms.sp_get_supplier_availability(2, '2013-02-01', '2013-02-02', 'pt_BR', 1

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

[SQL] How to access multicolumn function results?

2013-01-23 Thread Andreas
Hi I've got functions that return a TABLE. If I call it with constant parameters like: SELECT * FROM some_fct( 42 ); I get a table with column names as the result as intended. When I rather call it with the parameter coming from another table I get a set of records where I don't know how to a

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;

[SQL] How to generate drop cascade with pg_dump

2013-01-08 Thread Emi Lu
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; ... ... Only dropping constraints wi

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

[SQL] How to compare two tables in PostgreSQL

2012-11-11 Thread saikiran mothe
Hi, How can i compare two tables in PostgreSQL. Thanks, Sai

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? >

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

2012-10-06 Thread air
I have a CTE based query, to which I pass about 2600 4-tuple latitude/longitude values using joins - these latitude longitude 4-tuples have been ID tagged and held in a second table called coordinates. These top left and bottom right latitude / longitude values are passed into the CTE in order to d

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 >

[SQL] HOw to convert unicode to string

2012-09-24 Thread Abhijit Prusty -X (abprusty - UST Global at Cisco)
Hi, I have a query in oracle like this mentioned below Insert into TEST (TEMPLATE_ID, TEMPLATE_NAME, CREATED_BY, CREATED_DT, UPDATED_BY, UPDATED_DT, TEMPLATE_KEY) Values (1, UNISTR('\D3C9\BA85\B3C4 \B514\C2A4\D50C\B808\C774'), 'dmin', SYSDATE, 'admin', SYSDATE ,'FLOOR'); Now the o

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.

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

2012-06-27 Thread Andreas
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. Whenever I need an additional flag I'll add another column. This

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

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

2012-06-22 Thread 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-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, account_manage

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

[SQL] how to use schema with data type

2012-06-12 Thread John Fabiani
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._chromasun_totals(date) RETURNS SETOF "xchromasu

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

[SQL] How to use hstore

2012-06-04 Thread Jan Eskilsson
Hi all I log data in a table using a hstore field. 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 how to c

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

[SQL] How to group by similarity?

2012-04-24 Thread Andreas
Hi, I'm trying to get an idea about pg_trgrm. I created a GIST index on a text column in a table. Now I can filter the table with similarity(). How would I group the table so that it shows groups that have similarity () > x ? Lets say the table looks like this: id, txt 1, aa1 2, bb1 3,

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

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

2012-04-10 Thread 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" (double quotes are not part of the string, I use them for clarity only). I need to perform a SELECT statement on this table and get the values HTML DECODED

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

[SQL] how to write cursors

2012-04-04 Thread 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 the same task with the help of cursor CREATE OR REPLACE FUNCTION foo(id int) returns table(cust_id int) as $BODY$ BEGIN         retur

[SQL] How to write cursors

2012-04-03 Thread La Chi
Hello everyone, i have created this function in which i simply want to display a column values through a cursor , but unfortunately i am not getting the column values , this function is showing me simple column name but not the  fields in column. CREATE OR REPLACE FUNCTION foo(id int) returns t

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

[SQL] how to concatenate in PostgreSQL

2012-03-24 Thread Rehan Saleem
hi , how can we concatinate these lines and execute sql command          setsql ='select user,username, firstname '   set sql +=' lastname, cardno from table1where userid='+ 5   exec(sqi)      where 5 is the userid from table1 thanks

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

[SQL] How To Create Temporary Table inside a function

2012-03-02 Thread Rehan Saleem
hi everyone , how can i create temp table say table1 with three column of types varchar , int and int, inside the function body and if that same table already exist it should drop that already existing table(table1) , and on every run this process should run. and how can i insert values from pos

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_

[SQL] How to shrink database in postgresql

2012-02-29 Thread 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_CleanUpDB] AS declare @db nvarchar(50) select @db = db_name() DBCC SHRINKDATABASE (@db, 10) thanks

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

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

2012-02-28 Thread Rehan Saleem
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 thanks ALTERPROCEDURE [dbo].[sp_GetUserByID]   @UserId varchar(50),   @KBId  varch

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

[SQL] How to split up phone numbers?

2012-02-20 Thread Andreas
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 makes hardly sense like: +49432156780 004

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

[SQL] How to Return Table From Function

2012-01-22 Thread 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.00*count(useriddetails)/totaluser into percentage

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

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

2012-01-19 Thread Rehan Saleem
hi , how can i return the whole user table from this function not just the id . thanks CREATE TABLE users(id serial PRIMARY KEY, first_name varchar(10), last_name varchar(10)); CREATE OR REPLACE FUNCTION new_user(fname varchar, lname varchar) RETURNS int AS $$ DECLARE r int; BEGIN -- custom except

[SQL] How to implement Aggregate Awareness?

2011-11-10 Thread Olgierd Michalak
I wonder how to implement Aggregate Awareness or Transparent Aggregate Navigation in PostgreSQL? 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

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

[SQL] How to implement Aggregate Awareness?

2011-11-04 Thread Olgierd Michalak
I wonder how to implement Aggregate Awareness or Transparent Aggregate Navigation in PostgreSQL? 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

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

[SQL] How to obtain a coalesce aggregation in a GROUP BY query?

2011-10-27 Thread Federico Dal Maso
I need write a query like this select coalesce_agg(col order by col asc) from some_table group by other_col clearly the col column is nullable. which is the best way (in terms of performance too) to obtain this? Are there any built-in aggregate function or should I write a new aggregate function

[SQL] how to use explain analyze

2011-10-27 Thread alan
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 that allows the user to build and submit a query to my DB.

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

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

2011-10-25 Thread Rich
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?

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
evedo Cristina wrote: 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 co

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 che

[SQL] how to temporally disable foreign key constraint check

2011-10-21 Thread Emi Lu
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 -- Emi Lu, ENCS, Concordia University, Montreal H3G 1M8 em...@encs.concordia.ca+1 514 848-242

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

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

2011-10-19 Thread 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 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?

  1   2   3   4   5   6   7   8   9   10   >