Re: [SQL]

2013-10-08 Thread Andreas Kretschmer
Kaleeswaran Velu v_kal...@yahoo.com wrote: Hi Team, I am using PostgreSQL 9.2.3 in Windows platform. I have created two databases in it. Now I want to refer the tables across the databases. Meaning would like to create Database link. Can anyone guide me on how to create a DB link? You can

Re: [SQL] Primary DB stuck becuase of unavailable standby (synchronized streaming) - please help

2013-04-18 Thread Andreas Kretschmer
Sofer, Yuval yuval_so...@bmc.com wrote: Hi, I am using Postgres DB with stand by database, configured with streaming in synchronized mode (each commit on primary DB waits for commit on secondary DB). Sometimes we suffer from network issues and as consequences, secondary

Re: [SQL] How to reject overlapping timespans?

2013-02-17 Thread Andreas Kretschmer
Andreas maps...@gmx.net 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

Fwd: Re: [SQL] sql basic question

2012-12-28 Thread Andreas Kretschmer
sorry, only a private replay and not to the list -- Ursprüngliche Nachricht -- Von: Andreas Kretschmer andr...@a-kretschmer.de An: Antonio Parrotta antonioparro...@gmail.com Datum: 28. Dezember 2012 um 15:19 Betreff: Re: [SQL] sql basic question Hi, your question was: What I want

Re: [SQL] sql basic question

2012-12-28 Thread Andreas Kretschmer
| 129007 | 0.63454675634756 |0 *m 19 | 129007 | 0.97897897897654 |0 *M 13 | 129007 | 0.22345364656788 |1 *m 11 | 129007 | 0.86787897897689 |1 *M thanks - Antonio On 28 December 2012 15:19, Andreas Kretschmer andr...@a-kretschmer.dewrote: Hi, your

Re: [SQL] Help with a select statement design

2012-12-28 Thread Andreas Kretschmer
JORGE MALDONADO jorgemal1...@gmail.com 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

Re: [SQL] checking the gaps in intervals

2012-10-06 Thread Andreas Kretschmer
Anton Gavazuk antongava...@gmail.com wrote: Hi dear community, Have probably quite simple task but cannot find the solution, Imagine the table A with 2 columns start and end, data type is date start end 01 dec. 10 dec 11 dec. 13 dec 17 dec. 19 dec . If I

Re: [SQL] checking the gaps in intervals

2012-10-06 Thread Andreas Kretschmer
Andreas Kretschmer akretsch...@spamfence.net wrote: Anton Gavazuk antongava...@gmail.com wrote: Hi dear community, Have probably quite simple task but cannot find the solution, Imagine the table A with 2 columns start and end, data type is date start end 01 dec

Re: [SQL] Reuse temporary calculation results in an SQL update query

2012-09-29 Thread Andreas Kretschmer
Matthias Nagel matthias.h.na...@gmail.com hat am 29. September 2012 um 12:49 geschrieben: Hello, is there any way how one can store the result of a time-consuming calculation if this result is needed more than once in an SQL update query? This solution might be PostgreSQL specific and not

Re: [SQL] [GENERAL] Indexing question

