[SQL] Deleting entries from multiple tables

2010-11-30 Thread manidegr8
i am trying to run a query but its not working may be due to constraint conflicts i have table A, B and C B and C have a foreign key linked with A's primary key so i want to delete an entry from A for that i hav to delete child records first can u design a query which wont conflict the

Re: [SQL] Deleting entries from multiple tables

2010-11-30 Thread Dusan Misic
To be precise, if you used defaults, you can't delete any row in table A that has rows referencing to it in tables B and C. On Tue, Nov 30, 2010 at 6:59 AM, manidegr8 engineer.us...@ymail.com wrote: i am trying to run a query but its not working may be due to constraint conflicts i have

Re: [SQL] Deleting entries from multiple tables

2010-11-30 Thread Achilleas Mantzios
Here is my take on how to regard parent tables in one-to-many FK relationships. If lets say we have a situation when we model e.g. mail messages and its attachments, then we might want to use ON DELETE CASCADE since there is absolutely no reason for an attachment to exist when the main message

Re: [SQL] subselect and left join not working?

2010-11-30 Thread Carla
Try it: select zonas.zona_id, usr_folio from zonas left join usuarios on (*per_id = 2 and *zonas.zona_id = usuarios.zona_id) order by zonas.zona_id; Or: select zonas.zona_id, usr_folio from zonas left join usuarios on zonas.zona_id = usuarios.zona_id where per_id = 2 *or usuarios.zona_id is

Re: [SQL] Is there a solution for SELECT OR INSERT

2010-11-30 Thread Florian Weimer
* Stefan Becker: Is there a way to get the ID row OR create a new one in ONE single statement? You could create a stored procedure. But if you have concurrent inserts, locking is a bit tricky. -- Florian Weimerfwei...@bfk.de BFK edv-consulting GmbH http://www.bfk.de/

Re: [SQL] Deleting entries from multiple tables

2010-11-30 Thread manidegr8
yes i know about on delete cascade it automatically delete the child when master is deleted but the database i m working on is not built in this fashion tables r built on default rules so constraints r there i m jus asking to build a procedure or function that taking from the user and deletes

[SQL] indexing longish string

2010-11-30 Thread Rob Sargent
Were we to create a table which included a text field for a small block of xml (100-1000 chars worth), would an index on that field be useful against exact match queries? We're wondering if a criterion such as where 'a string expected to be of size range 100 to 500' =

Re: [SQL] indexing longish string

2010-11-30 Thread jose
Why don't you use some type of hash like md5 for indexing ? 2010/11/30 Rob Sargent robjsarg...@gmail.com: Were we to create a table which included a text field for a small block of xml (100-1000 chars worth), would an index on that field be useful against exact match queries? We're wondering

Re: [SQL] indexing longish string

2010-11-30 Thread Rob Sargent
If the performance against an index doesn't cut it, we would be forced to choose just such an implementation, but if pg can do it straight up that would be less work for us. A good thing, to be sure. On 11/30/2010 10:50 AM, jose wrote: Why don't you use some type of hash like md5 for indexing ?

Re: [SQL] indexing longish string

2010-11-30 Thread Kenneth Marshall
You can use a hash index for this. It's drawback is that it is not yet WAL enabled and if your DB crashes you will need to rebuild the index to fix the corruption. It works well(only) with equality searches. If it is a scenario where you must have WAL, use a function index based on the hash of the

Re: [SQL] indexing longish string

2010-11-30 Thread Isaac Dover
Hi, While hashing is certainly a good idea, you really should consider some issues well before you get to that point. Trust me, this could save you some headaches. First, though you're probably already aware, two XML documents can be the same document, but with very different literal

Re: [SQL] How strings are sorted by LC_COLLATE specifically?

2010-11-30 Thread Peter Eisentraut
On tor, 2010-11-25 at 14:42 +0900, Chang Chao wrote: How strings are sorted when LC_COLLATE = ja_JP.UTF-8. I tried to read the documention on that,but there are just a few words, like LC_COLLATE determines string sort order, Is there a specific reference about this? So I can implement an

Re: [SQL] indexing longish string

2010-11-30 Thread Isaac Dover
No problem, sir, hopefully I could help. I failed to mention that I've discovered some bugs in the PostgreSQL 8.4 XML implementation that forced me to take pause and ultimately forego XML with Postgres. I haven't looked at 9 yet, but considering the current lack of interest and/or disdain so many

[SQL] aggregation question

2010-11-30 Thread Samuel Gendler
I have a fact table with a number of foreign keys to dimension data and some measure columns. Let's assume I've got dimension columns a,b,c,d,e, and f and measure columns x, and y. I need to be able to find the value of f, x, and y for the row with min(x/y) when e in (1,2) and max(x/y) when e

[SQL] OT - load a shp file

2010-11-30 Thread John Fabiani
Hi, How do I load a Census shp file into an exist database? I believe I have postGIS install and now I want to load the US counties shp file. the following does not appear to work shp2pgsql -s 4269 -I -W latin1 tl_2008_us_county.shp 2008_us_county | psql Plus I don't know what it does!

[SQL] DELETE WHERE EXISTS unexpected results

2010-11-30 Thread Jeff Bland
I want to delete certain rows from table USER_TBL. Two tables are involved. USER_TBL and OWNER_TBL. The entries that match BLAND type in OWNER table and who also have a matching entry in USER table NAME but only for USER_TBL entries with places equal to HOME. DELETE FROM SP.TST_USER_TBL