Re: [SQL] Is there a way to build a query based on data in a table?

2013-08-28 Thread Brice André
Hello, >From what I know, in pure SQL, it is not possible to perform what you want. But it is feasible in PL/pgSQL (and this script language is supported by default by postgresql...). Regards, Brice 2013/8/28 Herouth Maoz : > Hello. > > I want to run an automatic archiving SQL script, that look

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

2013-05-27 Thread Brice André
Brice 2013/5/27 Guillaume Lelarge > Hi, > > On Sun, 2013-05-26 at 20:35 +0200, Brice André wrote: > > [...] > > Thanks for your answer. > > > > Your example is working fine on my computer too (I had to adapt some > > includes because my client is und

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

2013-05-25 Thread Brice André
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. I don't know if it may help, but just in case... The DELETE operation is not performed on a table : it is perf

[SQL] DELETE...RETURNING problem with libpq

2013-05-25 Thread Brice André
Dear all, I am trying to translate a code written in php to C++. So, I am now using lipq in order to access my postgresql database from C++. As performance is an important feature, I am using prepared statements. I have a SQL statement that performs a 'DELETE ... RETURNING ... ' stuff and I exec

[SQL] Partition database between users and implement disk quotas

2012-10-21 Thread Brice André
Hello, I wrote an aplication where I store data from different users whithin the same database. There is no link between data of different users. In my current implementation, I added a column "user_id" in each table, and, with views and rules mechanisms, I am able to hide data from other users.

Re: [SQL] Problem with sequence increment

2012-01-25 Thread Brice André
Hello, This is a normal behaviour of the sequence. In case of rollback, a sequence is never decremented. Read the note at the end of this page for more info : http://www.postgresql.org/docs/8.1/static/functions-sequence.html Regards, Brice 2012/1/25 Francisco Calderón > Hello, > > I am having

Re: [SQL] compare table names

2012-01-10 Thread Brice André
Just my 2 cents... Why don't you use a date column type instead of a string ? In this case, at insertion, you could simply do this : INERT INTO tablename (insertion_time, ...) VALUES (now(), ...) and, for the select, you could simply write : SELECT * FROM tablename WHERE insertion_time >= (now(

[SQL] pg_dump : problem with grant on table columns

2011-11-15 Thread Brice André
uot;Clients" TO "AgendaSubscript"; But, when I execute the content of this dump in a fresh database (for backup and restore stuff), those commands are rejected and thus, my restored database has not the proper access rights. Is this a bug with the pg_dump tool or am I doing something wrong ? Regards, Brice André

Re: [SQL] Handling mutliple clients access with views

2011-10-25 Thread Brice André
Thanks very much for those info. >From what I read, I think Veil will do the trick. I already use ROLES, but there are a few probems with them : - first, as I mix the data from different users in the same table, ROLES do not solve the complete problem. - second, this forces me to use a dedi

[SQL] Handling mutliple clients access with views

2011-10-24 Thread Brice André
ve write access. But maybe is it not a good idea to handle this at db level ? Do you have any suggestion on those aspects? Regards, Brice André

Re: [SQL] Problem with DROP ROLE

2011-10-19 Thread Brice André
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; $

[SQL] Problem with DROP ROLE

2011-10-19 Thread Brice André
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 table and so, I would want to perform something like this : DROP RO