Re: [SQL] postgresql multiple insert slow

2004-06-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Michael L. Hostbaek" <[EMAIL PROTECTED]> writes: > Hello, > I've got a table in an oracle database with approx. 10 records, that > I'd like to put into a table in a postgresql database. (This should be > done a couple of times per week) > I have written a sho

Re: [SQL] Export tab delimited from mysql to postgres.

2004-10-11 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Theo Galanakis <[EMAIL PROTECTED]> writes: > Has anyone been able to export and import a tab delimited file from mysql to > postgres successfully? > This is my dilemma which I have posted on mysql sites with no response, > however postgres users may have come across

Re: [SQL] Question about a select

2005-01-23 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Kretschmer Andreas <[EMAIL PROTECTED]> writes: > Hi, > I have a table with this columns: machine, date and area. > Now i need a view with machine an week, calculated from date, and > sum(area), where date between CURRENT_DATE and now+N days. > Okay, this is not the

Re: [SQL] DROP TYPE without error?

2005-04-07 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Mischa <[EMAIL PROTECTED]> writes: > I've got a similar request for other objects that do/do not exist. > Maybe it's just that I got lazy using MSSQL, but it sure was convenient > to have: >IF object_id('WorkTable') IS NULL >CREATE TABLE WorkTable(... >

Re: [SQL] Trimming the cost of ORDER BY in a simple query

2005-05-03 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Ragnar Hafstað <[EMAIL PROTECTED]> writes: > 20 ms does not sound like a big problem. > if 20 ms is really too much for you, and add_date IS a timestamp, > you might think about adding a date column , maintained > by triggers of by your application, and add an inde

Re: [SQL] Make COUNT(*) Faster?

2005-07-10 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Dawid Kuroczko <[EMAIL PROTECTED]> writes: > Use > EXPLAIN SELECT * FROM yourcountedtable; > Planner seems to track estimated statistics on-the-fly. :) > You can even wrap EXPLAIN SELECT in a pgsql function if you > need it. Do you know how to do that? A functio

Re: [SQL] POSIX Regular Expression question

2005-09-05 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Peter Eisentraut <[EMAIL PROTECTED]> writes: > Presumably, > colname ~ '^[A-Za-z]*$' > If you want to be independent of locale issues, then you'd have to enumerate > all the letters instead of using a range specification. How so? I thought character ranges

Re: [SQL] ERROR: syntax error at or near "select" at character 9

2005-09-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Stephan Szabo <[EMAIL PROTECTED]> writes: > On Fri, 2 Sep 2005, [ISO-8859-2] Graf László wrote: >> >> CREATE FUNCTION test_verif() RETURNS trigger AS $test_verif$ >> BEGIN >> NEW.id := select nextval('test_azon_seq'); > I think you want to remove select here, you'

Re: [SQL] Merging lines with NULLs (with example data)

2005-10-25 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, MaXX <[EMAIL PROTECTED]> writes: > How can I "merge" this > gday,count_udp,count_tcp > '2005-10-20','','2' > '2005-10-20','3','' > '2005-10-21','','1' > '2005-10-21','5','' > into that: > gday,count_udp,count_tcp > '2005-10-20','3','2' > '2005-10-21','5','1' > in

Re: [SQL] serial in output

2005-11-04 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "alessandra de gregorio" <[EMAIL PROTECTED]> writes: > Hi, > What function should I use to get a serial number, together with my results, > from a query? > Ex. Of output I want: > 1 ooo pp ij > 2 hou joo iu > 3 bhi ft yh

Re: [SQL] how to update table to make dup values distinct

2005-11-11 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, george young writes: > [PostgreSQL 7.4RC2 on i686-pc-linux-gnu](I know, I know... must upgrade soon) > I have a table mytable like: > i | txt > ---+--- > 1 | the > 2 | the > 3 | rain > 4 | in > 5 | mainly > 6 | spain > 7 | stays > 8 | mainly > 9 |

Re: [SQL] Date Interval

2005-12-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Bruce Momjian writes: > Magdalena Komorowska wrote: >> Hi, >> I hale a problem with counting interwal and I can't find what to do with >> this. >> I have two fields in the table: >> Column | Type | Modifiers >> -+-+--- >> d

[SQL] Composite primary keys

2009-06-23 Thread Harald Fuchs
I tried to throw some invalid SQL to PostgreSQL and found its reaction confusing: $ psql test psql (8.4beta2) Type "help" for help. test=# CREATE TABLE t1 ( test(# id serial NOT NULL, test(# name text NOT NULL, test(# PRIMARY KEY (id) test(# ); CREATE TABLE te

Re: [SQL] Composite primary keys

