Re: [SQL] Duplicate rows

2010-08-10 Thread A. Kretschmer
In response to Edward W. Rouse : > Solved. Because this is a 7.4 version and we used with oids by default, I > can use the oids instead of the ctid to remove the duplicates. Yeah, that's right ;-) Regards, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr:

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

Re: [SQL] grouping subsets

2010-07-22 Thread A. Kretschmer
In response to Rainer Stengele : > Hi, > > having a table similar to > > | 1 | B | [2010-07-15 Do] | > | 1 | B | [2010-07-16 Fr] | > |---+---+-| > | 2 | C | [2010-07-17 Sa] | > | 2 | C | [2010-07-18 So] | > |---+---+-| > | 1 | B | [2010-07-19 Mo] | > | 1 | B | [201

Re: [SQL] UUID for Postgresql 8.4

2010-07-21 Thread A. Kretschmer
In response to Trinath Somanchi : > Hi All, > > I have a column in my Postgresql database tables which need UUID. > > Is there any function in Pgsql for UUID generation. Please help me in this > regard. http://www.postgresql.org/docs/8.4/static/uuid-ossp.html Andreas -- Andreas Kretschmer Kont

Re: [SQL] How to Get Column Names from the Table

2010-07-07 Thread A. Kretschmer
In response to venkat : > Dear All, > >    How to get Column Names from Table in PostgreSQL. select column_name from information_schema.columns where table_name = 'your_table'; Regards, Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG:

Re: [SQL] error on line 1 trying to execute a script using psql

2010-06-21 Thread A. Kretschmer
In response to Tim Landscheidt : > Steven Dahlin wrote: > > > I am attempting to generate a temporary function to execute some dml with > > the following script: > > > create or replace function setuplicense() returns integer as $$ > > declare > > hwcustid integer := 0; > > retvalintege

Re: [SQL] sum an alias

2010-06-03 Thread A. Kretschmer
In response to Wes James : > In the statement: > > select > MAX(page_count_count) - MIN(page_count_count) as day_tot, > MAX(page_count_count) as day_max, sum(MAX(page_count_count) - > MIN(page_count_count)) as tot, > page_count_pdate > from page_count > group by page_count_pdate order

Re: [SQL] Question about slow queries...

2010-05-27 Thread A. Kretschmer
In response to Good, Thomas : > > Hi, > > I have a question about a query that starts out fine and over time > slows to a halt - but only on a webhosted site. Locally it does fine. > > The query is a singleton select (no joins), hitting a table with about > 5,000 records in it. Over time the q

Re: [SQL] Check set of date intervals

2010-05-27 Thread A. Kretschmer
In response to Anton Gavazuk : > Hi Andreas, > > great thanks for the response, please, answer to the list, not to me, okay? > > unfortunately function just tests every row  - it doesnt construct set of > periods which would cover choosed period. That's hard to achieve ... maybe you have to c

Re: [SQL] Check set of date intervals

2010-05-27 Thread A. Kretschmer
In response to A. Kretschmer : > > please, suggest an idea how to implement this in SQL without writing a > > procedure. > > There are a really nice additional contrib module from Jeff Davis, > described here: > > http://thoughts.j-davis.com/2010/03/09/temporal-po

Re: [SQL] Check set of date intervals

2010-05-27 Thread A. Kretschmer
In response to Anton Gavazuk : > Hi all, > > have such relation A: > > PERIOD_ID | DATE_START | DATE_END | OTHER_ATTRIBUTES... >   1     | 01.01.2010  |  01.02.2010 >   2 | 03.02.2010  |  04.03.2010 . > .. > > I want to search among periods for the set of

Re: [SQL] Rules and sequences

2010-05-26 Thread A. Kretschmer
In response to Tom Lane : > Ben Morrow writes: > > I am trying to implement a fairly standard 'audit table' setup, but > > using rules instead of triggers (since it should be more efficient). > > Rules are sufficiently tricky that I would never, ever rely on them for > auditing. Use a simple AFT

Re: [SQL] Need a help in regexp

2010-05-06 Thread A. Kretschmer
In response to Nicholas I : > Hi, > > Need a help in regexp! > > 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 > > i have written a query, > sele

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

Re: [SQL] SQL syntax rowcount value as an extra column in the result set

2010-03-25 Thread A. Kretschmer
In response to Jayadevan M : > Hi, > I don't think so. > Oracle - > SQL> select count(*) over () as ROWCOUNT , first_name from people; > > ROWCOUNT FIRST_NAME > -- > - > --- > 6 Mary

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

2010-03-24 Thread A. Kretschmer
In response to Louis-David Mitterrand : > On Wed, Mar 24, 2010 at 03:29:36PM +0100, A. Kretschmer wrote: > > In response to Louis-David Mitterrand : > > > Hi, > > > > > > I have time series data: price(id_price int, price int, created_on > > > t

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

2010-03-24 Thread A. Kretschmer
In response to Louis-David Mitterrand : > Hi, > > I have time series data: price(id_price int, price int, created_on timestamp) > > I'd like to select the latest price before, say, 2010-03-10 and the > latest price after that date. test=*# select * from price ; id_price | price | created_on

Re: [SQL] ALTER TYPE my_enum AS ENUM ADD ('label10')

2010-03-23 Thread A. Kretschmer
In response to Andreas Gaab : > I tried successfully to directly insert a further entry into table > pg_enum with the corresponding enumtypid. Do you think to directly > manipulate table pg_enum is allowed? It's maybe allowed, but not recommended. It's a system-table, not a user-table. Andreas -

Re: [SQL] ALTER TYPE my_enum AS ENUM ADD ('label10')

2010-03-22 Thread A. Kretschmer
In response to Andreas Gaab : > Hi all, > > > > I start working with enumerator types and I am wondering, if my enumerator can > later be adjusted. E.g. if I would like to add another label. AFAIK you can't. Each enum is a own type. Use a lookup-table instead and use enum's only for real stati

Re: [SQL] Postgresql format for ISO8601

2010-03-17 Thread A. Kretschmer
In response to Arnab Ghosh : > Hello Friends, > > I want to format a timstamp with timezone column with ISO 8601 FORMAT ([]- > [MM]-[DD]T[hh]:[mm]Z) > > Please let me know how to format?? I had tried with to_char but unable to > format to ISO-8601 format. Don't know much about ISO 8601, but

Re: [SQL] what exactly is a query structure?

2010-02-26 Thread A. Kretschmer
In response to silly sad : > > my own wild guess: > string constant '*' is of type "unknown" Maybe. Add a explicit cast, for instance '*'::text Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 3

Re: [SQL] what exactly is a query structure?

2010-02-25 Thread A. Kretschmer
In response to silly sad : > hello. > > Postgresql 8.3.9 > > CREATE TYPE usr_secrets AS (login TEXT, pass TEXT, shop_pass TEXT); > > CREATE OR REPLACE FUNCTION get_noobs () RETURNS SETOF usr_secrets AS $$ > BEGIN > RETURN QUERY SELECT login, '*' as pass, shop_pass FROM noob; > RETURN; > END;

Re: [SQL] join with an array

2010-02-24 Thread A. Kretschmer
In response to Louis-David Mitterrand : > Hi, > > I'm trying the following query: > > select array_agg(t1.id) from table1 t1 join table2 t2 on (t2.id = > any(array_agg)) group by t1.col1; > > but I get this error: ERROR: column "array_agg" does not exist > > I tried aliasing array_agg(t

Re: [SQL] [NOVICE] combine SQL SELECT statements into one

2010-02-01 Thread A. Kretschmer
In response to Neil Stlyz : > Good Evening, Good Morning Wherever you are whenever you may be reading this. > > I am new to this email group and have some good experience with SQL and > PostgreSQL database. > > > I am currently working on a PHP / PostgreSQL project and I came upon something > I

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-23 Thread A. Kretschmer
In response to Bryce Nesbitt : > Dear experts, > > This point is confusing me with the || operator. I've got a table with > "one column per data type", like so: > > # \d context_keyvals; > Table "public.context_keyvals" >Column|Type | Modifiers > --

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

2009-12-22 Thread A. Kretschmer
In response to Ivan Sergio Borgonovo : > Hi, > > I'd like to know if > > select sum(qty) from t where status=37; > > is > constant. > > qty is always >0. > > Is there a way to skip examining further rows and return a result > ASAP? I think no. But you can create a new table with 2 columns: s

Re: [SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread A. Kretschmer
In response to aymen marouani : > Thanks for the help, > > In deed I found those lines in my script > > "-- > -- TOC entry 25 (class 1255 OID 16409) > -- Dependencies: 6 > -- Name: bt_metap(text); Type: FUNCTION; Schema: public; Owner: postgres > -- > > CREATE FUNCTION bt_metap(relname text, OUT

Re: [SQL] SQL state 58P01 triggered by a database script execution

2009-12-09 Thread A. Kretschmer
In response to aymen marouani : > Hi, > > I have a database under Postgres v8.3 and I generated its backups script using > PGAdmin III. > I executed the same script under Postgres v8.2 in order to create the same > database but I get the following error > > " ERROR: could not access file "$libdir

Re: [SQL] How to start the "auto_explain" module

2009-11-26 Thread A. Kretschmer
In response to aymen marouani : > Hi, > In order to profile my Postgres queries, I used > the "auto_explain.log_min_duration (integer)". > How can I load the auto_explain module ? > Thanks in advance. http://www.depesz.com/index.php/2008/11/23/waiting-for-84-auto-explain/ Read that. Andreas --

Re: [SQL] Profiling tool for postgres under win32

2009-11-26 Thread A. Kretschmer
In response to aymen marouani : > Hi, > I'm using the Postgres database system version 8.3 for a J2EE application. > I'd  like to profile and monitor in "real time" the status of my queries > because I notice some slow loading. > Can anyone tell how to get a "good" profiling tool for the Postgres d

Re: [SQL] report generation from table.

2009-10-21 Thread A. Kretschmer
In response to sathiya psql : > Hi All, > > I have been searching for, Preparing report from a huge table. > > Queries am executing now are, > SELECT count(*) from HUGE_TBL where cond1, cond2; > SELECT count(*) from HUGE_TBL where cond1, cond3; > --- like this i have different conditions(10-15 di

Re: [SQL] select result into string's array

2009-10-09 Thread A. Kretschmer
In response to Alberto Asuero Arroyo : > Hi, > > I need to store the result of select into an array of string: test=*# select * from foo; t -- foo bar batz (3 rows) test=*# select array_agg(t) from foo; array_agg {foo,bar,batz} (1 row) Helps that? Andreas -- And

Re: [SQL] Need magic for a moving statistic

2009-10-02 Thread A. Kretschmer
In response to Andreas : > > A. Kretschmer schrieb: > >[...] Or simpler: > > > >test=*# select ((d-'2009-10-02'::date)/14) || '. period' as period, > >sum(value) from foo group by 1; > > > This is tricky, because you use a text-colum

Re: [SQL] right join problem

2009-10-01 Thread A. Kretschmer
In response to Greenhorn : > > > > Use a left join instead? > Hi, > Yes, but when i use a where clause on my query it only selects joined > records. :( > Thanks. Please, answer to the list and not directly to me. The WHERE-Clause works after the JOIN - so your select contains (without the WHERE)

Re: [SQL] right join problem

2009-10-01 Thread A. Kretschmer
In response to Greenhorn : > Hi, > > I'm trying to retrieve all meter_id from table meter, and for meter_id > without amount, I'd like it to show nothing, 'null'. I've used right > join here but it's not giving me my desired result. Is there another > way to do this? Here's the query I'm trying

Re: [SQL] Need magic for a moving statistic

2009-10-01 Thread A. Kretschmer
In response to Andreas : > Hi, > > I need some magic for a moving statistic that works on a rather big > table starting at a given date within the table up until now. > The statistic will count events allways on fridays over periods of 2 > weeks before ... biweekly? > So I'd like to get a line e

Re: [SQL] Can i customize null-padding for outer joins?

2009-09-30 Thread A. Kretschmer
In response to Shruthi A : > Hello, > > I have a query where I full-outer-join 2 tables, and all the columns other > than > the join column are numerical columns. For my further calculations i need to > pad the unmatched tuples with 0 (zero) instead of NULL so that I can perform > meaningful math

Re: [SQL] selecting latest record

2009-09-22 Thread A. Kretschmer
In response to Louis-David Mitterrand : > Hi, > > I have a simple table > > price(id_product, price, date) > > which records price changes for each id_product. Each time a price > changes a new tuple is created. > > What is the best way to select only the latest price of each id_product? The

Re: [SQL] ordered by join? ranked aggregate? how to?

2009-09-15 Thread A. Kretschmer
In response to wstrzalka : > What I need is to join 2 tables > > CREATE TABLE master( > id INT4 > ); > > > CREATE TABLE slave ( > master_id INT4, > rank INT4, > value TEXT); > > > What I need is to make the query: > > SELECT m.id, array_agg(s.value) AS my_problematic_array > F

Re: [SQL] ordered by join? ranked aggregate? how to?

2009-09-15 Thread A. Kretschmer
In response to wstrzalka : > What I need is to join 2 tables > > CREATE TABLE master( > id INT4 > ); > > > CREATE TABLE slave ( > master_id INT4, > rank INT4, > value TEXT); > > > What I need is to make the query: > > SELECT m.id, array_agg(s.value) AS my_problematic_array > F

Re: [SQL] Question

2009-09-03 Thread A. Kretschmer
In response to aymen marouani : > Hi for all, > What is the possible sources of the SQLState 55000 "OBJECT NOT IN PREREQUISITE > STATE" ? > The error 55000 was triggered when I executed the following query : > "select currval('"BatchTreatment_batch_treatment_id_seq"');" Within this session, first

Re: [SQL] Min and max element of an array column

2009-09-02 Thread A. Kretschmer
In response to Gianvito Pio : > Hello, > is it possible to obtain the minimum and the maximum single element of > an array column? > > Example: > [1, 2 ,5] > [3, -1, 6] > [9, 18,-4 ] > > I'd just like to make a query that gives me the min (-4) and the max(18) > of the column. Is that possible w

Re: [SQL] How to create Function which retruns username and password

2009-09-02 Thread A. Kretschmer
In response to venkat : > Dear All, > >     I want to create function which returns username and password from the > database.I have users table in the database.in that i have username and > password columns.I need return username and password using functions.it is > urgent. I am waiting for your

Re: [SQL] Selecting values from comma separated string

2009-08-26 Thread A. Kretschmer
In response to Nacef LABIDI : > Hi all, > > I want to write a function that takes as param a comma separated values string > and perform a select matching these values. > > Here is the string '1,3,7,8' > > And I wan to perform a : SELECT * FROM my_table WHERE id IN (1, 3, 7, 8); Use EXECUTE sql

Re: [SQL] Ask About SQL

2009-08-19 Thread A. Kretschmer
In response to Otniel Michael : > Hi All. > > Can help to create sql queries for this data : > > tabel A > field1, field2, field3 > x1, y1, 5 > x1, y2, 1 > x2, y1, 2 > x2, y3, 4 > x1, y3, 4 > > I want to get 2 record with the max value at field3 for each k

Re: [SQL] Import (.CVS File) to postgreSql

2009-08-10 Thread A. Kretschmer
In response to Premila Devi : > Dear All, > > > > I like to import (.CVS File) to postgreSql.Could anyone help me. May I know, > what the requirement. You can use the COPY-command for that, see the doc. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr:

Re: [SQL] two records per row from query

2009-08-06 Thread A. Kretschmer
In response to John : > Thanks - the sessionid's in fact do match. It's just that I can have more > than two (2) classes per sessionid. So mytable might look like: > select * from mytable > 1 2009/01/01 2101 > 2 2009/01/02 2101 > 3 2009/02/05 2101 > 4 2009/02/15 2101 > 5 2009/02/25 2101

Re: [SQL] two records per row from query

2009-08-05 Thread A. Kretschmer
In response to John : > mytable > pkid > class_date. > sessionid > > select * from mytable > 1 2009/01/01 2101 > 2 2009/01/02 2101 > > I would like an SQL that would produce > > newtable > pkid, > class_date1, > class_date2, > sessionid1, > sessionid2 > > Select * from newtable > > 1 2009/01/0

Re: [SQL] Need magical advice for counting NOTHING

2009-07-23 Thread A. Kretschmer
In response to A. Kretschmer : > test=*# select foo.user_name, foo.log_type, sum(case when log_type_fk is > not null then 1 else 0 end) from (select user_id, user_name, > log_type_id, log_type from users cross join log_type) foo full join log > on ((foo.user_id, foo.log_type_id)=

Re: [SQL] Need magical advice for counting NOTHING

2009-07-22 Thread A. Kretschmer
In response to Andreas : > Hi, > The source select counts log-events per user. > All is well when a user has at least one event per log_type in the log > within a given timespan. > If one log_type is missing COUNT() has nothing to count and there is > expectedly no result line that says 0. > BUT

Re: [SQL] uniqueness constraint with NULLs

2009-06-29 Thread A. Kretschmer
In response to Leo Mannhart : > On Mon, 2009-06-29 at 17:08 +1000, Robert Edwards wrote: > > A. Kretschmer wrote: > > > In response to Robert Edwards : > > >> Can anyone suggest a way that I can impose uniqueness on a and b when > > >> c is NULL?

Re: [SQL] uniqueness constraint with NULLs

2009-06-29 Thread A. Kretschmer
In response to Robert Edwards : > A. Kretschmer wrote: > >In response to Robert Edwards : > >>Can anyone suggest a way that I can impose uniqueness on a and b when > >>c is NULL? > > > >Sure, use a functional index: > > > >test=# create table bob

Re: [SQL] uniqueness constraint with NULLs

2009-06-28 Thread A. Kretschmer
In response to Robert Edwards : > Can anyone suggest a way that I can impose uniqueness on a and b when > c is NULL? Sure, use a functional index: test=# create table bobtest (a int, b int, c int); CREATE TABLE test=*# create unique index idx_bobtest on bobtest(a,b,coalesce(c::text,'NULL')); CREA

Re: [SQL] dynamic columns in a query

2009-06-11 Thread A. Kretschmer
In response to Jyoti Seth : > Hi All, > > Is there any way in postgres to write a query to display the result in > matrix form. (where column names are dynamic) > > For eg. > > > Employee Name Client1 Client2 Client3 Client4 > Emp1 100 102 90

Re: [SQL] Avoiding "will create implicit index" NOTICE

2009-06-11 Thread A. Kretschmer
In response to Bryce Nesbitt : > Hmm, no. I still get the NOTICE. How can I create the primary key > without triggering a NOTICE? Sure, set client_min_messages='...' test=*# create table bla(id int primary key); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "bla_pkey" for table

Re: [SQL] complex column definition in query

2009-06-03 Thread A. Kretschmer
In response to Seb : > > Thanks to all that responded on and off list. Is it necessary to ensure > that the "FROM" part of the two queries are exactly the same (the real No, but both queries should return the same columns (count, typ, order). Andreas -- Andreas Kretschmer Kontakt: Heynitz: 03

Re: [SQL] Creation of file from postgresql function

2009-06-03 Thread A. Kretschmer
In response to Jyoti Seth : > If anyone has idea about this problem or know any other alternative to > create a file from postgres function, please let me know. > > Thanks, > Jyoti On server-side? You need a function written in an untrusted language, for instance pl/perlU or plsh. Regards, And

Re: [SQL] complex column definition in query

2009-06-03 Thread A. Kretschmer
In response to Seb : > Hi, > > Say we have a table: > > SELECT * FROM weather; > city | temp_lo | temp_hi | prcp > ---+-+-+--- > San Francisco | 46 | 50 | 0.25 > San Francisco | 43 | 57 |0 > Hayward | 37 | 54

Re: [SQL] Add column by using SELECT statement

2009-02-24 Thread A. Kretschmer
In response to John Zhang : > Hi all, > > I was wondering how I can add a column and populate it by some query. > > For example: > TblA (Id, fld1) > TblB(Id, fld1, fld2) > > I have a query: > SELECT b.fld2 > FROM tblB b > WHERE condition1 > > what I want to do is add a column in tblA: fld2 > an

Re: [SQL] How concat 3 strings if 2 are not empty?

2009-02-18 Thread A. Kretschmer
In response to Andreas : > Hi, > > I'd like a function that concats 3 string parameters on condition the > 1st and 3rd are NOT empty or NULL. > xCat (s1, s2, s3) > s2 would be a connector that appears only if s1 and s3 are set. > > NULL and an empty string '' should be handled the same. > > e.g

Re: [SQL] Is this possible?

2009-02-17 Thread A. Kretschmer
In response to johnf : > Wow that looks like it will work - thanks. > When you say 'within a transaction' do you mean starting with > "Begin" and using "commit"? Exactly. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF60

Re: [SQL] Is this possible?

2009-02-16 Thread A. Kretschmer
In response to johnf : > Hi, > I'm not to sure this is possible. > > I need to replace a primary key (pkid) with the value of a different field. > I have > pkid = 200 > attendid = 301 > > I need the pkid = 301 > > But there may or may not be a pkid that already exist that has the value of >

Re: [SQL] Data length and data precision

2009-02-06 Thread A. Kretschmer
In response to Bart van Houdt : > Hi all, > > I'm trying to write some code to make a 'fingerprint' of a database. This to > compare a customer database with a reference database of our own. > Therefore I'm trying to retrieve information like this: > -Table name > pg_class.relname where relkind

Re: [SQL] How to Import Excel Into PostgreSQL database

2008-12-24 Thread A. Kretschmer
In response to Venkat Rao Tammineni : > Dear All, > > > > I using PosgreSql8.1.I want to import Excel into PostgreSQL database. Is > there any way to import ? . Create a CSV-File and import that with COPY. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (

Re: [SQL] archiving or versioning data?

2008-12-16 Thread A. Kretschmer
In response to Louis-David Mitterrand : > Hi, > > I'd like to find a way to archive versions of my data in an elegant and > extensible way. > > When a user modifies certain entries I'd like the database to keep the > previous versions (or a limited, definable number of versions). > Wiki-style. >

Re: [SQL] unique constraint on views

2008-12-10 Thread A. Kretschmer
In response to Jyoti Seth : > Hi All, > > Is it possible to add unique constraint on updateable views in postgres? Add the constraint to the base-table. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA

Re: [SQL] custom serial number

2008-11-19 Thread A. Kretschmer
am Wed, dem 19.11.2008, um 0:52:07 -0800 mailte mahmoud ewiwi folgendes: > Thank you very much, it works fine with me , but how can i restart the > sequence at the start of each month, or should i do it programatically? For instance, check if a record for the actual month are in the table. If n

Re: [SQL] custom serial number

2008-11-18 Thread A. Kretschmer
am Tue, dem 18.11.2008, um 20:56:07 -0800 mailte mahmoud ewiwi folgendes: > Thank you hery much, it works fine with me , but how can i restart the > sequence at the start of each month, or should i do it programatically? Please answer to the list and not to me. You can write a function for that

Re: [SQL] custom serial number

2008-11-18 Thread A. Kretschmer
am Tue, dem 18.11.2008, um 10:37:23 +0100 mailte Pavel Stehule folgendes: > Hello > > what do you wont to do exactly? > > you can try - > > create sequence s; > postgres=# create sequence s; > CREATE SEQUENCE > postgres=# select to_char(current_date, 'mmdd') || > trim(to_char(nextval('s'),

Re: [SQL] custom serial number

2008-11-18 Thread A. Kretschmer
am Tue, dem 18.11.2008, um 1:09:44 -0800 mailte mahmoud ewiwi folgendes: > hi gurus > i have a problem in generating serial number with the form mm how can > i do that? test=# create temporary sequence foo; CREATE SEQUENCE test=# select to_char(current_date, 'mm')||trim(to_char(next

Re: [SQL] trapping a NULL querystring error

2008-11-14 Thread A. Kretschmer
am Fri, dem 14.11.2008, um 7:29:32 -0300 mailte Gerardo Herzig folgendes: > Hi all. Inside a plpgsql function, i have a EXECUTE statement, which > sometimes seems to be receiving a null querystring. > > Can i check that condition in a BEGIN..EXCEPTION block? Under which > condition? > > Or shou

Re: [SQL] Postgres version of all_ind_cols

2008-11-11 Thread A. Kretschmer
am Tue, dem 11.11.2008, um 14:57:20 +0100 mailte Bart van Houdt folgendes: > Hi all, Please, don't hijack other threads. > > This might be a stupid question, but I wasn't able to find any information on > it, so here it goes: > Oracle knows a view which contains information about indexed colu

Re: [SQL] Converting between UUID and VARCHAR

2008-11-10 Thread A. Kretschmer
am Mon, dem 10.11.2008, um 15:34:10 +0100 mailte Mario Splivalo folgendes: > I have a table, like this: > > CREATE TABLE t1 > ( > u1 character varying > ) > > And some data inside: > > INSERT INTO t1 (u1) VALUES ('62d6b434-7dfd-4b3b-b1bf-87f6c20c10dd'); > INSERT INTO t1 (u1) VALUES ('e3fee596

Re: [SQL] Date Index

2008-10-31 Thread A. Kretschmer
am Thu, dem 30.10.2008, um 14:49:16 -0600 mailte Ryan Hansen folgendes: > Hey all, > > > > I?m apparently too lazy to figure this out on my own so maybe one of you can > just make it easy on me. J > > > > I want to index a timestamp field but I only want the index to include the > -mm

Re: [SQL] generating date sequences

2008-10-20 Thread A. Kretschmer
am Mon, dem 20.10.2008, um 15:24:38 +0200 mailte Patrick Scharrenberg folgendes: > Hi! > Is there a simple way to generate sequences of dates like the following? > "2008-07-03 00:00:00" > "2008-07-04 00:00:00" > "2008-07-05 00:00:00" > "2008-07-06 00:00:00" > Sure: test

Re: [SQL] Insert a space between each character

2008-09-16 Thread A. Kretschmer
am Wed, dem 17.09.2008, um 11:49:27 +0530 mailte Nicholas I folgendes: > Hi, > > can anybody help me, to insert a space between each character in postgresql. > > for example, > > ABC > > output > A B C write a function in plpgsql, you can use string-function like substr to split the st

Re: [SQL] INSERT or UPDATE

2008-08-18 Thread A. Kretschmer
am Mon, dem 18.08.2008, um 9:44:48 +0200 mailte Andreas Kraftl folgendes: > But there is also the possibility, that one row is available. Means that > i need an UPDATE instead of the INSERT. > > Is it in SQL possible to decide if there is an UPDATE or an INSERT or > must i program something with

Re: [SQL] A table with two names or table alias

2008-07-25 Thread A. Kretschmer
am Fri, dem 25.07.2008, um 14:12:47 +0200 mailte Tk421 folgendes: >Can I create a table name alias? > >What i want is to access the same table with two different names. An > example: > >I've the table CITY with fields code and name. I want to know if i > can create an alternative n

Re: [SQL] truncate vs. delete

2008-07-24 Thread A. Kretschmer
am Thu, dem 24.07.2008, um 10:01:46 -0400 mailte Emi Lu folgendes: > A. Kretschmer wrote: > >am Thu, dem 24.07.2008, um 9:47:48 -0400 mailte Emi Lu folgendes: > >>I found a link for SQL Server, it applies to PostgreSQL 8.0.x as well? > >>http://vadivel.blogspot.com

Re: [SQL] truncate vs. delete

2008-07-24 Thread A. Kretschmer
am Thu, dem 24.07.2008, um 9:47:48 -0400 mailte Emi Lu folgendes: > I found a link for SQL Server, it applies to PostgreSQL 8.0.x as well? > http://vadivel.blogspot.com/2004/06/delete-vs-truncate-statement.html Not realy, for instance, pg can rollback a truncate, and a sequence are not reset.

Re: [SQL] Select default values

2008-07-23 Thread A. Kretschmer
am Wed, dem 23.07.2008, um 10:32:58 +0200 mailte Maximilian Tyrtania folgendes: > Hi there, just a quickie: Is there a way to select all default values of a > given table? Something like "Select Default values from sometable" ? > Unfortunately this syntax doesn't seem to be supported. I know i can

Re: [SQL] index for group by

2008-07-22 Thread A. Kretschmer
am Tue, dem 22.07.2008, um 13:18:30 +0200 mailte Patrick Scharrenberg folgendes: > Hi, > > is there a way to speedup "group by" queries with an index? > > In particular if I have a table like this: > > CREATE TABLE data > ( >id1 integer, >id2 integer, >somedata character varying, >

Re: [SQL] How to Select a Tupl by Nearest Date

2008-07-22 Thread A. Kretschmer
am Tue, dem 22.07.2008, um 10:42:56 +0200 mailte Christian Kindler folgendes: > Hello > > Assume I have a table like > create table foo ( > id serial, > date foodate, > primary key(id) > ); > > with 2 tupls > insert into foo(foodate) values('2008-07-07'); --id = 1 > insert into foo(foodate

Re: [SQL] How to GROUP results BY month

2008-07-15 Thread A. Kretschmer
am Tue, dem 15.07.2008, um 18:15:07 -0700 mailte Mark Roberts folgendes: > > On Tue, 2008-07-15 at 14:31 +0200, A. Kretschmer wrote: > > am Tue, dem 15.07.2008, um 13:12:39 +0100 mailte Oliveiros Cristina > > folgendes: > > > Howdy, all, > > > > >

Re: [SQL] How to GROUP results BY month

2008-07-15 Thread A. Kretschmer
am Tue, dem 15.07.2008, um 15:57:54 -0600 mailte Scott Marlowe folgendes: > On Tue, Jul 15, 2008 at 6:12 AM, Oliveiros Cristina > <[EMAIL PROTECTED]> wrote: > > Howdy, all, > > > > I have a problem. > > > > I have a table which one of the fields is of type date. > > > > I need to obtain the totals

Re: [SQL] How to GROUP results BY month

2008-07-15 Thread A. Kretschmer
am Tue, dem 15.07.2008, um 13:12:39 +0100 mailte Oliveiros Cristina folgendes: > Howdy, all, > > I have a problem. > > I have a table which one of the fields is of type date. > > I need to obtain the totals of the other fields in a by-month basis > IS there any easy way to do this using the GR

Re: [SQL] how to perform minus (-) operation in a dynamic query

2008-07-13 Thread A. Kretschmer
am Mon, dem 14.07.2008, um 11:21:17 +0530 mailte Anoop G folgendes: > SELECT mf,sf,(mf mf * comm /100) (sf sf * comm/100) as flt_claim; ^^^ ^^^ ^^^ That's not valid SQL. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (m

Re: [SQL] Problem in dynamic query execution in plpgsql

2008-07-10 Thread A. Kretschmer
am Thu, dem 10.07.2008, um 18:25:38 +0530 mailte Anoop G folgendes: > my problems are: > > 1 problem : in RAISE NOTICE query string is print like this, > > How i can put the dates in single quote in a dynamic query string? Use more quotes *g*: Example: test=*# create or replace function my_fo

Re: [SQL] i can't connect after some periode

2008-07-10 Thread A. Kretschmer
am Thu, dem 10.07.2008, um 13:57:15 +0700 mailte aldy folgendes: > hi all, First, don't hijack other threads, your mail contains a References-header: References: <[EMAIL PROTECTED]> But this message contains to an other thread. In other words: don't answer to an email by deleting the body and c

Re: [SQL] Profiling postgresql queries

2008-07-09 Thread A. Kretschmer
am Wed, dem 09.07.2008, um 10:22:09 +0200 mailte Nacef LABIDI folgendes: > Hi all, > I was wondering if there is any GUI or command line based tool running on > windows that could help me to profile PostgreSQL queries performance. It > should You can use EXPLAIN ANALYSE to analyse your queries (

Re: [SQL] exclude part of result

2008-06-26 Thread A. Kretschmer
am Fri, dem 27.06.2008, um 0:35:38 +0100 mailte Tarlika Elisabeth Schmitz folgendes: > > SELECT DISTINCT a, b, c, now(), count(item_pk) > FROM product > LEFT JOIN item ON item.product_fk = product_pk > WHERE ... > GROUP BY a, b, c > > > I have another table 'navigation' which also has the co

Re: [SQL] "TZ"/"tz" not supported

2008-06-19 Thread A. Kretschmer
am Fri, dem 20.06.2008, um 8:35:10 +0200 mailte Peter Kovacs folgendes: > Thank you, Andreas! Your advice is very useful to me. > > I would still be interested why "TZ" is not accepted in the format string. I think because TZ is only useful for displaying a timestamptz and not for internal repr

Re: [SQL] "TZ"/"tz" not supported

2008-06-19 Thread A. Kretschmer
am Fri, dem 20.06.2008, um 7:51:50 +0200 mailte Peter Kovacs folgendes: > Hi, > > Execution of the following statement aborts with the error message in > the Subject: > > select to_timestamp('2008-06-20 02:30:00 GMT', '-MM-DD HH24:MI:SS TZ'); You can use: test=*# select '2008-06-20 02:30:

Re: [SQL] Results with leading zero

2008-06-15 Thread A. Kretschmer
am Mon, dem 16.06.2008, um 11:48:01 +1000 mailte novice folgendes: > I have a table > > CREATE TABLE problem ( > problem_id integer, > solution_count integer > ); > > INSERT INTO problem VALUES (1001, 4); > INSERT INTO problem VALUES (1012, 11); > > SELECT * from problem; > > problem_i

Re: [SQL] Results with leading zero

2008-06-15 Thread A. Kretschmer
am Mon, dem 16.06.2008, um 11:48:01 +1000 mailte novice folgendes: > I have a table > > CREATE TABLE problem ( > problem_id integer, > solution_count integer > ); > > INSERT INTO problem VALUES (1001, 4); > INSERT INTO problem VALUES (1012, 11); > > SELECT * from problem; > > problem_i

Re: [SQL] Update and trigger

2008-06-11 Thread A. Kretschmer
ger can't see the the data in NEW and OLD. And a row level trigger fires for every row. > > On Tue, Jun 10, 2008 at 10:21 PM, A. Kretschmer < > [EMAIL PROTECTED]> wrote: Please, no silly top posting with fullquote below, i'm reading from top to bottom. Andreas -- An

Re: [SQL] Update and trigger

2008-06-10 Thread A. Kretschmer
am Tue, dem 10.06.2008, um 18:45:51 -0700 mailte Medi Montaseri folgendes: > Hi, > > I need to increament a counter such as myTable.Counter of type integer > everytime myTable.status a boolean column is updated. Can you help me complete > this... > > create trigger counter_trigger after update o

Re: [SQL] Nextval & Currval

2008-06-10 Thread A. Kretschmer
am Tue, dem 10.06.2008, um 11:56:39 +0200 mailte Shavonne Marietta Wijesinghe folgendes: > Hello > > I'm using Nextval and Currval in my ASP programme. But everytime i run the > code > only the nextval record is inserted and the currval record is lost. I wrote > the > INSERT INTO in the log a

Re: [SQL] returning results from an update for joining other tables

2008-06-10 Thread A. Kretschmer
am Tue, dem 10.06.2008, um 10:50:52 +0200 mailte Patrick Scharrenberg folgendes: > Hi! > > I have a table containing data and a column which holds information on > which compute-node processes the data. In a given interval I'd like to > request some data from this table and mark these returned r

Re: [SQL] Problems with a Query between 7.3 and 8.2

2008-06-04 Thread A. Kretschmer
am Wed, dem 04.06.2008, um 12:47:41 +0200 mailte Holm Tiffe folgendes: > > Hi, > > I have to migrate an existing System from PostgreSQL 7 and 8.2. > There is a query that I'm not fully understand. It is running with > 7.3.21 generating two notices about missing FROM's: > > select poid,prodort.b

  1   2   3   >