Re: [SQL] Some help with functions-syntax

2007-01-17 Thread Jan Meyland Andersen
> There are two forms to iterate over the query: > > 1. FOR target IN query LOOP > 2. FOR target IN EXECUTE text_expression LOOP Thanks for your answer. > My suggestion is to eliminate the string you created (_WHERECLAUSE) and > add the proper conditions to the query expression you already have.

[SQL] Some help with functions-syntax

2007-01-17 Thread Jan Meyland Andersen
I have some problem with writing a function. I have made this function which I can't get it to work. This is probaly a triviel question but i'm new to plsql, so this is a showstopper for me. DECLARE _relkind char; _RES "EMS"."KeySet"; _WHERECLAUSE text; BEGIN SELE

Re: [SQL] Related tables to a view

2006-12-27 Thread Jan Meyland Andersen
> Try this query > > > select a.relname as base,a.relkind > from > pg_class a > join pg_depend d on (a.oid = d.refobjid) > join pg_class c on (d.classid = c.oid) > join pg_rewrite r on (objid = r.oid) > join pg_class v on (ev_class = v.oid) > where a.relkind in('r', 'v') > and a.relname <> v.relnam

Re: [SQL] Related tables to a view

2006-12-26 Thread Jan Meyland Andersen
> You could query pg_depend to find out which tables and columns the > view's rewrite rule depends on but that's not as specific as what > you're requesting. I'm not aware of a way to associate a particular > table column with a particular view column short of parsing the view > definition or rule

[SQL] Related tables to a view

2006-12-25 Thread Jan Meyland Andersen
Hi I need a function which are able to return the underlying tables to a view. If I have a view which is a selection from field1 and field2 from table1 and field1 and field2 from table2. How can I make a selection which returns the relation for the fields in a way so I am able to se which field