2012-08-14 Thread Andreas Kretschmer
amit sehas cu...@yahoo.com wrote: In SQL, given a table T, with two fields f1, f2, is it possible to create an index such that the same record is indexed in the index, once with field f1 and once with field f2. (I am not looking for a compound index in which the key would look like f1,

Re: [SQL] can this be done with a check expression?

2012-08-02 Thread Andreas Kretschmer
Tom Lane t...@sss.pgh.pa.us wrote: Wayne Cuddy lists-pg...@useunix.net writes: A less bogus way of doing things is to use an EXCLUDE constraint, although that will restrict you to be running PG 9.0 or newer. You also need some way of representing the ranges as indexable objects. In 9.0 or

Re: [SQL] Prevent double entries ... no simple unique index

2012-07-11 Thread Andreas Kretschmer
Andreas maps...@gmx.net wrote: Hi, I've got a log-table that records events regarding other objects. Those events have a state that shows the progress of further work on this event. They can be open, accepted or rejected. I don't want to be able to insert addition events regarding an

Re: [SQL] Prevent double entries ... no simple unique index

2012-07-11 Thread Andreas Kretschmer
Andreas Kretschmer akretsch...@spamfence.net wrote: Andreas maps...@gmx.net wrote: Hi, I've got a log-table that records events regarding other objects. Those events have a state that shows the progress of further work on this event. They can be open, accepted or rejected. I

Re: [SQL] Prevent double entries ... no simple unique index

2012-07-11 Thread Andreas Kretschmer
Marc Mamin m.ma...@intershop.de wrote: Or this one: test=*# create unique index on log((case when state = 0 then 0 when state = 1 then 1 else null end)); CREATE INDEX Now you can insert one '0' and one '1' - value - but no more. Hi, A partial index would do the same,

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

2012-06-22 Thread Andreas Kretschmer
Andreas maps...@gmx.net 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.

Re: [SQL] master/detail

2012-05-23 Thread Andreas Kretschmer
Jan Bakuwel jan.baku...@greenpeace.org hat am 21. Mai 2012 um 01:17 geschrieben: Hi, I'm trying to get my head around the following question. As an example take a table with products: productid (pk) name and productprice productpriceid (pk) productid (fk) pricedate price There

Re: [SQL] How change col name during query to use it in where clause

2012-05-04 Thread Andreas Kretschmer
Marcel Ruff m...@marcelruff.info hat am 4. Mai 2012 um 12:25 geschrieben: Hi, is an alias name not usable in the where clause? Exactly. Andreas -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription:

Re: [SQL] Simple way to get missing number

2012-04-24 Thread Andreas Kretschmer
Emi Lu em...@encs.concordia.ca wrote: Good morning, May I know is there a simple sql command which could return missing numbers please? For example, t1(id integer) values= 1, 2, 3 500 select miss_num(id) from t1 ; something like ,[ code ] | test=# select * from

Re: [SQL] Simple way to get missing number

2012-04-24 Thread Andreas Kretschmer
Raj Mathur (राज माथुर) r...@linux-delhi.org wrote: Nice one, but curious about how would this perform if the numbers in question extended into 7 figures or more? mode=David Fetter TIAS (Try It And See) /mode Andreas -- Really, I'm not out to destroy Microsoft. That will just be a

Re: [SQL] getting the OS user name

2012-04-23 Thread Andreas Kretschmer
John Fabiani jo...@jfcomputer.com wrote: Hi, In my app it is possible to login as one name and use a different name to login to postgres. Is it possible to get the actual OS login name using plsql. Since you can login to an remote database server: no. Andreas -- Really, I'm not out

Re: [SQL] foreign key is it a real key

2012-02-13 Thread Andreas Kretschmer
John Fabiani jo...@jfcomputer.com wrote: Hi, I have read a few articles and I'm not sure if it's me or the authors but I do not believe my question was answered. If I have table that has a PK and a FK - will the planner use the FK just same as it would use the PK? IOW's is a FK also

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Andreas Kretschmer
rverghese ri...@hotmail.com wrote: I want to insert a bunch of records and not do anything if the record already exists. So the 2 options I considered are 1) check if row exists or insert and 2) ignore the unique violation on insert if row exists. Any opinions on whether it is faster to

Re: [SQL] i want small information regarding postgres

2012-01-02 Thread Andreas Kretschmer
vinodh chowdary vinodchowda...@gmail.com wrote: Hi sir, i am using postgres as database for my project. i want to convert postgres data into excel sheet. is there any way to do it? please reply me. This should be possible with ODBC. (But i'm not familiar with it, don't ask me how ...)

Re: [SQL] Problem with tables and columns names

2011-12-19 Thread Andreas Kretschmer
Gabriel Filipiak gabriel.filip...@gmail.com wrote: Hi, so I am working on PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit. It seems that i can't give a table name for example testTable it has to be test_table, because I can't

Re: [SQL] Column ... does not exist (view + union)

2011-12-17 Thread Andreas Kretschmer
Stefan Weiss krewech...@gmail.com wrote: - running this query - SELECT name FROM dossier_contact_v WHERE dossier_id = 56993 AND ctype = 234 UNION SELECT name FROM dossier_contact_v WHERE dossier_id = -1 AND ctype = -1 ORDER BY

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler rich...@klingler.net wrote: Good day... I'm trying to build a query for PGSQL 9.1 where a table has two references with only one being used depending of the type of entry.. For example, the table has following simplified structure: portid primary key

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler rich...@klingler.net wrote: This seems to do the trick... select arp.ip, arp.mac, arp.port2time, arp.time, arp.hostname, arp.vlan from arp, port, node where arp.arp2port = port.portid and port.name = 'Fa1/0/1' and port.port2node = node.nodeid and

