Re: [SQL] Help needed with Window function

2013-10-03 Thread Akihiro Okuno
> This is an approach I also considered, but hoped for a solution without the > expense (albeit small) of having to create a function. How about this query? CREATE TABLE transactions ( item_code text, _date date, qty double precision ) ; INSERT INTO transaction

Re: [SQL] Help needed with Window function

2013-10-02 Thread gmb
David Johnston wrote > Basic idea: use ORDER BY in the window to auto-define a range-preceding > frame. Create an array of all dates (tags in the example) that match with > positive amounts. Negative amounts get their matching tag added to the > array as NULL. The provided function looks into th

Re: [SQL] Help needed with Window function

2013-10-02 Thread David Johnston
gmb wrote > item_code | _date| qty | max > - > ABC | 2013-04-05 | 10.00| 2013-04-05 > ABC | 2013-04-06 | 10.00| 2013-04-06 > ABC | 2013-04-06 | -2.00| 2013-04-06

Re: [SQL] Help with a select statement design

2012-12-28 Thread Franz Timmer
hello, ( select 'A' as x, id, price from tab where id = 'value' union all select 'B' as x, id, ... union all select 'C' as x, id, ... union all select 'D' as x, id, price from tab where id = 'value' ) generate a list like X id price A 1 10 B 2 20 C 3 30 D 4 40 select

Re: [SQL] Help with a select statement design

2012-12-28 Thread Andreas Kretschmer
JORGE MALDONADO hat am 24. Dezember 2012 um 17:30 geschrieben: > I have a record with the following fields: > > id1, id2, id3, id4, price1, price2, price3, price4 > > I would like to write a SELECT statement in order to get 4 records: > > id, price (record that comes from id1 and price 1) > id,

[SQL] Help with a select statement design