2009-06-24 Thread Harald Fuchs
In article <24680.1245784...@sss.pgh.pa.us>, Tom Lane writes: > Joshua Tolley writes: >> Primary keys are NOT NULL and UNIQUE. You can't have null values in a primary >> key. > On reflection I think the OP's beef is that we complain about this: > regression=# create table t (f1 int null not nu

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Harald Fuchs
In article , "Philippe Lang" writes: > Thanks for your answer. Si there a built-in function that would allow > generating the sort path based on the value of the lookup column, > instead of the id, which has no meaning at all? > If yes, we would get instead: > depth | id | lookup | parent_id

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

2009-07-31 Thread Harald Fuchs
In article <4a71f9cb.9050...@encs.concordia.ca>, Emi Lu writes: > 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 |

Re: [SQL] Schema's, roles and privileges

2009-11-30 Thread Harald Fuchs
In article <200911300708.12397.akla...@comcast.net>, Adrian Klaver writes: > From a quick look it would seem the easiest solution would be to change the > search_path in: > citext.sql.in > uuid-ossp.sql.in > These files are found in the respective contrib directories. Uninstall the > modules.

[SQL] Window function trouble

2009-12-10 Thread Harald Fuchs
I have a table like this: CREATE TABLE tbl ( host text NOT NULL, adr ip4 NOT NULL, usr text NOT NULL ); (ip4 is from the ip4r contrib module) and I want the number of entries per address and per user: SELECT adr, usr, count(*) FROM tbl WHERE host = ? AND adr <<= ? GRO

Re: [SQL] Window function trouble

2009-12-10 Thread Harald Fuchs
In article , Harald Fuchs writes: > The other users for one address are gone. Does anyone know why? Update: they are not gone, but they've moved to the end of the result set. Apparently the CASE expression is named "adr" unless named otherwise, and the result set is sorted

Re: [SQL] Window function trouble

2009-12-10 Thread Harald Fuchs
In article <25983.1260468...@sss.pgh.pa.us>, Tom Lane writes: > The SQL standard says the default name for any output column other > than a simple column reference is implementation-dependent. I think > our implementation involves looking at the default value for a CASE. Thanks for the clarific

Re: [SQL] Window function trouble

2009-12-11 Thread Harald Fuchs
In article <28855.1260486...@sss.pgh.pa.us>, Tom Lane writes: > Harald Fuchs writes: >> That being said, I still think that PostgreSQL could do better - how >> about naming expression columns so that they are distinct from column >> names? > Even though the rul

Re: [SQL] Is there any function to test for numeric ips?

2009-12-11 Thread Harald Fuchs
In article , "Oliveiros C," writes: > Dear All, > I have a table with host names and some happen to be numeric IPs. > I would like to be able to filter out the later. > Is there any function pre-defined in the system that can test a particular > text > type value to see if it is a numeric ip

Re: [SQL] Cascading sum in tree with CTE?

2010-04-09 Thread Harald Fuchs
In article <4bbed49d.7080...@krap.dk>, Svenne Krap writes: > Hi . > My problem resembles this: > I have the following (simplified) tables > 1) create table account ( id serial, name varchar, parent_id int4 > references account, primary key (id)) > 2) create table transaction (id serial, accoun

Re: [SQL] LEFT OUTER JOIN issue

2010-04-21 Thread Harald Fuchs
In article <987929295d1345b5bce249f42730c...@marktestcr.marktest.pt>, "Oliveiros" writes: > Hi, Thomas. > I believe it is because of your WHERE clause, which is filtering out the nulls > from hp table. > According to > WHERE > hp.poste_idposte = 275 > You only want registers that have hp.post

Re: [SQL] inner join and limit

2010-06-03 Thread Harald Fuchs
In article <4bfd5bc0.90...@unipex.it>, Michele Petrazzo - Unipex writes: > Hi list, > I have two table that are so represented: > t1: > id int primary key > ... other > t2: > id int primary key > t1id int fk(t1.id) > somedate date > ... other > data t1: > 1 | abcde > 2 | fghi > data t2: > 1 |

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

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

Re: [SQL] self join

2011-05-15 Thread Harald Fuchs
In article , Jasen Betts writes: > On 2011-05-14, Seb wrote: >> Hi, >> >> This probably reflects my confusion with how self joins work. >> >> Suppose we have this table: >> If I want to get a table with records where none of the values in column >> b are found in column a, I thought this shou

Re: [SQL] Usage of function retruning record in query

2011-07-04 Thread Harald Fuchs
In article <1309762075448-4549140.p...@n5.nabble.com>, gmb writes: > Hi I have a stored function returning a record consisting of two field, > and receiving as input a single identifier: CREATE FUNCTION calcvalues(IN > itemid VACHAR, OUT calcval1 NUMERIC, OUT calcval2 NUMERIC) RETURNS > record...

Re: [SQL] exclusion constraint for ranges of IP

2011-08-21 Thread Harald Fuchs
In article , Herouth Maoz writes: > Hi, > I'm designing a new database. One of the table contains allowed IP ranges for > a customer (Fields: customer_id, from_ip, to_ip) which is intended to check - > if an incoming connection's originating IP number falls within the range, it > is identifie

Re: [SQL] exclusion constraint for ranges of IP

2011-08-22 Thread Harald Fuchs
In article <1343d11c-6f58-4653-8ea8-837c01e61...@unicell.co.il>, Herouth Maoz writes: > On 22/08/2011, at 01:19, Harald Fuchs wrote: >> In article , >> Herouth Maoz writes: >> >>> Hi, >>> I'm designing a new database. One of the table cont

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] Group by on Date