Re: [SQL] Number timestamped rows

2011-11-02 Thread Andreas Kretschmer
Jan Peters peters...@gmx.at wrote: Dear all, maybe a stupid question, but: I have a table that is ordered like this: user_id|timestamp|event 1 |0:1 |event_a 1 |0:2 |event_b 2 |0:1 |event_b 2 |0:3 |event_c 2 |0:4 |event_b 3 |0:1

Re: [SQL] Problem with DROP ROLE

2011-10-25 Thread Andreas Kretschmer
You can't do that in THAT way, but you can use dynamic SQL:   test=# select * from drop_role ;    t  foobar (1 row) test=*# do $$ declare r text; begin for r in select t from drop_role loop execute 'drop role ' || quote_ident(r) || ';'; end loop; end; $$language plpgsql;   DO     

Re: [SQL] postgres sql help

2011-10-16 Thread Andreas Kretschmer
James Bond coolof...@hotmail.com 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.

Re: [SQL] Group by on Date

2011-10-16 Thread Andreas Kretschmer
maya.more meena...@gmail.com wrote: I have a table with Date and unit column. . I want to find sum of unit column considering 3 days each User will specify start and enddate Eg DateUnit 10/1/2011 1 10/2/2011 2 10/3/2011 3 10/4/2011 4 10/5/2011 4

Re: [SQL] Clever way to check overlapping time intervals ?

2011-09-15 Thread Andreas Kretschmer
Andreas maps...@gmx.net wrote: Hi, is there a clever way to check overlapping time intervals ? An option named n should be taken from date y to y. The same name is ok for another interval. e.g. table : mytab ( d1 date, d2 date, n text, v text ) There should be a constraint to provide no

Re: [SQL] Subselects not allowed?

2011-06-12 Thread Andreas Kretschmer
, and Andreas Kretschmer. You guys are great. And even better, in the first comment to the blog post, I was advised about the SETVAL() function which does exactly what I wanted in the first place. Yeah, right! Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Andreas Kretschmer
Leif Biberg Kristensen l...@solumslekt.org wrote: Can anybody tell me why this doesn't work? pgslekt= CREATE SEQUENCE sources_source_id_seq START WITH (SELECT MAX(source_id) FROM sources); ERROR: syntax error at or near ( LINE 1: CREATE SEQUENCE sources_source_id_seq START WITH (SELECT

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

2011-05-03 Thread Andreas Kretschmer
Emi Lu em...@encs.concordia.ca 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

Re: [SQL] concatenate question

2010-12-11 Thread Andreas Kretschmer
Tony Capobianco tcapobia...@prospectiv.com wrote: Here's my table: plsql_dw=# \d tmpsv_parent_master Table staging.tmpsv_parent_master Why won't this work? plsql_dw=# select memberid || addeddate from tmpsv_parent_master limit 10; ERROR: operator does not exist: numeric ||

Re: [SQL] force view column varchar(32) to varchar(128)

