Re: [SQL] select based on multi-column primary keys
On Fri, Jan 19, 2007 at 07:45:40PM -0800, codeWarrior wrote: > AFAIK: You cannot have multiple primary keys. How would you know which one > is the actual key ? You can have a multi-column primary key, though. That's a perfectly legitimate approach. > FYI: What you are really talking about are table contraints... When you have No, it's a multi-column primary key. > My advice would be to alter your table structure so that you have a "real" > PK not table constraints -- that would make it searchable This is already searchable. What you are talking about is not a real primary key, but an artificial one. The OP already has a real primary key. SQL purists think artificial primary keys mean that you haven't done enough normalisation. I'm going to remain silent on that topic, though, so that we don't get a Thread That Does Not End :) A -- Andrew Sullivan | [EMAIL PROTECTED] If they don't do anything, we don't need their acronym. --Josh Hamilton, on the US FEMA ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] Changing point for commas and commas for point
Hi list, Here in my country (Brazil) we have the decimal simbol as ' , ' (commas) and thousand separator as ' . ' (point) Here my sql uses: to_char(sum(My_column), '0D00') Is there any way to make this happens ? Regards -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Atenciosamente (Sincerely) Ezequias Rodrigues da Rocha =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- A pior das democracias ainda é melhor do que a melhor das ditaduras The worst of democracies is still better than the better of dictatorships http://ezequiasrocha.blogspot.com/
Re: [SQL] Changing point for commas and commas for point
"Ezequias Rodrigues da Rocha" <[EMAIL PROTECTED]> writes: > Here in my country (Brazil) we have the decimal simbol as ' , ' (commas) and > thousand separator as ' . ' (point) > Here my sql uses: to_char(sum(My_column), '0D00') That's the right thing. > Is there any way to make this happens ? I think you forgot to set LC_NUMERIC. regression=# select to_char(42.45, '0D00'); to_char --- 42.45 (1 row) regression=# set lc_numeric TO 'pt_PT.iso88591'; SET regression=# select to_char(42.45, '0D00'); to_char --- 42,45 (1 row) The specific locale names available vary across OSes ... try "locale -a" for a list. regards, tom lane ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate
Re: [SQL] Changing point for commas and commas for point
Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> schrieb: > Hi list, > > Here in my country (Brazil) we have the decimal simbol as ' , ' (commas) and > thousand separator as ' . ' (point) > > Here my sql uses: to_char(sum(My_column), '0D00') > > Is there any way to make this happens ? I think, you can use the 'G' as a group separator for this: test=*# select to_char(12345.67, '999G990D00'); to_char - 12.345,67 (1 row) Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly."(unknow) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889° ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org
[SQL] Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
Hi My system currently runs on PostgreSQL 8.1 and makes use of the old behaviour of SET CONSTRAINTS, namely that the command is applied to all constraints that match the specified name. This makes it very easy to write a general-case function that can change the DEFERRED mode on a given constraint that is present in several similar schemas (sounds odd maybe but it works very well in my case!). I understand that SET CONSTRAINTS in 8.2 no longer behaves like this. It's looking like my general function will need to do something like: SET CONSTRAINTS schema1.foo IMMEDIATE; SET CONSTRAINTS schema2.foo IMMEDIATE; SET CONSTRAINTS schema3.foo IMMEDIATE; ... SET CONSTRAINTS schemaX.foo IMMEDIATE; instead of SET CONSTRAINTS foo IMMEDIATE; and hope that I remember to add new clauses to this function when new schemas are added in the future. Or can I do something with pg_contraints, or some other technique? I'm relunctant to use SET CONSTRAINTS' 'ALL' clause in case it messes with other constraints in the system. Hope this makes sense, Simon --- Simon Kinsella Technical Director - Bluefire Systems Ltd This message has been scanned for viruses. ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org
Re: [SQL] Possible to emulate pre-8.2 behaviour of SET CONSTRAINTS?
"Simon Kinsella" <[EMAIL PROTECTED]> writes: > My system currently runs on PostgreSQL 8.1 and makes use of the old > behaviour of SET CONSTRAINTS, namely that the command is applied to all > constraints that match the specified name. Unfortunately that was pretty far away from what the SQL spec says :-( > This makes it very easy to write > a general-case function that can change the DEFERRED mode on a given > constraint that is present in several similar schemas (sounds odd maybe but > it works very well in my case!). I think you could do it fairly easily still, eg for rec in select nspname from pg_namespace n join pg_constraint c on n.oid = c.connamespace where conname = $1 loop execute 'set constraints ' || quote_ident(rec.nspname) || '.' || quote_ident($1) || ' immediate'; end loop; Exceedingly untested, but something close to this seems like it'd solve your problem. regards, tom lane ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] list variable attributes in one select
Hello, I've got the following tables: person: - id_person - firstname - lastname - type person_to_type: - id_person references person - type references person_type; person_type: - type "person_type" contains differents caracteristics for a person (actor, director, author, etc.) who can have several types, hence the need for the person_to_type table. I'd like to know if I can list in one SELECT command a person and all of its types, given that the number of types can be 0 to n. For example, for a given person I'd like to obtain: "John Doe", "actor", "playright", "author" or "Jane Doe", "director" in one select. Is that possible? ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