2011-10-16 Thread Harald Fuchs
In article <1318661510830-4904685.p...@n5.nabble.com>, "maya.more" writes: > 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/201

Re: [SQL] CTE or Subselect and outer joins not behaving as expected?

2011-10-25 Thread Harald Fuchs
In article , Joel Stevenson writes: > select tally_table. tally_mon, met.datum > from ( > select distinct date_trunc( 'month', '2011-06-01'::date + tally_day )::date > as tally_mon > from generate_series( 0, ( select current_date - '2011-06-01'::date ) ) as > tally_day > ) as tally_table fu

Re: [SQL] optimize self-join query

2011-10-28 Thread Harald Fuchs
In article , Ty Busby writes: > I have a table that stores a very large starting number called > epc_start_numeric and a quantity. I've apparently built the most > inefficient query possible for doing the job I need: find out if any > records overlap. Imagine the epc_start_numeric + quantity >

Re: [SQL] DBD::Pg ... how would I format this prepare?

2006-07-31 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Marc G. Fournier" <[EMAIL PROTECTED]> writes: > I need to do: > NOW() + '2 day'::interval > where 2 is a variable ... > if I do: > NOW() + '? day'::interval > it, of course, takes the ? as a literal ... so is there some way I can > do this such that I can do t

Re: [SQL] Need a SQL to create sets of hobbies

2006-09-20 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "CN" <[EMAIL PROTECTED]> writes: > select * from x1; > name | hobby > ---+-- > John | music > John | arts > Bob | arts > Bob | music > Rocky | computer > Steve | arts > Steve | football > Tom | computer > Tom | music > (9 rows)

Re: [SQL] Having difficulty writing a "best-fit" query..

2007-10-17 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Jamie Tufnell" <[EMAIL PROTECTED]> writes: > Hi list, > I have a many-to-many relationship between movies and genres and, in the link > table I have a third field called which orders the "appropriateness" of the > relations within each movie. > For example: > mo

Re: [SQL] request for help with COPY syntax

2007-10-24 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Chuck D." <[EMAIL PROTECTED]> writes: > On October 23, 2007 08:51:18 pm you wrote: >> >> I got it to work with your sample data by using the COPY command as >> follows: COPY geo.orig_city_maxmind >> FROM '/home/www/geo/DATA/MAXMIND.com/cities_no_header.txt' >> CSV

Re: [SQL] JOINing based on whether an IP address is contained within a CIDR range?

2007-10-26 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Jamie Tufnell" <[EMAIL PROTECTED]> writes: > Hi, > I am storing a log of HTTP requests in a database table (including IP > address): > http_log: id(PK), path, time, ip > I have another table that contains CIDR ranges and names for them: > network_names: id(PK),

Re: [SQL] Add a ROWCOUNT to the output of a select.

2008-05-14 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Robins Tharakan" <[EMAIL PROTECTED]> writes: > While we could always check for the query performance reasons, I > rather think that this is an overkill for the purpose of mere line > numbers. > If such queries don't change frequently, you could be better off > usi

Re: [SQL] Enumerated (enum) types

2008-05-27 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Michael Lourant" <[EMAIL PROTECTED]> writes: > Type Safety > Enumerated types are completely separate data types and may not be compared > with each other. ... > An Alternative Way To Do The Same > Instead of using an enum type we can set up a CHECK CONSTRAINT

Re: [SQL] exclude part of result

2008-06-27 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Tarlika Elisabeth Schmitz <[EMAIL PROTECTED]> writes: > PRODUCT table : > A B C > 100 200 300 > 100 200 301 > 100 205 300 > 100 205 301 > NAVIGATION table > A B C #ITEMS > 100 200 300 5 > 100 200 301 6 > My query needs to return > 100 205 300 #items > 100 205 30

Re: [SQL] regexp_replace and UTF8

2009-01-30 Thread Harald Fuchs
In article <87ljstm4eq@oxford.xeocode.com>, Gregory Stark writes: > "Bart Degryse" writes: >> Hi, >> I have a text field with data like this: 'de patiënt niet' >> Can anyone help me fix this or point me to a better approach. >> By the way, changing the way data is put into the field is >> u

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Harald Fuchs
In article <162867790905180410n670062b0ud2d7fdd0e652...@mail.gmail.com>, Pavel Stehule writes: > Hello > postgres=# create or replace function sum_items(bigint[]) returns > bigint as $$ select sum($1[i])::bigint from > generate_series(array_lower($1,1), array_upper($1,1)) g(i)$$ language > sql im