2012-12-28 Thread JORGE MALDONADO
I have a record with the following fields: id1, id2, id3, id4, price1, price2, price3, price4 I would like to write a SELECT statement in order to get 4 records: id, price (record that comes from id1 and price 1) id, price (record that comes from id2 and price 2) id, price (record that comes fro

Re: [SQL] Help in accessing array

2012-10-02 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of mephysto > Sent: Thursday, September 27, 2012 6:12 AM > To: pgsql-sql@postgresql.org > Subject: [SQL] Help in accessing array > > Hi to everyone, &

[SQL] Help in accessing array

2012-10-02 Thread mephysto
Hi to everyone, I have a little problem to retrieve data from multidimensional array. For example, if I have this array foo[][] = {{5,3},{2,2}} how can I retrieve one of two internal array (for example I would to retrieve {5,3}? I tried foo[1:1] but the result is {{5,3}}, not {5,3}. Is a method

Re: [SQL] help on a function with exception

2012-03-14 Thread David Johnston
On Mar 13, 2012, at 14:29, "M. D." wrote: > Hi, > > I want to do a check on a column if other columns meet certain conditions. > The program I'm working with allows to create additional columns on every > 'object' - called extra data, but I have no control over the program. I want > to enfor

[SQL] help on a function with exception

2012-03-14 Thread M. D.
Hi, I want to do a check on a column if other columns meet certain conditions. The program I'm working with allows to create additional columns on every 'object' - called extra data, but I have no control over the program. I want to enforce the values on this one extra data to be of type dat

Re: [SQL] help with xpath namespace

2011-11-08 Thread Ross Reedstrom
On Mon, Sep 26, 2011 at 09:56:06AM -0400, Brian Sherwood wrote: > Yep, that did it. > > Thanks! ProTip (for the list archive): since the namespace alias in the query and the original XML don't need to match (in this common case, the document uses a default namespace, which isn't available in xpat

Re: [SQL] postgres sql help

2011-10-17 Thread Tim Landscheidt
Harald Fuchs wrote: >> hi, i am fairly new in postgresql, so if anyone can help me would be great >> if i simply do: >> select ver_no >> from version >> order by ver_no >> the result will be something like this: >> .1.3.1 >> .1.3.2.5. >> .1.4.1.7.12 >> .1.4.11.14.7. >> .1.4.3.109.1. >> .1.4.8.

Re: [SQL] postgres sql help

2011-10-16 Thread Harald Fuchs
In article , James Bond writes: > hi, i am fairly new in postgresql, so if anyone can help me would be great > if i simply do: > select ver_no > from version > order by ver_no > the result will be something like this: > .1.3.1 > .1.3.2.5. > .1.4.1.7.12 > .1.4.11.14.7. > .1.4.3.109.1. > .1.4.8.

Re: [SQL] postgres sql help

2011-10-16 Thread Andreas Kretschmer
James Bond wrote: > hi, i am fairly new in postgresql, so if anyone can help me would be great > > if i simply do: > > select ver_no > from version > order by ver_no > > the result will be something like this: > > .1.3.1 > .1.3.2.5. > .1.4.1.7.12 > .1.4.11.14.7. > .1.4.3.109.1. > .1.4.8.66. >

[SQL] postgres sql help

2011-10-16 Thread James Bond
hi, i am fairly new in postgresql, so if anyone can help me would be great if i simply do: select ver_no from version order by ver_no the result will be something like this: .1.3.1 .1.3.2.5. .1.4.1.7.12 .1.4.11.14.7. .1.4.3.109.1. .1.4.8.66. so as you can see first 3 lines ar

Re: [SQL] help with xpath namespace

2011-09-26 Thread Brian Sherwood
Yep, that did it. Thanks! 2011/9/23 Filip Rembiałkowski : > > > 2011/9/22 Brian Sherwood >> >> select (xpath('/chassis-inventory/chassis/serial-number/text()', >>        data_xml, >>        ARRAY[ARRAY['junos', >> 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] >>       )) from xml_test; >

Re: [SQL] help with xpath namespace

2011-09-23 Thread Filip Rembiałkowski
2011/9/22 Brian Sherwood > > select (xpath('/chassis-inventory/chassis/serial-number/text()', >data_xml, >ARRAY[ARRAY['junos', > 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] > )) from xml_test; > > Can anyone suggest how I would go about getting the serial-number wit

[SQL] help with xpath namespace

2011-09-23 Thread Brian Sherwood
I am trying to use xpath to extract some information from a XML document. (if it matters, It's the router config for a Juniper router) I believe I am having problems with the namespace. I am trying to extract the serial-number, but I am not getting anything. Here is the script I have been testing

Re: [SQL] Help with regexp-query

2011-08-02 Thread Tim Landscheidt
Johann Spies wrote: > I am struggling a bit to do the following type of update in a table. > I want the content of a field updated like this: > Original: > '0894396e-16bf-4e63-aa52-97fe7031eec9||50a6b47c-f69c-414d-bcb6-14bbe403de5f|||' > After update: > '|0894396e-16bf-4e63-aa52-97fe7031e

[SQL] Re: [SQL] Help with regexp-query

2011-08-02 Thread Charlie
select id, regexp_replace(category, (E'\\|{2,}'), E'\|', 'g') as category from akb_articles limit 100 Backslash in regex doubled. Added global modifier to replace all occurrences. - Reply message - From: "Johann Spies" Date: Thu, Jul 28, 2011

[SQL] Help with regexp-query

2011-08-02 Thread Johann Spies
I am struggling a bit to do the following type of update in a table. I want the content of a field updated like this: Original: '0894396e-16bf-4e63-aa52-97fe7031eec9||50a6b47c-f69c-414d-bcb6-14bbe403de5f|||' After update: '|0894396e-16bf-4e63-aa52-97fe7031eec9|50a6b47c-f69c-414d-bcb6-14bb

Re: [SQL] help on select

2011-04-21 Thread Jasen Betts
On 2011-04-20, Saulo Venâncio wrote: > --bcaec52e65e9b2f22304a15f3840 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: quoted-printable > > Hi guys, > I need your help. > I have a table called medidas, in this table i have some ocurrences that ha= > s > id_medida(primary

Re: [SQL] help on select

2011-04-21 Thread Charlie
trunc('day', datetime) ), datetimes AS ( SELECT datetime FROM subset GROUP BY datetime HAVING COUNT(*) = (SELECT COUNT(*) FROM pontos) ) SELECT max(datetime) FROM datetimes ; From: saulo.venan...@gmail.com Date: Wed, 20 Apr 2011 17:10:32 -0300 Subject: [SQ

[SQL] help on select

2011-04-20 Thread Saulo Venâncio
Hi guys, I need your help. I have a table called medidas, in this table i have some ocurrences that has id_medida(primary key) id_ponto (sec_key) and also datetime field as timestamp. i would like to know from a set of idpontos, e.g. 10,11,23,24 how can i get the most recent date that is common

Re: [SQL] Help needed in skipping column for copy command

2011-01-17 Thread Russell Galyon
COPY D_2147483927_2147484848_TAB ( CP , CPR , CHOUSENO , CSTREET , CLOCALITY , CCITY , CPROVINCE , CCOUNTRY , CZIP ) FROM 'one.txt' WITH DELIMITER ',' QUOTE '"' csv HEADER; On Mon, Jan 17, 2011 at 7:59 AM, Amar Dhol

Re: [SQL] Help needed in skipping column for copy command

2011-01-17 Thread Adrian Klaver
On 01/17/2011 05:59 AM, Amar Dhole wrote: I have table created as follows CREATE TABLE D_2147483927_2147484848_TAB( CP VARCHAR(256) , CPR VARCHAR(256) , CHOUSENO VARCHAR(256) , CSTREET VARCHAR(256) , CLOCALITY VARCHAR(256) , CCITY VARCHAR(256) , CPROVINCE VARCHAR(256) , CCOUNTRY VARCHAR(

[SQL] Help needed in skipping column for copy command

2011-01-17 Thread Amar Dhole
I have table created as follows CREATE TABLE D_2147483927_2147484848_TAB( CP VARCHAR(256) , CPR VARCHAR(256) , CHOUSENO VARCHAR(256) , CSTREET VARCHAR(256) , CLOCALITY VARCHAR(256) , CCITY VARCHAR(256) , CPROVINCE VARCHAR(256) , CCOUNTRY VARCHAR(256) , CZIP VARCHAR(256) , CCO VAR

Re: [SQL] help needs in converting db2 function in postgresql.

2011-01-12 Thread Amar Dhole
Thanks this solves my problem.. From: filip.rembialkow...@gmail.com [mailto:filip.rembialkow...@gmail.com] On Behalf Of Filip Rembialkowski Sent: Wednesday, January 12, 2011 1:41 AM To: Amar Dhole Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] help needs in

Re: [SQL] help needs in converting db2 function in postgresql.

2011-01-11 Thread Filip Rembiałkowski
2011/1/11 Amar Dhole > Hi, > I need helping converting following db2 function in postgresql function. > Any pointer will be great help in proceeding me ahead. > > CREATE FUNCTION in_liststring ( string CLOB(64K) ) > RETURNS TABLE ( ordinal INTEGER, index INTEGER ) > LANGUAGE SQL > DETERMINI

[SQL] help needs in converting db2 function in postgresql.

2011-01-11 Thread Amar Dhole
Hi, I need helping converting following db2 function in postgresql function. Any pointer will be great help in proceeding me ahead. CREATE FUNCTION in_liststring ( string CLOB(64K) ) RETURNS TABLE ( ordinal INTEGER, index INTEGER ) LANGUAGE SQL DETERMINISTIC NO EXTERNAL ACTION

[SQL] Help with Function in plpgsql

2010-12-19 Thread acurtis416
Hello Postgres Team My environment is 8.4.5 I use PGADMIN 1.10. I've written a function in which I'm having difficulty debugging to determine whether I have a logic error or what I'm attempting to do is not possible in plpgsql? Understand that I come from the Windows and Microsoft World. I'm use

Re: [SQL] Help with queries.

2010-09-21 Thread Adrian Johnson
Hello Oliver. thanks for your reply. Here are my answers. Sorry I shot e-mail in morning and I was not clear about it. I am afraid, I am not jamming you with all information. Thank you very much for your help. == your questions ==

Re: [SQL] Help with queries.

2010-09-21 Thread Oliveiros d'Azevedo Cristina
Howdy, Adrian, Please see my questions below snps table id | sample_id | chromosome | from | to | 1 1chr1 10 11 2 1 chr1 14 15 3 2

[SQL] Help with queries.

2010-09-21 Thread Adrian Johnson
Dear group, I just started learning postgres and I have to analyze my data. So please bear with me, for all the simple questions that I am asking. Apologies. I have a table: snps table id | sample_id | chromosome | from | to | -

Re: [SQL] Help Need some hindsight

2010-08-04 Thread A. Kretschmer
In response to Andreas : > Hi, > I need to display log events (again). > The log is simply like this > log ( log_id serial primary key, create_ts timestamp default > localtimestamp, object_id, state_id, ... ) > > It records the state of objects and when and what happend to to change > this

[SQL] Help Need some hindsight

2010-08-04 Thread Andreas
Hi, I need to display log events (again). The log is simply like this log ( log_id serial primary key, create_ts timestamp default localtimestamp, object_id, state_id, ... ) It records the state of objects and when and what happend to to change this state. I'd like to get a list that sh

Re: [SQL] help

2010-06-27 Thread Marcin Krawczyk
Or even simpler, or easier to understand: SELECT trim(foo, '()') FROM foobar pozdrowienia / regards / salutations mk 2010/5/5 Nicholas I > Hi, > > I have a table in which the data's are entered like, > > Example: > > One (1) > Two (2) > Three (3) > > I want to extract the data which is only

Fw: Re: [SQL] help

2010-05-27 Thread James Kitambara
--- On Thu, 27/5/10, James Kitambara wrote: From: James Kitambara Subject: Re: [SQL] help To: "Nicholas I" Date: Thursday, 27 May, 2010, 14:50 Hello Mr. Nicholas,   You can try the following:   THIS IS WHAT I TRIED TO SOLVE YOUR PROBLEM, BUT IN ORACLE DBMS (SORRY I

Re: [SQL] help

2010-05-07 Thread Filip Rembiałkowski
select substring( data from '\((.*)\)' ) from table; 2010/5/5 Nicholas I : > Hi, > > I have a table in which the data's are entered like, > > Example: > > One (1) > Two (2) > Three (3) > > I want to extract the data which is only within the parentheses. > > that is > 1 > 2 > 3 > > > Thank You > N

[SQL] help

2010-05-07 Thread Nicholas I
Hi, I have a table in which the data's are entered like, Example: One (1) Two (2) Three (3) I want to extract the data which is only within the parentheses. that is 1 2 3 Thank You Nicholas I

Re: [SQL] Help me with this multi-table query

2010-03-25 Thread A. Kretschmer
In response to Nilesh Govindarajan : > Hi, > > I want to find out the userid, nodecount and comment count of the userid. > > I'm going wrong somewhere. > > Check my SQL Code- Check my example: test=*# select * from u; id 1 2 3 (3 rows) test=*# select * from n; uid - 1 1

[SQL] Help with reg_exp

2010-03-25 Thread John Gage
[I mistakenly used the wrong Subject line initially with this post] In going through the arcana of string functions, I have come across the following series of selects that contain, for me, a mysterious "$re$". -- return all matches from regexp SELECT regexp_matches(' foobarbequebaz', $re$(bar)(b

[SQL] Help me with this multi-table query

2010-03-25 Thread Nilesh Govindarajan
Hi, I want to find out the userid, nodecount and comment count of the userid. I'm going wrong somewhere. Check my SQL Code- select u.uid, count(n.nid) nc , count(c.cid) cc from users u left join node n on ( n.uid = u.uid ) left join comments c on ( c.uid = u.uid ) group by u.uid having u.uid

Re: [SQL] Help : insert a bytea data into new table

2010-03-15 Thread dennis
Dear Ben thanks for you anwser. I try to add function quote_literal on my sql statement . but it raise other error message (quote_literal not support bytea format): function quote_literal(bytea) does not exist Ben Morrow 提到: Quoth dennis : Hi Ben here is my function , it's for fi

Re: [SQL] Help : insert a bytea data into new table

2010-03-15 Thread dennis
Postgres : 8.1.4 Dennis Ben Morrow wrote: Quoth dennis: Dear Ben thanks for you anwser. I try to add function quote_literal on my sql statement . but it raise other error message (quote_literal not support bytea format): function quote_literal(bytea) does not exist Which P

Re: [SQL] Help : insert a bytea data into new table

2010-03-15 Thread dennis
Hi Ben here is my function , it's for fix missing chunk problem. It has same problem ,please take look thank for you help -table-- db=# \d usersessiontable; Table "public.usersessiontable" Column | Type | Modifiers ---+---

Re: [SQL] Help : insert a bytea data into new table

2010-03-15 Thread dennis
here is example table name is "mail": column| type - sender|char subject |char content |bytea I want copy some record into new table 'mail_new'. sql: create table mail_new as select * from mail sender='dennis' result has an error: operator does not exist:

Re: [SQL] Help : insert a bytea data into new table

2010-03-11 Thread Ben Morrow
[quoting fixed] Quoth dennis : > Ben Morrow wrote: > > Quoth dennis: > >> Dear Ben > >> > >> thanks for you anwser. > >> I try to add function quote_literal on my sql statement . > >> > >> but it raise other error message (quote_literal not support bytea format): > >>function quote_li

Re: [SQL] Help : insert a bytea data into new table

2010-03-11 Thread Ben Morrow
Quoth dennis : > Dear Ben > > thanks for you anwser. > I try to add function quote_literal on my sql statement . > > but it raise other error message (quote_literal not support bytea format): > function quote_literal(bytea) does not exist Which Postgres version are you using? Ben --

Re: [SQL] Help : insert a bytea data into new table

2010-03-10 Thread Ben Morrow
Quoth dennis : > Hi Ben > > here is my function , it's for fix missing chunk problem. > It has same problem ,please take look > > > thank for you help > > -table-- > > > db=# \d usersessiontable; > Table "public.usersessiontable" >Column |

Re: [SQL] Help : insert a bytea data into new table

2010-03-09 Thread Ben Morrow
Quoth dennis : > here is example > > table name is "mail": > column| type > - > sender|char > subject |char I presume you mean 'varchar'? > content |bytea > > > I want copy some record into new table 'mail_new'. > > sql: > create table mail_new as select

Re: [SQL] Help : insert a bytea data into new table

2010-03-08 Thread Ben Morrow
Quoth dennis : > > I need to copy some data to new table. > But I encounter some error message. > the table structure > Table A: > c1 char > c2 bytea > > Table B: > c1 char > c2 bytea > > > My sql command: > insert into B as select * from a where c1=xxx 'AS' isn't valid there.

Re: [SQL] help-simplify query

2009-11-09 Thread rafizeldi
dateadd() is not sql postgresql standard, it's mssql in postgresql i only need to use +/- operators and interval for the same function dateadd('year', 1, '2008/1/1') ==> date '2008/1/1' + interval '1 year' rafizeldi wrote: > > Dear All > I need to simplify this query, It takes a lot of time t

[SQL] help-simplify query

2009-10-17 Thread Muhammad Rafizeldi
Dear All I need to simplify this query, It takes a lot of time to execute Since "skala_rental" table has 2.3million rows(Table Size:387 MB, Indexes Size: 132MB) and scanned 6 times in the execution. cf_application_id has +10rows, Table Size: 21 MB, Indexes Size: 18MB I guest the problem is on t

Re: [SQL] help with pg_hba.conf

2009-05-22 Thread Tom Lane
Isaac Dover writes: > thank you _SO_ much. I'm not sure how I overlooked that, but it is far > easier to manage using connect. I'm assuming that even if tables have public > privileges granted, that they are not visible to people not granted connect > privileges to the database? Right, if you can

Re: [SQL] help with pg_hba.conf

2009-05-22 Thread Isaac Dover
thank you _SO_ much. I'm not sure how I overlooked that, but it is far easier to manage using connect. I'm assuming that even if tables have public privileges granted, that they are not visible to people not granted connect privileges to the database? Thanks, Isaac On Fri, May 22, 2009 at 12:31 P

Re: [SQL] help with pg_hba.conf

2009-05-22 Thread Tom Lane
Isaac Dover writes: >> As far as i can tell, >> pg_hba.conf is the only manner in which to prevent users from connecting to >> other users' databases. I've restricted roles to connecting only using >> sameuser: >> >> host sameuser all 192.168.168.0/24 md5 In recent releases (certainly 8.3) the b

Re: [SQL] help with pg_hba.conf

2009-05-22 Thread Isaac Dover
possibly this answers my question, and what i am doing is indeed the most appropriate? "Databases are physically separated and access control is managed at the connection level." from 8.3 docs, section 20.1 thanks, Isaac On Fri, May 22, 2009 at 2:37 AM, Isaac Dover wrote: > Hello, to this poi

Re: [SQL] help in writing query

2008-06-10 Thread maria s
Hi Scott, Thanks for the information. This is very useful for me. I will be careful when forming the column. Thanks, -maria On Tue, Jun 10, 2008 at 3:16 PM, Scott Marlowe <[EMAIL PROTECTED]> wrote: > On Tue, Jun 10, 2008 at 11:51 AM, maria s <[EMAIL PROTECTED]> wrote: > > Hi Rosario, > > Thanks

Re: [SQL] help in writing query

2008-06-10 Thread Scott Marlowe
On Tue, Jun 10, 2008 at 11:51 AM, maria s <[EMAIL PROTECTED]> wrote: > Hi Rosario, > Thanks for the link. I hope this will solve my problem. It should be able to. Note that crosstab functions expect "square" inputs from the select they run. I.e. you can't have empty columns, you need to replace

Re: [SQL] help in writing query

2008-06-10 Thread maria s
Hi Rosario, Thanks for the link. I hope this will solve my problem. Thanks, Maria On Tue, Jun 10, 2008 at 11:34 AM, Osvaldo Rosario Kussama < [EMAIL PROTECTED]> wrote: > maria s escreveu: > >> >> I tried the query and it is returning result as , >> for a single entry in sample info in separate r

Re: [SQL] help in writing query

2008-06-10 Thread Pavel Stehule
2008/6/10 maria s <[EMAIL PROTECTED]>: > Hi Pavel, > Thank you for your reply. > > I tried the query and it is returning result as , > for a single entry in sample info in separate rows > > The result of the query as > > 1, prop1,value1 > 1,prop2,value2 > 2,prop1,value1 > 2 prop2,value2 > 2 prop3,v

Re: [SQL] help in writing query

2008-06-10 Thread Osvaldo Rosario Kussama
maria s escreveu: I tried the query and it is returning result as , for a single entry in sample info in separate rows The result of the query as 1, prop1,value1 1,prop2,value2 2,prop1,value1 2 prop2,value2 2 prop3,value3 but i want the output as single row per sample id like 1,value1,value2

Re: [SQL] help in writing query

2008-06-10 Thread maria s
Hi Pavel, Thank you for your reply. I tried the query and it is returning result as , for a single entry in sample info in separate rows The result of the query as 1, prop1,value1 1,prop2,value2 2,prop1,value1 2 prop2,value2 2 prop3,value3 but i want the output as single row per sample id like

Re: [SQL] help in writing query

2008-06-10 Thread Pavel Stehule
Hello SELECT i.name, p.property_name, p.property_value FROM sample_info i JOIN sample_properties p ON i.id = p.id maybe Pavel 2008/6/10 maria s <[EMAIL PROTECTED]>: > Hello friends, > I need help in write a query. > > I have 2 tables, one is sample_info

Re: [SQL] Help with sub query

2007-03-18 Thread Phillip Smith
Add something like this to your query: ORDER BY price_time LIMIT 1 Cheers, ~p -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of roopa perumalraja Sent: Monday, 19 March 2007 13:56 To: pgsql-sql@postgresql.org Subject: [SQL] Help with sub query

[SQL] Help with sub query

2007-03-18 Thread roopa perumalraja
Hi all, I want the last value from the group of rows. The table 'index_prices' is index_code price_time price XYZ09:45:00 7.5 XYZ09:46:00 7.4 XYZ09:59:00 7.2 XYZ10:00:00 7.3 XYZ10:01:00 7.6 XYZ

Re: [SQL] Help ... Unexpected results when using limit/offset with

2007-01-18 Thread Stephan Szabo
On Thu, 18 Jan 2007, Barbara Cosentino wrote: > Then I perform the following selects > > SELECT host_id, host_datum_type_id, host_datum_source_id, data > FROM nc_host_datum INNER JOIN nc_host USING (host_id) > WHERE audit_id=2041 > ORDER BY host_id > LIMIT 49 OFFSET 1372; > > And > > SELECT host_

[SQL] Help ... Unexpected results when using limit/offset with select statement..DB corruption?

2007-01-18 Thread Barbara Cosentino
I got some weird results when processing select statements with limit and offset. I think its some kind of database corruption but I was wondering what other's think. Background: The table I'm having the issue with is described below. The thing to note is the primary key ice=# \d nc_host

Re: [SQL] Help with Array

2007-01-08 Thread Aaron Bono
On 1/8/07, Jeremiah Elliott <[EMAIL PROTECTED]> wrote: I have a java application that moves data from our erp platform (progress) into a Postgres database. One of the fields in progress is a character array. I haven't had any luck getting this field to transfer. What I would like to do is someth

[SQL] Help with Array

2007-01-08 Thread Jeremiah Elliott
I have a java application that moves data from our erp platform (progress) into a Postgres database. One of the fields in progress is a character array. I haven't had any luck getting this field to transfer. What I would like to do is something like: preparedStatement.setArray(i,resultSet.ge

Re: [SQL] help with version checking

2006-12-29 Thread Chris Dunworth
I'd probably make a small change to make this a little cleaner. Specifically, change check_version() to take an argument, which is the needed version, and check this against the current value in agenda_version, throwing the exception if they don't match. Once you've written this, you'll never

Re: [SQL] help with version checking

2006-12-29 Thread Arnau
Hi all, Thanks for all replies, taking into account all your suggestions and my google research I arrived to the next script. I'd like to know your opinion. Hopefully this will be useful for somebody else. --used to stop the script execution on any error

Re: [SQL] help with version checking

2006-12-29 Thread Karsten Hilbert
In GNUmed we have created a function gm_concat_table_structure() in http://cvs.savannah.gnu.org/viewcvs/gnumed/gnumed/server/sql/gmSchemaRevisionViews.sql?rev=1.6&root=gnumed&view=log which returns a reproducable, human-readable TEXT concatenation of all the relevant parts of t

[SQL] Help in altering the column lenght

2006-12-28 Thread roopa perumalraja
Hi all, I am trying to alter the column lenght of the table which has 500 child tables by sql command. alter table ticks alter column qualifiers type varchar(500); the error is ERROR: cannot alter type of a column used by a view or rule DETAIL: rule ticks_insert_20070228

Re: [SQL] help with version checking

2006-12-28 Thread Daniel CAUNE
> I tried to do the following in PostgreSQL: > > DECLARE >v_version VARCHAR; > > BEGIN >SELECT version INTO v_version FROM version WHERE id = 1; > >IF v_version <> ''1.0.0.0'' THEN > RAISE EXCEPTION ''This script needs Agenda version 1.0.0.0, > detected version %'', v_version; >

Re: [SQL] help with version checking

2006-12-28 Thread Chris Dunworth
Can you do the whole thing inside a transaction context (both the version check and the updates)? The exception should cause the transaction to bail out, and the updates won't proceed. Thus: BEGIN; SELECT check_version(); UPDATE agenda_version set version = '1.0.0.1' where id = 1; COMMIT; I t

Re: [SQL] help with version checking

2006-12-28 Thread Arnau
Arnau wrote: Tom Lane wrote: Arnau <[EMAIL PROTECTED]> writes: I don't want, if it's possible, to create a function. Unlike Oracle, PG makes a strong distinction between SQL and programmable languages (including plpgsql). You can't write plpgsql code without putting it into a function.

Re: [SQL] help with version checking

2006-12-28 Thread Arnau
Tom Lane wrote: Arnau <[EMAIL PROTECTED]> writes: I don't want, if it's possible, to create a function. Unlike Oracle, PG makes a strong distinction between SQL and programmable languages (including plpgsql). You can't write plpgsql code without putting it into a function.

Re: [SQL] help with version checking

2006-12-28 Thread Tom Lane
Arnau <[EMAIL PROTECTED]> writes: >I don't want, if it's possible, to create a function. Unlike Oracle, PG makes a strong distinction between SQL and programmable languages (including plpgsql). You can't write plpgsql code without putting it into a function. regards,

Re: [SQL] help with version checking

2006-12-28 Thread Arnau
Hi Daniel, You should define a PL/PGSQL function such as: CREATE OR REPLACE FUNCTION check_version() RETURNS void AS $$ DECLARE v_version VARCHAR; BEGIN SELECT version INTO v_version FROM version WHERE id = 1; IF v_version <> '1.0.0.0' THEN RAISE EXCEPTION 'This script needs Agen

[SQL] help with version checking

2006-12-28 Thread Arnau
Hi all!, I've got the following problem and I don't know how to solve it in PostgreSQL. I'd like to add a version checking to my db scripts. That is, I have the db creation scripts and the changes/upgrade script, and there is a table inside each db that holds the version of script execut

Re: [SQL] Help with quotes in plpgsql

2006-12-20 Thread Richard Huxton
Richard Ray wrote: It makes sense when ya'll explain it It never sounds that good when I'm talkin to myself That solves my problem but not my ignorance I'm still curious about how would I properly quote create or replace function test(integer) returns setof text as $$ declare a record; begin

Re: [SQL] Help with quotes in plpgsql

2006-12-20 Thread Richard Ray
It makes sense when ya'll explain it It never sounds that good when I'm talkin to myself That solves my problem but not my ignorance I'm still curious about how would I properly quote create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now()

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Tom Lane
"Hector Villarreal" <[EMAIL PROTECTED]> writes: >select into a now() - ($1::text||'days')::interval; People keep suggesting variants of that as ways to convert numeric values to intervals, but it's really extremely bad practice. Much better is to use number-times-interval multiplication:

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Hector Villarreal
::interval; return next a; return; end $$ language 'plpgsql'; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Milen A. Radev Sent: Tuesday, December 19, 2006 2:54 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Help with quotes in plpgsql

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Milen A. Radev
Richard Ray написа: > On Tue, 19 Dec 2006, Milen A. Radev wrote: > >> Richard Ray : >>> How should this be properly quoted >>> >>> create or replace function test(integer) returns setof text as $$ >>> declare >>> a record; >>> begin >>> select into a now() - interval '$1 day'; >>>

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread A. Kretschmer
am Tue, dem 19.12.2006, um 14:09:37 -0600 mailte Richard Ray folgendes: > How should this be properly quoted > > create or replace function test(integer) returns setof text as $$ > declare > a record; > begin > select into a now() - interval '$1 day'; > return next a; > return; > end > $$

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Richard Ray
On Tue, 19 Dec 2006, Milen A. Radev wrote: Richard Ray : How should this be properly quoted create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now() - interval '$1 day'; return next a; return; end $$ language 'plpgsql';

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Richard Ray
:10 PM To: pgsql-sql@postgresql.org Subject: [SQL] Help with quotes in plpgsql How should this be properly quoted create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now() - interval '$1 day'; return next a; return; end $$

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Hector Villarreal
turn; end $$ language 'plpgsql'; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Ray Sent: Tuesday, December 19, 2006 12:10 PM To: pgsql-sql@postgresql.org Subject: [SQL] Help with quotes in plpgsql How should this be properly

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Milen A. Radev
Richard Ray написа: > How should this be properly quoted > > create or replace function test(integer) returns setof text as $$ > declare > a record; > begin > select into a now() - interval '$1 day'; > return next a; > return; > end > $$ language 'plpgsql'; > > I'm not having a lot of luc

Re: [SQL] Help with quotes in plpgsql

2006-12-19 Thread Jim Buttafuoco
Try select into a now() - interval ($1 || ' day') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Ray Sent: Tuesday, December 19, 2006 3:10 PM To: pgsql-sql@postgresql.org Subject: [SQL] Help with quotes in plpgsql How should this b

[SQL] Help with quotes in plpgsql

2006-12-19 Thread Richard Ray
How should this be properly quoted create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now() - interval '$1 day'; return next a; return; end $$ language 'plpgsql'; I'm not having a lot of luck Thanks Richard ---

Re: [SQL] Help with optional parameters

2006-09-21 Thread MaXX
Curtis Scheer wrote: > I noticed this one by searching in the archives, as I am working with some > "optional" parameters myself and noticed your solution. I just wanted to > make one improvement suggestion which is instead of checking whether or not > a parameter has been used simply start yo

Re: [SQL] Help with optional parameters

2006-09-21 Thread Curtis Scheer
: Thursday, August 17, 2006 8:58 PM To: MaXX Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Help with optional parameters   BEGIN query_base := 'SELECT * FROM my_table '; has_param := FALSE; query_where := ''; IF (a IS NOT NULL) THEN    IF (has_param IS FALSE)THEN   -- t

Re: [SQL] help with pagila

2006-09-04 Thread Markus Schaber
Hi, Tom, Tom Lane wrote: > If film_id is a primary key for film, then it's actually legal per SQL99 > (though not in earlier SQL specs) to just GROUP BY film_id and then > reference the other columns of film without explicit grouping, because > clearly there can be only one value of them per film

Re: [SQL] help with pagila

2006-09-01 Thread Stephan Szabo
On Fri, 1 Sep 2006, Walter Cruz wrote: > Hi all. I'm with a little doubt. > > I'm testing the pagila (the postgres port of mysql sakila sample). > > Well, I was trying to translate the query: > > select > film.film_id AS FID, > film.title AS title, > film.description AS description

Re: [SQL] help with pagila

2006-09-01 Thread Walter Cruz
Thank you all.I found myself with the same trouble in last week, when I tried to port mambo CMS to PostgreSQL.After some work, In fall i a query like the one that was quoted by Andrew and decided to stop. In that time, my guess wae that something was wrong with MySQL.(I don't know.. I have seen que

Re: [SQL] help with pagila

2006-09-01 Thread Tomas Vondra
> So I can assume that the MySQL implementation is strange? (It accepts > that kind of query) Yes, MySQL behaves strangely in this case (as well as in several other cases). I wouldn't rely on this as it probably can choose different values each time (although as far as I remember I haven't seen th

  1   2   3   4   5   >