Re: [SQL] unused columns in copy

2009-07-20 Thread Marcin Stępnicki
On Mon, Jul 20, 2009 at 3:22 PM, chester c young wrote: > > is there a way for COPY FROM to ignore unused columns in CSV? > > in other words, if table t1 has columns c1, c2, and if csv has columns c1, > c3, c2, could I do something like > > COPY t1( c1, null, c2 ) FROM 'file.csv' No, but you can

Re: [SQL] Oracle to PostgreSQL

2009-03-16 Thread Marcin Stępnicki
On Mon, Mar 16, 2009 at 12:35 AM, Greenhorn wrote: > Hi, > > I have almost 1300 files from Oracle (no access to oracle server).  I > have to create the tables and data as follows. (...) snip (...) > Any recommendation is greatly appreciated :) Try here: http://wiki.postgresql.org/wiki/Converting

[SQL] xpath_table feature

2009-03-13 Thread Marcin Stępnicki
Hello. I've read the documentation, I think I have even found the article after which this part of documentation has been updated (http://markmail.org/thread/ys2a2yph5zgmnls5) but I still can't write appropriate query :-(. Let's consider the following: create table test_xml (id serial primary k

Re: [SQL] alter column from varchar(32) to varchar(255) without view re-creation

2009-02-24 Thread Marcin Stępnicki
On Tue, Feb 24, 2009 at 4:27 PM, Emi Lu wrote: > Good morning, > > I am using PostgreSQL 8.0.15. > > Is there a way that I can easily alter column type from varchar(32) to > varchar(255) but do not have to worry about views dependent on it? You should test it carefully and it is considered a bad

Re: [SQL] Permission denied for create table

2008-11-23 Thread Marcin Stępnicki
On Mon, Nov 24, 2008 at 7:50 AM, Pascal Tufenkji <[EMAIL PROTECTED]> wrote: > sql073751=> SELECT * into emp2 from emp; > > ERROR: emp: permission denied > Creating a normal table works fine, but creating a table with subqueries is > giving me "permission denied" > > Anyone got a clue? You don't

Re: [SQL] How to change a view's owner in postgres

2008-08-01 Thread Marcin Stępnicki
On Fri, Aug 1, 2008 at 11:41 AM, Anoop G <[EMAIL PROTECTED]> wrote: > How to change a view's owner in postgres? ALTER TABLE view_name OWNER TO new_owner; -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-s

[SQL] Function returning setof taking parameters from another table

2008-07-31 Thread Marcin Stępnicki
Hello. I've got a function which returns set of records: select * from f_test(123); param | val1 | val2 --- 123 | 1 | 17 123 | 2 | 18 I'd like to execute it multiple times with parameters from other query, like (it doesn't work of course): select *

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

2008-05-14 Thread Marcin Stępnicki
On Wed, May 14, 2008 at 10:40 AM, Harald Fuchs <[EMAIL PROTECTED]> wrote: > I think a sequence is much simpler: > > create temp sequence tmp; > select nextval('tmp') as rownum, >contactdate > from >myTable > where >contactdate > '2007-06-30 23:59:59' > order by >contactdate; I used

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

2008-05-14 Thread Marcin Stępnicki
On Wed, May 14, 2008 at 1:54 AM, Gavin 'Beau' Baumanis <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > After spending some time searching through our good friend Mr. Google and > the mailing list I found a post that provided me with a query that does just > what I need. I think that this should be h

Re: [SQL] Export Access 97 to PostgreSQL

2008-03-27 Thread Marcin Stępnicki
On Thu, Mar 27, 2008 at 11:06 AM, Shavonne Marietta Wijesinghe <[EMAIL PROTECTED]> wrote: > COPY REGIONI FROM (...) > Strange coz i created the table. Why doesn't it seem to find it?? > > CREATE TABLE "REGIONI" You need to quote the name in your COPY command as well. -- Sent via pgsql-sql mail

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Marcin Stępnicki
On Jan 11, 2008 4:23 AM, Daniel Caune <[EMAIL PROTECTED]> wrote: Please ignore my post. I havent' read your message carefully enough. ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-11 Thread Marcin Stępnicki
On Jan 11, 2008 4:23 AM, Daniel Caune <[EMAIL PROTECTED]> wrote: > Hi, > > Is there any way to define a SQL stored function that inserts a row in a > table and returns the serial generated? Maybe you just need INSERT ... RETURNING? http://www.postgresql.org/docs/8.2/interactive/sql-insert.html "

Re: [SQL] Advice for generalizing trigger functions

2007-12-28 Thread Marcin Stępnicki
Dnia 25-12-2007, Wt o godzinie 16:20 -0800, Richard Broersma Jr pisze: > I've created quite a few functions that log modifications to various history > tables. > (the history table has the same name as the base table but is prefixed by the > 'History.' schema.) > The only difference between fu

Re: [SQL] Potential bug in postgres 8.2.4

2007-05-24 Thread Marcin Stępnicki
Dnia Thu, 24 May 2007 12:54:48 +0100, Tomas Doran napisał(a): > If I can do something to make it work in the postgres backend, then that'd > be acceptable, and I'm investigating that.. >From what I know it's impossible without touching the source. > This is, at the very least, is a glaring inco

Re: [SQL] Potential bug in postgres 8.2.4

2007-05-24 Thread Marcin Stępnicki
Dnia Thu, 24 May 2007 12:20:54 +0100, Tomas Doran napisał(a): > CREATE TABLE testtable ( > col1 char(1), > data text > ); > > INSERT INTO testtable (col1, data) VALUES ('1', 'foobar'); INSERT INTO > testtable (col1, data) VALUES ('2', 'foobarbaz'); > > The following queries all work

Re: [SQL] system table storing sequence attributes

2007-05-22 Thread Marcin Stępnicki
Dnia Tue, 22 May 2007 15:23:44 +0300, Sabin Coanda napisał(a): > ... >> select last_value from sequence_name > > Unfortunately there is the same problem. The documentation say: "It is an > error to call lastval if nextval has not yet been called in the current > session." and I don't want to

Re: [SQL] system table storing sequence attributes

2007-05-22 Thread Marcin Stępnicki
Dnia Tue, 22 May 2007 10:03:28 +0300, Sabin Coanda napisał(a): > Hi there, > > I'd like to read the global sequence attribute "currval", but not using > currval function, because it is session dependent and requires a nextval > function to be used before. > > Do you know where is stored this val

Re: [SQL] How can I know if a row is Locked?

2007-04-13 Thread Marcin Stępnicki
Dnia Fri, 13 Apr 2007 04:27:34 -0700, Carlos Santos napisał(a): > How can I know if a row is locked by another transaction. > I have in a transaction like that: > > BEGIN; > SELECT * FROM compels.teste WHERE id = '1' FOR UPDATE; > > PS1: where id is the primary key. > PS2: The COMMIT command is

Re: [SQL] DISTINCT ON not working...?

2007-02-20 Thread Marcin Stępnicki
Dnia Tue, 20 Feb 2007 15:36:32 +1100, Phillip Smith napisał(a): > Removing the CASE statement all together: > SELECT DISTINCT ON (ean) > ean, > count(*) > FROMTMPTABLE > WHERE code NOT IN (SELECT code FROM stock_deleted) > ANDean IS NOT NULL > GROUP BY ean > > Still gi

Re: [SQL] Function returning SETOF using plpythonu

2007-01-26 Thread Marcin Stępnicki
Dnia Fri, 26 Jan 2007 17:24:52 +, Luís Sousa napisał(a): > Hi, > > Is it possible to return rows from a function written in plpythonu using > SETOF? > > Example: > CREATE FUNCTION "test_python_setof"() > RETURNS SETOF text AS ' > records=plpy.execute("SELECT name FROM interface"); >

Re: [SQL] Schema sample

2007-01-22 Thread Marcin Stępnicki
Dnia Mon, 22 Jan 2007 17:38:09 -0200, Ezequias Rodrigues da Rocha napisał(a): > Hi list, > > I would like to ask you if there is any schema that someone can send me. I > must make some Replication testes and would like to use a simple schema > with two or three tables would be nice. You can find

Re: [SQL] Postgresql & Oracle Heteregenous services - strange behaviour

2007-01-19 Thread Marcin Stępnicki
Dnia Wed, 17 Jan 2007 13:04:28 +, Richard Huxton napisał(a): > That'd be my guess. And then it's not fetching any rows, expecting > cursor-like behaviour. Of course we fetch all the rows before returning > any results. > > The real solution would be to add "LIMIT 0" or "LIMIT 1" to the > c

Re: [SQL] Postgresql & Oracle Heteregenous services - strange behaviour

2007-01-17 Thread Marcin Stępnicki
Dnia Wed, 17 Jan 2007 13:04:28 +, Richard Huxton napisał(a): > Andrew Sullivan wrote: >> I bet it's getting the column list from the table or some such thing. >> This is a lousy way to do it (the information_schema would be more >> correct, although maybe no faster). > > That'd be my guess.

[SQL] Postgresql & Oracle Heteregenous services - strange behaviour

2007-01-17 Thread Marcin Stępnicki
I'm not sure if it's proper group, if not then please direct me to more appropriate one (unixodbc?) I've set up connection from oracle to postgresql via unixodbc and oracle's heterogeneus services. The connection works, but when I issue the following: select "p_nr_pesel" from "zew_patients"@my_po

[SQL] Finding gaps in scheduled events

2006-12-12 Thread Marcin Stępnicki
Hello. I've been struggling with this one for over a week, but for some reason my mind isn't compatibile with the problem - it seems simple, yet I'm unable to find the proper solution :(. I have a timeline divided to 15 minute periods: start | --+ 8:00 | 8:15 | 8:30 | 8:45 | (...)| 14