[SQL] check for circular references in a 2-table heirachy

2004-09-08 Thread Terence Kearns
Does anyone know how I could check to ensure circular references are no created in my 2 table heirachy structure? Here are the tables albums album_relations ++ +-+ | album_id | | parent_album_id | | title | | child_album_id | +-

Re: [SQL] returning a recordset from PLpg/SQL

2004-06-09 Thread Terence Kearns
Stephan Szabo wrote: As a starting point, SETOF "RECORD" is different from SETOF RECORD given PostgreSQL's fold case to lower case for unquoted names. Ahh! That will help :) That's what you get when you use a silly IDE instead of a regular editor like vi or notepad or something. Because I haven't

[SQL] scripts for converting postgres to oracle?

2004-03-01 Thread Terence Kearns
which will work for a particular database. Does anyone have something pre-made which will *assist* with a postgres to oracle conversion? -- Terence Kearns ~ ph: +61 2 6201 5516 IT Database/Applications Developer Enterprise Information Systems Client Services Division University of Canberra www.

Re: [SQL] returning a recordset from PLpg/SQL

2004-03-01 Thread Terence Kearns
t the text value to whatever the entity_attribute record [for that value] specifies. I also think a 2-step approach is the way to go. Thanks. Joe Conway wrote: Tom Lane wrote: Stephan Szabo <[EMAIL PROTECTED]> writes: On Tue, 2 Mar 2004, Terence Kearns wrote: Well I haven't yet do

Re: [SQL] returning a recordset from PLpg/SQL

2004-03-01 Thread Terence Kearns
Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > >> On Tue, 2 Mar 2004, Terence Kearns wrote: >> >>> Well I haven't yet done anything because I couldn't get anything to >>> compile which returned SETOF RECORD.. > > > &

Re: [SQL] returning a recordset from PLpg/SQL

2004-03-01 Thread Terence Kearns
Tom Lane wrote: > Terence Kearns <[EMAIL PROTECTED]> writes: > >>I tried >>RETURNS SETOF RECORD >>but that doesn't work > > > Sure it does, if you use it correctly. Better show us what you did. > >regards, tom lane Well

[SQL] returning a recordset from PLpg/SQL

2004-02-29 Thread Terence Kearns
Looking at the datatypes you can RETURN, it doesn't seem that there is a way to return a recordset I tried RETURNS SETOF RECORD but that doesn't work I even tried RETURNS SETOF fooTable%ROWTYPE What I would like to do is not that simple, I need to be able to build/declare a record definition wit

[SQL] cygwin warnings in the log file

2004-01-21 Thread Terence Kearns
I get these LOG: shmdt(0xf8) failed: Invalid argument anyone know what's up with that? ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] Is there a more elegant way to write this query?...

2003-11-19 Thread Terence Kearns
Nick Fankhauser wrote: Hi- I'm suffering from a performance problem, but when I look at my query, I'm not convinced that there isn't a better way to handle this in SQL. -So I'm seeking advice here before I go to the performance list. I have three tables- case, actor and actor_case_assignment. As

Re: [SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-19 Thread Terence Kearns
Josh Berkus wrote: Terence, Oh well, can't win them all :/ Nope. I'll suggest that for the TODO list ... we already have several requests for added features for PL/pgSQL. The problem is that we currently don't have a lead developer for PL/pgSQL, so the language has rather stagnated. Well

Re: [SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-18 Thread Terence Kearns
Richard Huxton wrote: On Friday 18 Jul 2003 9:22 am, Terence Kearns wrote: I'm writing a trigger which wants to reference the pre-defined NEW record. I can do this idval := NEW.blah; This works fine!!! What I really need to do is idval := NEW.(quote_ident(TG_ARGV[3])); or this idval :

[SQL] (trigger function) -> ERROR: NEW used in non-rule query

2003-07-18 Thread Terence Kearns
co at http://www.postgresql.org/docs/7.3/interactive/plpgsql-trigger.html using pg 7.3.3 -- Terence Kearns ~ ph: +61 2 6201 5516 IT Database/Applications Developer Enterprise Information Systems Client Services Division University of Canberra www.canberra.edu.au ---(end of bro

[SQL] parse error for function def

2003-07-17 Thread Terence Kearns
eate a function to use on a trigger to check reference to views since pg does not support foreign keys referencing views. -- Terence Kearns ~ ph: +61 2 6201 5516 IT Database/Applications Developer Enterprise Information Systems Client Services Division University of Canberra www.canberra.edu.au

Re: [SQL] relevance

2003-07-17 Thread Terence Kearns
Rajesh Kumar Mallah wrote: On Thursday 17 Jul 2003 8:21 am, Terence Kearns wrote: select id from tablename where message like '%sql%'; If there any way to determine exactly how many times 'sql' is matched in that search in each particular row, and then sort by the most ma

Re: [SQL] relevance

2003-07-16 Thread Terence Kearns
uld probably write a function in postgres (say, "matchcount()") which returns the match count (possibly using perl and a regex). SELECT matchcount(message,'sql') AS matchcount, id FROM tablename WHERE message LIKE '%sql%' ORDER BY matchcount(message,'sql') DESC The