Re: [SQL] the value of OLD on an initial row insert

2013-09-22 Thread Luca Ferrari
On Fri, Sep 20, 2013 at 6:43 PM, James Sharrett wrote: > ERROR: record "old" is not assigned yet > SQL state: 55000 > Detail: The tuple structure of a not-yet-assigned record is indeterminate. > > Is this what's happening? If so, how can I avoid the issue. If I get it right you are running the

Re: [SQL] detect initiator of update/delete action

2013-09-20 Thread Luca Ferrari
On Fri, Sep 20, 2013 at 9:52 AM, ssylla wrote: > There are two cases: > 1. if the deletion was executed through a user action, both the update and > insert statement of the 'table1_del' function should be executed > 2. if the deletion was initiated through a function fired from another > table, on

Re: [SQL] xmlElement and \n

2013-09-19 Thread Luca Ferrari
On Thu, Sep 19, 2013 at 9:46 AM, Enrico Oliva wrote: > I would like to have > > > Yes > ... I'm not sure there is an indenting facility, since indentation strongly depends on what the user think about. However you can concatenate a new line at each xmlelement call: SELECT xmleleme

Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Luca Ferrari
On Thu, Aug 29, 2013 at 3:33 PM, Bruce Momjian wrote: > Uh, I think Vim can use etags, no? Isn't etags Exuberant Ctags? The > Exuberant Ctags's FAQ mentions Vim: > I was referring to the etags shipped with emacs, that even if does not support (explicitly) sql seems to work for a very simple te

Re: [SQL] CTAGS for PL/pgSQL ?

2013-08-29 Thread Luca Ferrari
On Wed, Aug 28, 2013 at 5:08 PM, Charles Sheridan wrote: > Does anyone know if there are any CTAGS extensions or variants that support > PL/pgSQL ? > > I use exuberant-ctags which does not support it, and a web search does not > return anything promising. As far as I know, the quick answer is NO.

Re: [SQL] monthly statistics

2013-07-24 Thread Luca Ferrari
On Mon, Jul 8, 2013 at 2:18 PM, Andreas wrote: > How could I combine those 2 queries so that the date in query 1 would be > replaced dynamically with the result of the series? > Surely I'm missing something, but maybe this is something to work on: WITH RECURSIVE months(number) AS ( SELECT 1 UN

Re: [SQL] Advice on key design

2013-07-24 Thread Luca Ferrari
On Wed, Jul 24, 2013 at 11:47 AM, Bèrto ëd Sèra wrote: > Hi, > > It looks heavy, performance-wise. If this is not OLTP intensive you can > probably survive, but I'd still really be interested to know ow you can end > up having non unique records on a Cartesian product, where the PK is defined > by

Re: [SQL] Listing table definitions by only one command

2013-07-24 Thread Luca Ferrari
On Wed, Jul 17, 2013 at 5:29 PM, Carla Goncalves wrote: > Hi > I would like to list the definition of all user tables by only one command. > Is there a way to *not* show pg_catalog tables when using "\d ." in > PostgreSQL 9.1.9? > What do you mean by "user tables"? The execution of \d without any

Re: [SQL] Advice on key design

2013-07-24 Thread Luca Ferrari
On Wed, Jul 24, 2013 at 10:38 AM, Bèrto ëd Sèra wrote: > What would be the rationale behind the serial number? > The serial key, also named "surrogate key" is there for management purposes. Imagine one day you find out your database design is wrong and what was unique the day before is no more s

Re: [SQL] sql problem with join

2006-11-15 Thread Luca Ferrari
On Wednesday 15 November 2006 16:20 your cat, walking on the keyboard, wrote: > May be you could show the results you are getting and then make up some > results that you would really like to get. I am not entirely clear what > you are trying to achieve. Lastly I found the solution, for the mome

[SQL] sql problem with join

2006-11-15 Thread Luca Ferrari
Hi all, I've got a problem tryng to define a view with a few joins, I'll appreciate if someone could drive me in the definition of such query. I've got a table roleSkill that contains a row for each skill belonging to a defined role and with the desired competence level for such skill in such r

[SQL] hiding column values for specific rows

2006-11-13 Thread Luca Ferrari
Hi, I don't know if this's possible but I'd like to hide column values for specific rows within a query. Imagine I've got a table with columns username and password: users(username,password). Now I'd like the user registered in the table to see her password, to see who is registered but not to s

Re: [SQL] delete on cascade

2006-10-23 Thread Luca Ferrari
On Monday 23 October 2006 11:00 Achilleas Mantzios's cat, walking on the keyboard, wrote: > not right!!! > ON DELETE CASCADE is specified in FOREIGN KEY contsraints. > So that would be in ass_sf table. > If you find ALTER TABLE ass_sf command hard to run, then drob your > ass_sf table and define i

[SQL] delete on cascade

2006-10-23 Thread Luca Ferrari
Hi all, I guess this is an already asked question, but I didn't found an answer, so apologize me. Imagine I've got two tables: skill(id,description) // primary key => id family(id,description) // primary key => id and I want to associate skills to families: ass_sf(id_skill,id_family)