2010-11-19 Thread Andreas Kretschmer
Emi Lu em...@encs.concordia.ca wrote: Hello, Is there a way to force the view column change from varhcar(32) to varchar(128)? No, you have to recreate the view ... Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread Andreas Kretschmer
John Lister john.lister...@kickstone.com wrote: Hi, I was wondering if it is possible to do this with a single query rather than iterate over all of the rows in an application: I have a table which for brevity looks like: create table offers { integer id; integer product_id;

Re: [SQL] Duplicate rows

2010-08-10 Thread Andreas Kretschmer
Edward W. Rouse ero...@comsquared.com wrote: Is there any way to remove a duplicate row from a table? Not my db but I have to work with it. On version 7.4 right now. How to select the right records? You can try to use the ctid-column, see my simple example: test=# select * from dups ; i

Re: [SQL] is there a tutorial on window functions?

2010-06-11 Thread Andreas Kretschmer
John jo...@jfcomputer.com wrote: Hi, I'd like to learn the use of window functions and did not find a tutorial using google (postgres window function tutorial). I'm hoping someone has a link. My link-collection: http://delicious.com/akretschmer/windowing and

Re: [SQL] INSERT INTO...RETURNING vs SELECT

2010-04-05 Thread Andreas Kretschmer
Cliff Wells cl...@develix.com wrote: As far as I can see, INSERT INTO...RETURNING is semantically equivalent to SELECT...FROM with a side-effect, so it seems this construct should work. Can someone shed some light? Well, at the moment you can't reuse the RETURNING-values, you have to wait

Re: [SQL] window function to sort times series data?

2010-03-24 Thread Andreas Kretschmer
A. Kretschmer andreas.kretsch...@schollglas.com wrote: Well, and now i'm using 8.4 windowing-functions: test=*# select * from price order by price_id, d; price_id | price | d --+---+ 1 |10 | 2010-03-12 1 |11 | 2010-03-19 1 |12 |

Re: [SQL] Drop all constraints

2010-03-06 Thread Andreas Kretschmer
Gianvito Pio pio.gianv...@gmail.com wrote: Hi all, is there a way to drop all constraints of a table? I found this workaround in the manual: CREATE TABLE temp AS SELECT * FROM distributors; DROP TABLE distributors; CREATE TABLE distributors AS SELECT * FROM temp; DROP TABLE temp; I

Re: [SQL] Triggers on system tables

2010-03-03 Thread Andreas Kretschmer
Gianvito Pio pio.gianv...@gmail.com wrote: Hi all, is there a way (also strange) to define a trigger on a system table (for example on pg_class)? No. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

Re: [SQL] selecting rows tagged with a but not b

2010-02-01 Thread Andreas Kretschmer
8q5tmky...@sneakemail.com 8q5tmky...@sneakemail.com wrote: Hi, I have a two tables: article articleID, name, content tags articleID, tag I want to find all articles that are tagged with a but not b how do I do this? select a.* from article left join tags t on

Re: [SQL] short-cutting if sum()constant

2009-12-22 Thread Andreas Kretschmer
msi77 ms...@yandex.ru wrote: Does PG support CTE? Since 8.4 yes. You can try it. Sorry, but i don't know how a CTE can help in this case, can you explain that? Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

Re: [SQL] Show CAS, USD first; the left ordered by currency name

2009-07-30 Thread Andreas Kretschmer
Emi Lu em...@encs.concordia.ca wrote: Good morning, I have a currency table (code, description). Example values: ADF | Andorran Franc ... ... ANG | NL Antillian Guilder AON | Angolan New Kwanza AUD | Australian Dollar AWG | Aruban Florin BBD | Barbados Dollar USD | US Dollar

Re: [SQL] how to set the value to the column

2009-04-16 Thread Andreas Kretschmer
DM dm.a...@gmail.com wrote: Hi All, I have a table test with columns name and value test table name value It has around 500 rows. I added a new column id to the table, Table test id, name, value I am not sure how to insert numbers to my column id (1-500). You can

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Andreas Kretschmer
Carol Cheung cache...@consumercontact.com wrote: Hi, I have a table called temp access_date | active | status -++ 2009-02-01 | t | 15 2009-02-01 | f | 16 2009-02-02 | f | 17 2009-02-01 | t | 17 2009-02-02 | f

Re: [SQL] Seeking for the fore-part of the key

2009-01-11 Thread Andreas Kretschmer
Havasvölgyi Ottó havasvolgyi.o...@gmail.com schrieb: Hi, Let's assume I have a table (called tbl) with a column 'name' and an index on it. How to optimally find records whose name column begins with - say - Pre? I know it can be done with LIKE (WHERE name LIKE 'Pre%'), but will this use

Re: [SQL] adding order by to a group by query

2008-12-06 Thread Andreas Kretschmer
Louis-David Mitterrand [EMAIL PROTECTED] schrieb: But if I append this order by pt.type_fr = 'comédien'; I get this error: ERROR: column pt.type_fr must appear in the GROUP BY clause or be used in an aggregate function It seems I am using pt.type_fr in an aggregate

Re: [SQL] adding order by to a group by query

2008-12-06 Thread Andreas Kretschmer
Scott Marlowe [EMAIL PROTECTED] schrieb: You can use a subquery like my example: test=*# select i, comma(t) from (select distinct i,t from foo) bar group by i; i | comma ---+- 1 | a, b, c (1 row) Time: 0.554 ms test=*# select i, comma(t) from (select distinct i,t

Re: [SQL] EXECUTE query INTO problem

2008-11-25 Thread Andreas Kretschmer
Tk421 [EMAIL PROTECTED] schrieb: I've got a problem with a function: It receives two parameters, the first, the table name, and the second, a where condition. The function looks like this: DECLARE cod bigint; query TEXT; BEGIN query = 'SELECT codigo FROM '

Re: [SQL] Select function with set return type

2008-08-18 Thread Andreas Kretschmer
Nacef LABIDI [EMAIL PROTECTED] schrieb: Hi all, I am writing some functions with retrun type as a SETOF of a datatype that I have defined. How can I test them with a select statement. Doing select my_function(); return set valued function called in context that cannot accept a set Try

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Andreas Kretschmer
Patrick Scharrenberg [EMAIL PROTECTED] schrieb: Something like this select a, b , a*b as c from ta where c=2; But postgresql complains, that column c does not exist. Do I have to repeat the calculation (which might be even more complex yes. Andreas -- Really, I'm not out to destroy

Re: [SQL] merge timestamps to intervals

2008-05-12 Thread Andreas Kretschmer
Patrick Scharrenberg [EMAIL PROTECTED] schrieb: Hi! I have a table where I repeatingly log the status of some service, which looks something like this: timestamp, status I'd like to merge this information to intervals where the service was up or down. intervall,

Re: [SQL] Concatenation through SQL

2007-12-21 Thread Andreas Kretschmer
Philippe Lang [EMAIL PROTECTED] schrieb: 2 ways: * You can use something like this: test=*# select * from a; id | val +- 1 | foo 2 | bar (2 rows) test=*# select array_to_string(array(select val from a), ', '); array_to_string - foo, bar (1 row) *

Re: [SQL] INSERT INTO relational tables

2007-12-07 Thread Andreas Kretschmer
Stefan Scheidegger [EMAIL PROTECTED] schrieb: An example to explain my Problem: Lets say I have a table containing information about the customer (name, address, ...) and about his order (pieces, product-name, price). Because one customer can order several products I split the table into two

Re: [SQL] execute system command from storage procedure

2007-12-06 Thread Andreas Kretschmer
Sabin Coanda [EMAIL PROTECTED] schrieb: Hi there, Is it possible to execute a system command from a function ? (e.g. bash ) Yes, of course, but you need an untrusted language like pl/perlU oder plsh. http://plsh.projects.postgresql.org/ Andreas -- Really, I'm not out to destroy Microsoft.

Re: [SQL] Removing whitespace using regexp_replace

2007-10-28 Thread Andreas Kretschmer
Thomas Kellerer [EMAIL PROTECTED] schrieb: Hi, I have a column with the datatype text that may contain leading whitespace (tabs, spaces newlines, ...) and I would like to remove them all (ideally leading and trailing). You can use trim() for that: select 'x' || trim(both '\t' from

Re: [SQL] Removing whitespace using regexp_replace

2007-10-28 Thread Andreas Kretschmer
Thomas Kellerer [EMAIL PROTECTED] schrieb: Andreas Kretschmer wrote on 28.10.2007 12:42: I have a column with the datatype text that may contain leading whitespace (tabs, spaces newlines, ...) and I would like to remove them all (ideally leading and trailing). You can use trim

Re: [PERFORM] [SQL] two queryes in a single tablescan

2007-10-20 Thread Andreas Kretschmer
Markus Schaber [EMAIL PROTECTED] schrieb: is there any way to get both results in a single query, eventually through stored procedure? The retrieved [count(*),A] ; [count(*),B)] data couldnt fit on a single table, of course. The main goal would be to get multiple results while

Re: [SQL] What SQL is running against my DB?

2007-10-04 Thread Andreas Kretschmer
Tore Lukashaugen [EMAIL PROTECTED] schrieb: Hello all, I have an application running against my postgres 8.2 database (on Windows Vista) for which I do not have access to the source code. I would like to know what SQL statements are being executed by the application. Is there a way to

Re: [SQL] Format intervall as hours/minutes etc

2007-09-16 Thread Andreas Kretschmer
Andreas Joseph Krogh [EMAIL PROTECTED] schrieb: Hi all. Any hint on how to format this interval as number of hour/seconds etc? select age('2007-09-22 17:00'::timestamp, '2000-02-20 18:00'::timestamp); age --- 7 years 7 mons 1 day 23:00:00 You can

Re: [SQL] Counting all rows

2007-06-23 Thread Andreas Kretschmer
Stefan Arentz [EMAIL PROTECTED] schrieb: I need to get statistics from a bunch of tables. Simply the number of records in them. The query plan looks like this: = explain select count(id) from stuff; QUERY PLAN

Re: [SQL] joining a table whose name is stored in the primary record

2007-06-17 Thread Andreas Kretschmer
John Gunther [EMAIL PROTECTED] schrieb: I've tried everything I can think of here to join records when the join table varies and is named in the primary record, but to no avail. Here's an example with all non-essentials stripped out. I have 3 tables: create table zip ( id serial

Re: [SQL] show index from [table]

2007-06-08 Thread Andreas Kretschmer
Stefan Zweig [EMAIL PROTECTED] schrieb: hi list, currently i am switching from mysql to pgsql, so i am a bit new to postgres' syntax. You are welcome. at the moment i am looking in postgres for something which is similar to SHOW INDEX FROM [table] in mysql. unfortunately i could not

Re: [SQL] plpgsql function question

2007-04-03 Thread Andreas Kretschmer
Karthikeyan Sundaram [EMAIL PROTECTED] schrieb: Hi, I am having a requirement here. 1) I need to write a plpgsql function where it takes the input parameter of a structure of a table. Because? To build this table? You can pass an ascii-text with

Re: [SQL] union with count?

2007-03-28 Thread Andreas Kretschmer
Gerardo Herzig [EMAIL PROTECTED] schrieb: Thanks! But now i have another problem related with count(): select page_id, word, word_position, count(page_id) from (select * from search_word('word1', 'table1') union search_word('word2', 'table2')) foo group by page_id; and gives me

Re: [SQL] ordering by multiple columns

2007-03-14 Thread Andreas Kretschmer
Pablo Barrón [EMAIL PROTECTED] schrieb: Hi! I'm trying to order a list in which the first parameter to order is a specific field, and the second should vary depending on a specific condition. More explicit, I would like to do something like: - ORDER BY a.column1, [b.column2 if

Re: [SQL] how to use a date range in a join

2007-03-12 Thread Andreas Kretschmer
chester c young [EMAIL PROTECTED] schrieb: trying to do something like select d.day, c.name from [dates between day1 and day2] d left join c.some_table; but cannot figure out what to put into the brackets. Perhaps something like this: test=# select current_date +

Re: [SQL] Inc

2007-03-06 Thread Andreas Kretschmer
Richard Broersma Jr [EMAIL PROTECTED] schrieb: --- Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Thank you but I must inc an specific row. How to do that ? Does, UPDATE your_table SET your_row = your_row +1 WHERE your_pkey = some value; not do what you need? I think, he

Re: [SQL] sub-limiting a query

2007-02-17 Thread Andreas Kretschmer
Louis-David Mitterrand [EMAIL PROTECTED] schrieb: ballet,etc.) and I am looking for a select that can return the 10 last entered shows AND at most 2 of each type. Is that possible in one query? A similar question i found in the archive and there are a couple of answers: (for the second part

Re: [SQL] [ADMIN] Deadlock on transaction

2007-02-12 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha [EMAIL PROTECTED] schrieb: I mean really deadlock. Other transactions can't access the database until the main transaction is complete. A question: That's not true. PostgreSQL doesn't permit multiple transactions concurrently ? Why not? Show us a complete case.

Re: [SQL] consistent random order

2006-11-29 Thread Andreas Kretschmer
Jeff Herrin [EMAIL PROTECTED] schrieb: I am returning results ordered randomly using 'order by random()'. My issue has to do with page numbers in our web application. When I hit the 2nd page and retrieve results with an offset, ordering by random() isn't really what I want since I will

Re: [SQL] select into

2006-11-24 Thread Andreas Kretschmer
Adrian Klaver [EMAIL PROTECTED] schrieb: On Thursday 23 November 2006 08:45 pm, Tom Lane wrote: Mulham freshcode [EMAIL PROTECTED] writes: execute sql_str1 into svc_data_rec ; svc_data_rec is a RECORD, which is supposed to be dynamic. This should work --- in PG 8.1 or later. In

Re: [SQL] select into

2006-11-22 Thread Andreas Kretschmer
Richard Broersma Jr [EMAIL PROTECTED] schrieb: Hi guys, Am new to sql scripting so this might be a stupid question. Am getting an error while trying to do the following SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id; where svc_data_rec is defined as

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini [EMAIL PROTECTED] schrieb: Dear all... I have created a check constraint without giving it a name.. now I have a check named $25 in my table that I need to drop or modify!!! How can I do??? Can you see the name with \d table within psql? An example: test=# create table bla

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini [EMAIL PROTECTED] schrieb: . or it depend on the fact I'm using postgres 7.4.13 many thanks... Maybe, the information-schema can be different in different versions. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side

Re: [SQL] [GENERAL] How to split a table?

2006-10-17 Thread Andreas Kretschmer
Felix Zhang [EMAIL PROTECTED] schrieb: Hi, I want to split a table to 2 small tables. The 1st one contains 60% records which are randomly selected from the source table. How to do it? Why do you want to do this? Andreas -- Really, I'm not out to destroy Microsoft. That will just be a

Re: [SQL] [GENERAL] Any documatation about porting from Oracle to PostgreSQL

2006-10-17 Thread Andreas Kretschmer
Felix Zhang [EMAIL PROTECTED] schrieb: Hi all, I'm a newbie of PostgreSQL. I'm searching materials about porting from Oracle to PostgreSQL. Anyone can share with me some good documatations? http://techdocs.postgresql.org/#convertfrom Andreas -- Really, I'm not out to destroy Microsoft.

Re: [SQL] Substitute a Character

2006-09-06 Thread Andreas Kretschmer
Judith [EMAIL PROTECTED] schrieb: Hello everybody!! I have a field type text with folios like this: A98526 but I want to change de A for a 0 like this: 098526, exists a way to do this in a query??? Perhaps something like this: test=# select regexp_replace('A98526', '^.',

Re: [SQL] Mac Address

2006-09-03 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha [EMAIL PROTECTED] schrieb: Hi list, It is possible to retrieve the MAC Address of a computer using a Postgresql function like others: In the same subnet? Then you can use untrusted languages such as plperlu or plsh to retrieve the MAC for a IP. (arp -a ip) Btw.:

Re: [SQL] i have a problem of privilages

2006-07-04 Thread Andreas Kretschmer
MJ Santhosh [EMAIL PROTECTED] schrieb: I am not an expert in postgres, may this work for you. REVOKE INSERT,UPDATE,DELETE ON ALL from PUBLIC; IIRC, you cant REVOKE ... ON ALL, you need a table-name instead ALL. But, you can create a script for all tables:

Re: [SQL] Multi-column index not used, new flipped column index is

2006-05-11 Thread Andreas Kretschmer
[EMAIL PROTECTED] [EMAIL PROTECTED] schrieb: Hi Andreas and Markus, Bitmap indices sound like a good reason to go from 8.0 to 8.1. Is 8.2 around the corner, by any chance? IIRC in autumn/winter. If it is finish ;-) I searched PG docs to see if I need to do something special to create

Re: [SQL] Multi-column index not used, new flipped column index is

2006-05-10 Thread Andreas Kretschmer
Markus Schaber [EMAIL PROTECTED] schrieb: Bitmap Index Scans can be your solution, but AFAIK they were invented in 8.1. Right. For bitmap index scans, you have one index on fkColumnOne and one on fkColumnTwo, and the query planner knows to combine them when both columns are given in a

Re: [SQL] Looking for some help with cascading updates...

2006-04-18 Thread Andreas Kretschmer
Mark True [EMAIL PROTECTED] schrieb: Here is the question: I have a situation where I need to create triggers to cascade an insert operation to many tables to maintain foreign key constraints. So at a high level INSERT INTO myTable (Name, Address, Zip) VALUES ('Mark', '3 Dingle

Re: [SQL] Looking for some help with cascading updates...

2006-04-18 Thread Andreas Kretschmer
Mark True [EMAIL PROTECTED] schrieb: I guess I should have clarified. I am having trouble figuring out how to construct the IF statement to see if that item exists in the foreign table something like: count=select count(*) from table; if count=0 { insert fkey into myOtherTable } a

Re: [SQL] Looking for some help with cascading updates...

2006-04-18 Thread Andreas Kretschmer
Mark True [EMAIL PROTECTED] schrieb: Next silly question, how do you get your database to like plpgsql... - createlang on the command line - create language plpgsql; (in psql) I do CREATE LANGUAGE 'plpgsql' and it says it is not defined? Strange... --Mark On 4/18/06,

Re: [SQL] on select rule

2006-04-14 Thread Andreas Kretschmer
Sergey Levchenko [EMAIL PROTECTED] schrieb: http://www.postgresql.org/docs/8.1/interactive/sql-createtrigger.htmlSELECT does not modify any rows so you can not create SELECT triggers.Rules and views are more appropriate in such cases. On 4/14/06, A. Oh yes, i'm sorry. Andreas -- Really,

Re: [SQL] regarding join

2006-03-24 Thread Andreas Kretschmer
AKHILESH GUPTA [EMAIL PROTECTED] schrieb: hi all, below I have created two tables in pgsql with field name as 'name' and 'id' as their datatype 'varchar(15)' and 'integer'. i want the output as:- ... a UNION of this 2 tables: test=# select * from test1 union select * from test3 order by

Re: [SQL] how to get the size of array?

2006-03-14 Thread Andreas Kretschmer
Emi Lu [EMAIL PROTECTED] schrieb: Hello, Is there a way that I can get the size of one array ? Yes: http://www.postgresql.org/docs/8.1/interactive/functions-array.html HTH, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

Re: [SQL] input from a external text file......!

2006-03-11 Thread Andreas Kretschmer
AKHILESH GUPTA [EMAIL PROTECTED] schrieb: Hi All.! I just want to know one thing that is it possible with PGSQL that, if I want to insert and execute a query from a external text file instead of giving it at the pgsql prompt? in psql, try simple \i your_file.sql to execute the

Re: [SQL] Merging rows into one result?

2006-03-11 Thread Andreas Kretschmer
Jesper K. Pedersen [EMAIL PROTECTED] schrieb: Is it possible to use SQL to merge data into one result? A theorethical example to explain: tbl_test ( id integer, information varchar(25)) id | information ---+-- 1 | Yo 2 | Go away 1 | Stay put 3 | Greetings

Re: [SQL] newbie question

2006-03-03 Thread Andreas Kretschmer
ivan marchesini [EMAIL PROTECTED] schrieb: Dear users.. I have fastly created a table in a postgresql database.. some columns where edited by hand (columns A, B, C), and some others (columns D, E, F) have been calculated as a result of mathematical equation (where the factors are the A, B, C

Re: [SQL] alter table

2006-02-15 Thread Andreas Kretschmer
Maciej Piekielniak [EMAIL PROTECTED] schrieb: Hello , How can i modify few fields with alter? ALTER TABLE fv_wystawione ALTER id_fv SET DEFAULT nextval('id_fv_seq'::text), ALTER imie SET DEFAULT ''; test=# create table xyz (id int not null); CREATE TABLE test=# create sequence

Re: [SQL] question with times and intervals

2006-01-26 Thread Andreas Kretschmer
Richard Huxton dev@archonet.com schrieb: Now (upper_time - lower_time) is the interval you want and summing them will give you your answer. Any help? Yes, thanks. But, i remember a little function that i wrote in the past: http://a-kretschmer.de/tools/time_intersect.sql And now i have a

Re: [SQL] SQL Statement Help needed

2005-12-04 Thread Andreas Kretschmer
Michael Avila [EMAIL PROTECTED] schrieb: I am not much of a SQL guru so I am having trouble trying to figure out how to format a SQL statement. I have a table with members named members. Each member has only 1 record. Then I have a table with member telephone numbers in it name

Re: [SQL] MAX, MIN and arrays

2005-11-27 Thread Andreas Kretschmer
Colton A Smith [EMAIL PROTECTED] schrieb: Hi: Let's say I have a table with a column of one-dimensional arrays. What exactly is returned when the database is queried for a maximum from that particular column? The array was the greatest average value? Let's say What du you expect?

Re: [SQL] How to change database owner in PostgreSQL 7.4?

2005-11-26 Thread Andreas Kretschmer
frank church [EMAIL PROTECTED] schrieb: Hi guys, What is the command change database owner in PostgreSQL 7.4? ALTER DATABASE foo OWNER TO blob; In general: start psql and type '\h alter database', and, more general, '\h' and '\?' HTH, Andreas -- Really, I'm not out to destroy Microsoft.

  1   2   >