Re: [SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Guillaume Lelarge
On Sat, 2013-05-25 at 14:49 +0200, Brice André wrote: > Hi Wolfe, > > First, thanks for your help. > > I tried your code, but it does not work... the function returns a string : > "0". When I check, this command properly modifies one row, as expected. > It works for me with PQntuples. > I don'

Re: [SQL] ALTER USER abc PASSWORD - what's going on ???

2013-04-18 Thread Guillaume Lelarge
On Thu, 2013-04-18 at 13:21 +0200, Marcin Krawczyk wrote: > I figured it out... when changing role from pgAdmin, it has a default VALID > UNTIL 1970 set and after confirming changes it just made my abc user > account invalid... FYI, this pgAdmin bug has been fixed. The fix will be available in the

Re: [SQL] \copy multiline

2012-11-29 Thread Guillaume Lelarge
On Wed, 2012-11-28 at 21:21 -0600, Seb wrote: > Hi, > > I use \copy to output tables into CSV files: > > \copy (SELECT ...) TO 'a.csv' CSV > > but for long and complex SELECT statements, it is cumbersome and > confusing to write everything in a single line, and multiline statements > don't seem

Re: [SQL] ignore case in where clause

2012-03-22 Thread Guillaume Lelarge
On Thu, 2012-03-22 at 16:26 -0400, Edward W. Rouse wrote: > I am currently using lower(column) = '' for matching case insensitive. I > know that there are ways to do this with regular expressions too. I recently > noticed that including even one lower causes severe performance issues (from > 290ms

Re: [SQL] new user on mac

2012-01-02 Thread Guillaume Lelarge
On Thu, 2011-10-20 at 04:15 -0700, Scott Swank wrote: > Here is a seeming quirk in pgadmin3. I say seeming, because I may > simply not be sufficiently familiar with this tool. > > [A quick note for non-mac users, the Finder is the gui file browser, > equivalent to Nautilus/Dolphin in linux or the

Re: [SQL] new user on mac

2011-10-24 Thread Guillaume Lelarge
On Thu, 2011-10-20 at 12:22 +0200, Guillaume Lelarge wrote: > On Wed, 2011-10-19 at 01:13 -0700, Basil Bourque wrote: > [...] > > I may have once had an inexplicable glitch, but after restart all was well. > > I've only been bitten by 2 recurring bugs: > > > &

Re: [SQL] new user on mac

2011-10-20 Thread Guillaume Lelarge
On Wed, 2011-10-19 at 01:13 -0700, Basil Bourque wrote: > >> I have a postgres 9.1 database up & running, no problem. Purely in > >> terms of writing sql (ddl, dml & pg/plsql), what tools are > >> recommended? > >> > >> Coming from an Oracle world, I'm thinking of toad, sql developer, etc. > >> >

Re: [SQL] Problem with DROP ROLE

2011-10-19 Thread Guillaume Lelarge
On Wed, 2011-10-19 at 12:11 +0200, Brice André wrote: > Hello everyone, > > I would want to implement an SQL query where I would be able to suppress all > information from a registered user. I am currenlty able to suppress > everything except the user role. The name of the role is present in a tab

Re: [SQL] [GENERAL] Creating rule for sliding data

2011-10-09 Thread Guillaume Lelarge
On Sun, 2011-10-09 at 21:17 +0200, F. BROUARD / SQLpro wrote: > Hi, > > Le 09/10/2011 19:07, Guillaume Lelarge a écrit : > > Hi, > > > > On Sun, 2011-10-09 at 18:50 +0200, F. BROUARD / SQLpro wrote: > >> I am answering to myseilf... > &g

Re: [SQL] [GENERAL] Creating rule for sliding data

2011-10-09 Thread Guillaume Lelarge
Hi, On Sun, 2011-10-09 at 18:50 +0200, F. BROUARD / SQLpro wrote: > I am answering to myseilf... > > the good syntax is something like : > > > CREATE RULE R_U_MSR_BEFORE2000x > AS > ON UPDATE TO T_MESURE_MSR > WHERE ( NEW.MSR_DATE < DATE '2000-01-01' ) > DO INSTEAD > ( > -- rows does not ch

Re: [SQL] Use select and update together

2011-09-17 Thread Guillaume Lelarge
On Sat, 2011-09-17 at 16:56 +0200, Andreas wrote: > Am 13.09.2011 07:50, schrieb pasman pasmański: > > In 8.4 this syntax is not implemented. > > select * from ( > update tbl set val = 1 where key in ( 1, 2, 3, 4, 5 ) returning * > ) as x > > wouldn't work even in PG 9.1. > So what data structure

Re: [SQL] Looking for a "show create table " equivalent

2011-07-13 Thread Guillaume Lelarge
On Tue, 2011-07-12 at 10:33 +0200, B.Rathmann wrote: > [...] > I've been trying to find out how to find out which sql was run to create > a certain table. As I need this in a program which may access the > database remotely, using pg_dump --schema-only or psql is not an option > (the system my prog

Re: [SQL] Subselects not allowed?

2011-06-11 Thread Guillaume Lelarge
On Sat, 2011-06-11 at 17:01 +0200, Leif Biberg Kristensen wrote: > Can anybody tell me why this doesn't work? > Because it's not supported. The START clause expects a value, not a subquery. > pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT > MAX(source_id) FROM sources); > ER

Re: [SQL] Specifying column level collations

2011-05-07 Thread Guillaume Lelarge
On 05/07/2011 01:19 PM, Thomas Kellerer wrote: > Hi, > > I'm playing around with 9.1beta1 and would like to create a table where > one column has a non-default collation. > > But whatever I try, I can't find the correct name that I have to use. > > My database is initialized as follows: > > pos

Re: [SQL] Insert row in 1.10.1 and 1.10.3

2010-11-26 Thread Guillaume Lelarge
Le 26/11/2010 18:14, Thomas Kellerer a écrit : > ndias, 26.11.2010 17:22: >> When doing a insert row with less columns mentioned in "into table(col1, >> col2, col3,..." than the columns that exist on the table, on 1.10.1 it >> returns an error saying "INSERT has more expressions than target columns

Re: [SQL] pgdump with insert command help

2010-09-24 Thread Guillaume Lelarge
Le 24/09/2010 14:32, Nicholas I a écrit : > hi, > > i am trying to dump a table with insert command rather tahn copy. > > pg_dump -Dt --insert table dbname > table.sql; > > i am not able to get the output. is this correct ? > > > -Nicholas I > You should put the table name right after the -t

Re: [SQL] insert into help

2010-09-22 Thread Guillaume Lelarge
Le 22/09/2010 09:32, Nicholas I a écrit : > Hi, > > i have two tables, > --- > *table1 > > id type serial, name varchar;* > *-- > table 2 > > name varchar;* >

Re: [SQL] pgAgent stats

2010-03-17 Thread Guillaume Lelarge
Hi, Le 16/03/2010 08:40, Marcin Krawczyk a écrit : > Hi list, does anyone know the reason for pgAdmin not showing the stats > neither for selected pgAgent step nor whole job ? The pga_joblog and > pga_jobsteplog both get populated with data on run so I was thinking that > maybe I'm missing some vi

Re: [SQL] rename primary key

2010-01-27 Thread Guillaume Lelarge
Le 15/01/2010 17:13, Seb a écrit : > On Fri, 15 Jan 2010 07:35:17 +0100, > Guillaume Lelarge wrote: > > [...] > >> Primary keys are constraints. They are enforced with an index, but >> actually they are constraints. So we put them on the constraints >> nodes.

Re: [SQL] rename primary key

2010-01-14 Thread Guillaume Lelarge
Le 15/01/2010 04:39, Seb a écrit : > On Fri, 15 Jan 2010 12:34:15 +0900, > Ian Barwick wrote: > [...] > On a related note: how come pgadmin3 shows "Indexes (0)" for such a > table, even though an index does exist for the primary key? Are these > indexes created in a separate table that is looked

Re: [SQL] CREATE SERVER - what is this?

2009-11-26 Thread Guillaume Lelarge
Le mardi 24 novembre 2009 à 16:45:27, Richard Broersma a écrit : > I noticed a few new SQL references in the manual: > > CREATE SERVER > CREATE FOREIGN DATA WRAPPER, > CREATE USER MAPPING > > Is this similar to DBI-Link? > They appear on the 8.4 release. They were added to support the use of SQ

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Guillaume Lelarge
Le jeudi 19 novembre 2009 à 01:20:24, Kris Kewley a écrit : > Could you not create a function to do this instead? > > Set var_limit = 20% of row count > Replace subquery with var_limit > Sure, see the previous mails from Pavel. You can also put the percent as a parameter of the function. --

Re: [SQL] LIMIT BASED ON PERCENT

2009-11-18 Thread Guillaume Lelarge
Le mercredi 18 novembre 2009 à 20:24:09, Another Trad a écrit : > No, It doesn't. > In my machine: > > First select > ERROR: syntax error at end of input > LINE 1: select * from rapadura.cliente limit 20% > ^ > Second one: > ERROR: argument of LIMI

Re: [SQL] .psql_history": No such file

2009-06-26 Thread Guillaume Lelarge
Hi Ivan, Le vendredi 26 juin 2009 à 17:53:15, ivan marchesini a écrit : > [...] > I have installed a postgres db using a datadir different > from /var/lib/pgsql/.psql_history. > > then: >su postgres >psql postgres > > All went fine but when I exit from psql from a db I obtain: > ___ >

Re: [SQL] Copy question

2008-12-29 Thread Guillaume Lelarge
Judith Altamirano a écrit : > Hello every body I'm trying to extract a query as follows: > > copy (select * from clientes where id_cliente = 7895) to > '/home/paso/sel.copy'; > > But it returns the next error: > > ERROR: error de sintaxis en o cerca de «(» at character 6 > LINE 1: copy (select

Re: [SQL] Simple Problem ?

2008-09-16 Thread Guillaume Lelarge
Hengky Lie a écrit : > I have to use sql command because i want to retrieve data according to > several criteria. > The SQL command just a sample to show that the data i retrieve not > updateable. The real query like : > > SELECT * FROM TBLPRODUK WHERE SUBKAT='abc'; > > So i do not need to view d

Re: [SQL] Simple Problem ?

2008-09-16 Thread Guillaume Lelarge
Hengky Lie a écrit : > This is the same as what i think but the table has primary key and has > no relation to other table. This is the table definition : > [...] > > These query result non updateable records : > > SELECT kode, namabarang from tblproduk; > > SELECT * from tblproduk; > > What is

Re: [SQL] Simple Problem ?

2008-09-15 Thread Guillaume Lelarge
Hengky Lie a écrit : > [...] > I really amazed with this problem and need your help. > > I run simple query from Query window of PgAdmin3: SELECT * FROM mytable > limit 10; > > and the result are NON UPDATABLE QUERY, while i need the result are > updatable. > > I run the same query from Passthro

Re: [SQL] Concat field result in select query

2008-08-22 Thread Guillaume Lelarge
Nacef LABIDI a écrit : > Hi all, > > I was wondering if there is a way to concatenate the results of a field > in a select to return it as a single string. > > Example : > > my_field > -- > 1 > 2 > 3 > > select concat_something(my_field) from my_table group by something; > the resul

Re: [SQL] undefined relations in pg_locks

2008-02-06 Thread Guillaume Lelarge
Sabin Coanda wrote: Hi there, I have a procedure where a dead-lock occurs, and I'm trying to find the tables involved in the lock. Unfortunatelly, I don't find the related objects of the oids of "relation" field. Also all the fields "classid" and "objid" are null. May I suppose there were

Re: [SQL] currval() within one statement

2008-01-22 Thread Guillaume Lelarge
sad wrote: Guillaume Lelarge wrote: sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only

Re: [SQL] currval() within one statement

2008-01-22 Thread Guillaume Lelarge
sad wrote: A. Kretschmer wrote: is it expected that the currval() changes its value between calls within one statement ? Conclusion, don't call nextval() within a TRIGGER, and insert either nextval() for the column or omit this column. I only note that i still want to discuss the titled pr

Re: [SQL] Error OID

2007-12-04 Thread Guillaume Lelarge
Yohanes Purnomo a écrit : > [...] > I create a function: > > CREATE OR REPLACE FUNCTION ReProses() > RETURNS BOOLEAN > AS $$ > > DECLARE > nHasil Numeric; > > BEGIN > CREATE TEMP TABLE tmpTtlRekening WITHOUT OIDS ON COMMIT DROP > AS > SELECT Rekening, SUM(Debet) AS D

Re: [SQL] join problem

2007-06-13 Thread Guillaume Lelarge
A. R. Van Hook a écrit : > I have join problem: > "select i.ivid, v.eventdate, v.deposit, v.invdate, cai.db, > sum(i.tax) as tax, > sum(i.tax + i.rowtot) as totalP, > (sum(i.tax + i.rowtot) - v.deposit) as balance > from invoice v >

Re: [SQL] INSERT INTO

2007-03-16 Thread Guillaume Lelarge
Shavonne Marietta Wijesinghe a ecrit le 16/03/2007 11:31: i took a look at the link Guillaume gave me. But it also explains on PHP i'm using ASP :( Yes, that's why I said that it didn't answer your question. Sorry if this wasn't clear. After a bit of googling, I found the replace function.

Re: [SQL] INSERT INTO

2007-03-16 Thread Guillaume Lelarge
Bart Degryse a ecrit le 16/03/2007 10:03: I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "SANT'ANGELO LODIGIANO"; $query = "INSERT INTO TABLE2 (TE_INDI) VALUES ('" . str_replace("'", "''", $valuetoinsert) . "')"; I'm sure ASP has also a string replacement fun

Re: [SQL] lower() not working correctly...?

2006-09-15 Thread Guillaume Lelarge
Andreas Joseph Krogh a ecrit le 15/09/2006 10:06: I have the following query: select lower(firstname) || ' ' || lower(lastname) from person firstname and lastname are VARCHAR lower() returns NULL when firstname OR lastname is NULL, is this correct? This is 8.2devel from 24.08.2006. NULL is

Re: [SQL] Add column and specify the column position in a table

2006-05-18 Thread Guillaume Lelarge
2006/5/18, Andrew Sullivan <[EMAIL PROTECTED]>: On Thu, May 18, 2006 at 05:43:19PM +0200, Guillaume Lelarge wrote: > Do you mean that, using "alter table test add column" with the "after" > option, MySQL creates a new table, populates it with the old table > d

Re: [SQL] Add column and specify the column position in a table

2006-05-18 Thread Guillaume Lelarge
2006/5/18, Alvaro Herrera <[EMAIL PROTECTED]>: Guillaume LELARGE wrote: > Emi Lu a écrit : > > I am trying to insert one column to a specific position in a table. > > > > In mysql, I can do: > > . create table test(id varchar(3), name varchar(12)); > >

Re: [SQL] Add column and specify the column position in a table

2006-05-17 Thread Guillaume LELARGE
Emi Lu a écrit : > I am trying to insert one column to a specific position in a table. > > In mysql, I can do: > . create table test(id varchar(3), name varchar(12)); > . alter table test add column givename varchar(12) after id; > > > I am looking for similar things in postgresql to add a new c

Re: [SQL] Like with special character

2006-05-01 Thread Guillaume LELARGE
Hi, tnodev a écrit : > I'm using postGre with tables which contain French character (éèçàù...). > Is there a fonction which performs a like in replacing é (e cute) by e ? > select translate('forêt', 'àâäéèêëîïôöùûü', 'aaaiioouuu'); Change the first word (forêt) by the string you want charac

Re: [SQL] append fields for *where...*

2005-02-11 Thread Guillaume LELARGE
Johnny C wrote: I have the following tables: TABLE A month | year | item | num 1 2005 myitem 003 TABLE B num| date | descr 003 02-01-2005 blahblah 003 01-01-2005 toratora I am trying to come up with

Re: [SQL] Getting last insert value

2003-11-15 Thread Guillaume LELARGE
Le Samedi 15 Novembre 2003 16:40, vous avez écrit : > Doing a "select currval() from my_table" after your insert should work. > Actually, this is select currval('my_sequence') Sorry about this. > For more details, see > http://www.postgresql.org/docs/7.3/interactive/functions-sequence.html -

Re: [SQL] Getting last insert value

2003-11-15 Thread Guillaume LELARGE
Le Samedi 15 Novembre 2003 15:18, vous avez écrit : > Hello, > I have a table with many fields, and one of the fields is of type serial. > I will do many inserts, and there will be many repeats of the other fields > in the table, but, obviously, the serial field will be unique for all the > rows.

Re: [SQL] CREATE table1 FROM table2

2003-06-17 Thread Guillaume LELARGE
Hi, Le Mardi 17 Juin 2003 20:46, Achilleus Mantzios a écrit : > On 17 Jun 2003, Rado Petrik wrote: > > How I create table1 from other table2 . > > > > "cp table1 table2" > > create table table2 as select * from table1; > Another way would be: select * into table2 from table1; (See http://www.p

Re: [SQL] UNION & LIMIT & ORDER BY

2003-06-16 Thread Guillaume LELARGE
Hi, Le Samedi 14 Juin 2003 17:01, Emmanuel Engelhart a écrit : > [...] Taken from the postgresql manual (http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-select.html#SQL-UNION): ORDER BY and LIMIT can be attached to a sub-expression if it is enclosed in parentheses. Without pa