Trigger with dynamic SQL

--0016e643594ad9c6d30486f19e2a
Content-Type: text/plain; charset=ISO-8859-1

To avoid to delete registers I created one trigger activated "before delete"
with lines like that:
UPDATE tableX set dtExc = 'now', userExc = current_user where idTableX =
OLD.idTableX;
return NULL;

but, I need do the same for many tables and I don't catch how.
I created an sql variable to construct the update command using parameters
on trigger
qry := 'UPDATE '||arg_table||' set userexc = '
||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
arg_id ||' = OLD.'||TG_ARGV[1];

but when "EXECUTE qry" I lost the OLD.variable.

I can't send the bigint id to delete in trigger parameters.

Any suggestions?

Thanks in advance,
Josi Perez

--0016e643594ad9c6d30486f19e2a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<span style=3D"font-family: verdana,sans-serif;">To avoid to delete registe=
rs I created one trigger activated "before delete" with lines lik=
e that:</span><br style=3D"font-family: verdana,sans-serif;"><span style=3D=
"font-family: verdana,sans-serif;">UPDATE tableX=A0 set dtExc =3D 'now&=
#39;, userExc =3D current_user where idTableX =3D OLD.idTableX;</span><br s=
tyle=3D"font-family: verdana,sans-serif;">
<span style=3D"font-family: verdana,sans-serif;">return NULL;</span><br sty=
le=3D"font-family: verdana,sans-serif;"><br style=3D"font-family: verdana,s=
ans-serif;"><span style=3D"font-family: verdana,sans-serif;">but, I need do=
the same for many tables and I don't catch how.</span><br style=3D"fon=
t-family: verdana,sans-serif;">
<span style=3D"font-family: verdana,sans-serif;">I created an sql variable =
to construct the update command using parameters on trigger</span><br style=
=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: verdana,s=
ans-serif;">=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' se=
t userexc =3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '=
;||'''now'''||' where ' || arg_id ||' =
=3D OLD.'||TG_ARGV[1];</span><br style=3D"font-family: verdana,sans-ser=
if;">
<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">but when "EXECUTE qry" I lost the OLD.variab=
le.</span><br style=3D"font-family: verdana,sans-serif;"><br style=3D"font-=
family: verdana,sans-serif;">
<span style=3D"font-family: verdana,sans-serif;">I can't send the bigin=
t id to delete in trigger parameters.</span><br style=3D"font-family: verda=
na,sans-serif;"><br style=3D"font-family: verdana,sans-serif;"><span style=
=3D"font-family: verdana,sans-serif;">Any suggestions?</span><br style=3D"f=
ont-family: verdana,sans-serif;">
<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">Thanks in advance,</span><br style=3D"font-family: ver=
dana,sans-serif;"><span style=3D"font-family: verdana,sans-serif;">Josi Per=
ez</span><br style=3D"font-family: verdana,sans-serif;">
<br><div style=3D"visibility: hidden; display: inline;" id=3D"avg_ls_inline=
_popup"></div><style type=3D"text/css">#avg_ls_inline_popup { position:abs=
olute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0p=
x; width: 240px; overflow: hidden; word-wrap: break-word; color: black;=
font-size: 10px; text-align: left; line-height: 13px;}</style>

--0016e643594ad9c6d30486f19e2a--
josiperez3t [ Mi, 19 Mai 2010 14:30 ] [ ID #2041677 ]

Re: Trigger with dynamic SQL

--001636b14798a05c440487596837
Content-Type: text/plain; charset=ISO-8859-1

Sorry for the inconvenience, but no one have ideas to solve this problem? Am
I in the wrong list to ask this?
Need I create triggers for each table?

Thanks in advance for any suggestions.
Josi Perez

2010/5/19 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>

> To avoid to delete registers I created one trigger activated "before
> delete" with lines like that:
> UPDATE tableX set dtExc = 'now', userExc = current_user where idTableX =
> OLD.idTableX;
> return NULL;
>
> but, I need do the same for many tables and I don't catch how.
> I created an sql variable to construct the update command using parameters
> on trigger
> qry := 'UPDATE '||arg_table||' set userexc = '
> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
> arg_id ||' = OLD.'||TG_ARGV[1];
>
> but when "EXECUTE qry" I lost the OLD.variable.
>
> I can't send the bigint id to delete in trigger parameters.
>
> Any suggestions?
>
> Thanks in advance,
> Josi Perez
>
>

--001636b14798a05c440487596837
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Sorry for the inconvenience, but no one have ideas to solve this problem? A=
m I in the wrong list to ask this?<br>Need I create triggers for each table=
?<br><br>Thanks in advance for any suggestions.<br>Josi Perez<br><br><div c=
lass=3D"gmail_quote">
2010/5/19 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=3D"mailto:j=
osiperez3t [at] gmail.com">josiperez3t [at] gmail.com</a>></span><br><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px s=
olid rgb(204, 204, 204); padding-left: 1ex;">
<span style=3D"font-family: verdana,sans-serif;">To avoid to delete registe=
rs I created one trigger activated "before delete" with lines lik=
e that:</span><br style=3D"font-family: verdana,sans-serif;"><span style=3D=
"font-family: verdana,sans-serif;">UPDATE tableX=A0 set dtExc =3D 'now&=
#39;, userExc =3D current_user where idTableX =3D OLD.idTableX;</span><br s=
tyle=3D"font-family: verdana,sans-serif;">

<span style=3D"font-family: verdana,sans-serif;">return NULL;</span><br sty=
le=3D"font-family: verdana,sans-serif;"><br style=3D"font-family: verdana,s=
ans-serif;"><span style=3D"font-family: verdana,sans-serif;">but, I need do=
the same for many tables and I don't catch how.</span><br style=3D"fon=
t-family: verdana,sans-serif;">

<span style=3D"font-family: verdana,sans-serif;">I created an sql variable =
to construct the update command using parameters on trigger</span><br style=
=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: verdana,s=
ans-serif;">=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' se=
t userexc =3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '=
;||'''now'''||' where ' || arg_id ||' =
=3D OLD.'||TG_ARGV[1];</span><br style=3D"font-family: verdana,sans-ser=
if;">

<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">but when "EXECUTE qry" I lost the OLD.variab=
le.</span><br style=3D"font-family: verdana,sans-serif;"><br style=3D"font-=
family: verdana,sans-serif;">

<span style=3D"font-family: verdana,sans-serif;">I can't send the bigin=
t id to delete in trigger parameters.</span><br style=3D"font-family: verda=
na,sans-serif;"><br style=3D"font-family: verdana,sans-serif;"><span style=
=3D"font-family: verdana,sans-serif;">Any suggestions?</span><br style=3D"f=
ont-family: verdana,sans-serif;">

<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">Thanks in advance,</span><br style=3D"font-family: ver=
dana,sans-serif;"><font color=3D"#888888"><span style=3D"font-family: verda=
na,sans-serif;">Josi Perez</span><br style=3D"font-family: verdana,sans-ser=
if;">

<br><div style=3D"display: inline;"></div>
</font></blockquote></div><br><div style=3D"visibility: hidden; display: in=
line;" id=3D"avg_ls_inline_popup"></div><style type=3D"text/css">#avg_ls_in=
line_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-=
left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: =
break-word; color: black; font-size: 10px; text-align: left; line-heigh=
t: 13px;}</style>

--001636b14798a05c440487596837--
josiperez3t [ Mo, 24 Mai 2010 18:19 ] [ ID #2041944 ]

Re: Trigger with dynamic SQL

--0016367fa760f720910487599457
Content-Type: text/plain; charset=UTF-8

2010/5/24 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>

> Sorry for the inconvenience, but no one have ideas to solve this problem?
> Am I in the wrong list to ask this?
> Need I create triggers for each table?
>
> Thanks in advance for any suggestions.
> Josi Perez
>
> 2010/5/19 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>
>
> To avoid to delete registers I created one trigger activated "before
>> delete" with lines like that:
>> UPDATE tableX set dtExc = 'now', userExc = current_user where idTableX =
>> OLD.idTableX;
>> return NULL;
>>
>> but, I need do the same for many tables and I don't catch how.
>> I created an sql variable to construct the update command using parameters
>> on trigger
>> qry := 'UPDATE '||arg_table||' set userexc = '
>> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
>> arg_id ||' = OLD.'||TG_ARGV[1];
>>
>> but when "EXECUTE qry" I lost the OLD.variable.
>>
>> I can't send the bigint id to delete in trigger parameters.
>>
>> Any suggestions?
>>
>> Thanks in advance,
>> Josi Perez
>>
>>
>
What is the problem? What do you mean by "lost the OLD.variable"? Better
show us the whole trigger code as I really don't get it.

regards
Szymon Guz

--0016367fa760f720910487599457
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div class=3D"gmail_quote">2010/5/24 Josi Perez (3T Systems) <span dir=3D"l=
tr"><<a href=3D"mailto:josiperez3t [at] gmail.com">josiperez3t [at] gmail.com</a>&=
gt;</span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex;">
Sorry for the inconvenience, but no one have ideas to solve this problem? A=
m I in the wrong list to ask this?<br>Need I create triggers for each table=
?<br><br>Thanks in advance for any suggestions.<br>Josi Perez<br><br><div c=
lass=3D"gmail_quote">

2010/5/19 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=3D"mailto:j=
osiperez3t [at] gmail.com" target=3D"_blank">josiperez3t [at] gmail.com</a>></span=
><div><div></div><div class=3D"h5"><br><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);pa=
dding-left:1ex">

<span style=3D"font-family:verdana,sans-serif">To avoid to delete registers=
I created one trigger activated "before delete" with lines like =
that:</span><br style=3D"font-family:verdana,sans-serif"><span style=3D"fon=
t-family:verdana,sans-serif">UPDATE tableX=C2=A0 set dtExc =3D 'now'=
;, userExc =3D current_user where idTableX =3D OLD.idTableX;</span><br styl=
e=3D"font-family:verdana,sans-serif">


<span style=3D"font-family:verdana,sans-serif">return NULL;</span><br style=
=3D"font-family:verdana,sans-serif"><br style=3D"font-family:verdana,sans-s=
erif"><span style=3D"font-family:verdana,sans-serif">but, I need do the sam=
e for many tables and I don't catch how.</span><br style=3D"font-family=
:verdana,sans-serif">


<span style=3D"font-family:verdana,sans-serif">I created an sql variable to=
construct the update command using parameters on trigger</span><br style=
=3D"font-family:verdana,sans-serif"><span style=3D"font-family:verdana,sans=
-serif">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qry :=3D 'UPDATE '||arg_tabl=
e||' set userexc =3D ' ||chr(39)||current_user||chr(39)||', dta=
lt =3D '||'''now'''||' where ' || arg_i=
d ||' =3D OLD.'||TG_ARGV[1];</span><br style=3D"font-family:verdana=
,sans-serif">


<br style=3D"font-family:verdana,sans-serif"><span style=3D"font-family:ver=
dana,sans-serif">but when "EXECUTE qry" I lost the OLD.variable.<=
/span><br style=3D"font-family:verdana,sans-serif"><br style=3D"font-family=
:verdana,sans-serif">


<span style=3D"font-family:verdana,sans-serif">I can't send the bigint =
id to delete in trigger parameters.</span><br style=3D"font-family:verdana,=
sans-serif"><br style=3D"font-family:verdana,sans-serif"><span style=3D"fon=
t-family:verdana,sans-serif">Any suggestions?</span><br style=3D"font-famil=
y:verdana,sans-serif">


<br style=3D"font-family:verdana,sans-serif"><span style=3D"font-family:ver=
dana,sans-serif">Thanks in advance,</span><br style=3D"font-family:verdana,=
sans-serif"><font color=3D"#888888"><span style=3D"font-family:verdana,sans=
-serif">Josi Perez</span><br style=3D"font-family:verdana,sans-serif">


<br><div style=3D"display:inline"></div>
</font></blockquote></div></div></div><br><div style=3D"display:inline"></d=
iv>
</blockquote></div><br><div>What is the problem? What do you mean by "=
lost the OLD.variable"? Better show us the whole trigger code as I rea=
lly don't get it.</div><div><br></div><div>regards</div><div>Szymon Guz=
</div>

--0016367fa760f720910487599457--
Szymon Guz [ Mo, 24 Mai 2010 18:32 ] [ ID #2041945 ]

Re: Trigger with dynamic SQL

On Wed, May 19, 2010 at 06:30, Josi Perez (3T Systems)
<josiperez3t [at] gmail.com> wrote:
> To avoid to delete registers I created one trigger activated "before dele=
te"
> with lines like that:
> UPDATE tableX=C2=A0 set dtExc =3D 'now', userExc =3D current_user where i=
dTableX =3D
> OLD.idTableX;
> return NULL;
>
> but, I need do the same for many tables and I don't catch how.
> I created an sql variable to construct the update command using parameters
> on trigger
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qry :=3D 'UPDATE '||arg_table||' set usere=
xc =3D '
> ||chr(39)||current_user||chr(39)||', dtalt =3D '||'''now'''||' where ' ||
> arg_id ||' =3D OLD.'||TG_ARGV[1];
>
> but when "EXECUTE qry" I lost the OLD.variable.

Yeah, when the update runs its not running under pgpsql so referencing
OLD wont work. Try something like (note completely untested):

qry :=3D 'UPDATE '|| quote_ident(arg_table) ||
' SET userexc =3D current_user, dtalt =3D now() where '||
quote_literal(arg_id) ||' =3D '|| quote_literal(OLD.TG_ARGV[1]) ||';';

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Alex Hunsaker [ Mo, 24 Mai 2010 20:14 ] [ ID #2041946 ]

Re: Trigger with dynamic SQL

--0016e643594a35f57104875b8e81
Content-Type: text/plain; charset=ISO-8859-1

Thank you.

The trigger:
CREATE OR REPLACE FUNCTION logdata()
RETURNS trigger AS
$BODY$DECLARE
arg_table varchar;
arg_id varchar;
arg_old integer;
qry text;

BEGIN
arg_table := TG_ARGV[0];
arg_id := TG_ARGV[1]; --field to use OLD.id
arg_old := TG_ARGV[2]; --value

if TG_OP = 'INSERT' then
new.userinc := current_user;
new.dtinc := 'now';
return new;
elseif TG_OP = 'UPDATE' then
new.useralt := current_user;
new.dtalt := 'now';
return new;

*elseif TG_OP = 'DELETE' then
---just user postgresW can delete
if current_user <> 'postgresW' then
-- trying to mount the SQL
--qry := 'UPDATE '||arg_table||' set userexc = '
||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
arg_id ||' = OLD.'||TG_ARGV[1];
qry := 'UPDATE '||arg_table||' set userexc = '
||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
arg_id ||' = '||to_char(arg_old,'999999');

--qry := 'update '||quote_ident(arg_table)||"set dtexc = now, userexc
= current_user "||"where
"||quote_ident(arg_id)||"=OLD."||quote_ident(arg_id)||";";

raise notice 'QRY = %', qry;
EXECUTE qry;
--EXECUTE 'UPDATE '||arg_table||' set userexc = '
||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
arg_id ||' = OLD.'||TG_ARGV[1];
--EXECUTE 'update '||quote_ident(arg_table)||' set userexc ='||
current_user ||' where '||quote_ident(arg_id)||' =
OLD.'||quote_ident(arg_id)||';';
--update opcao set dtexc = 'now', userexc = current_user
-- where idopcao = OLD.idopcao;
return NULL;*
else
return OLD;
end if;
end if;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION logdata() OWNER TO postgres;


To each table:
CREATE TRIGGER logdatatable
BEFORE INSERT OR UPDATE OR DELETE
ON opcao
FOR EACH ROW
EXECUTE PROCEDURE logdata('op', 'idop', idop);

I could not send the current idop (integer) to mount a SQL without OLD.
The goal is to use the same trigger changing just the parameters in each
table.

Thanks in advance,
Josi Perez



2010/5/24 Szymon Guz <mabewlun [at] gmail.com>

> 2010/5/24 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>
>
> Sorry for the inconvenience, but no one have ideas to solve this problem?
>> Am I in the wrong list to ask this?
>> Need I create triggers for each table?
>>
>> Thanks in advance for any suggestions.
>> Josi Perez
>>
>> 2010/5/19 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>
>>
>> To avoid to delete registers I created one trigger activated "before
>>> delete" with lines like that:
>>> UPDATE tableX set dtExc = 'now', userExc = current_user where idTableX =
>>> OLD.idTableX;
>>> return NULL;
>>>
>>> but, I need do the same for many tables and I don't catch how.
>>> I created an sql variable to construct the update command using
>>> parameters on trigger
>>> qry := 'UPDATE '||arg_table||' set userexc = '
>>> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
>>> arg_id ||' = OLD.'||TG_ARGV[1];
>>>
>>> but when "EXECUTE qry" I lost the OLD.variable.
>>>
>>> I can't send the bigint id to delete in trigger parameters.
>>>
>>> Any suggestions?
>>>
>>> Thanks in advance,
>>> Josi Perez
>>>
>>>
>>
> What is the problem? What do you mean by "lost the OLD.variable"? Better
> show us the whole trigger code as I really don't get it.
>
> regards
> Szymon Guz
>

--0016e643594a35f57104875b8e81
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Thank you.<br><br>The trigger:<br>CREATE OR REPLACE FUNCTION logdata()<br>=
=A0 RETURNS trigger AS<br>$BODY$DECLARE<br>=A0=A0 arg_table=A0 varchar;<br>=
=A0=A0 arg_id=A0=A0=A0=A0 varchar;<br>=A0=A0 arg_old=A0=A0=A0 integer;<br>=
=A0=A0 qry=A0=A0=A0=A0=A0=A0=A0 text;<br><br>BEGIN<br>
arg_table :=3D TG_ARGV[0];=A0 <br>arg_id=A0=A0=A0 :=3D TG_ARGV[1];=A0=A0=A0=
--field to use OLD.id<br>arg_old=A0=A0 :=3D TG_ARGV[2];=A0=A0 --value<br><=
br>if TG_OP =3D 'INSERT' then<br>=A0=A0 new.userinc :=3D current_us=
er;<br>=A0=A0 new.dtinc :=3D 'now';<br>
=A0=A0 return new;<br>elseif TG_OP =3D 'UPDATE' then<br>=A0=A0 new.=
useralt :=3D current_user;<br>=A0=A0 new.dtalt :=3D 'now';<br>=A0=
=A0 return new;<br><br><b>elseif TG_OP =3D 'DELETE' then<br>=A0=A0 =
---just user postgresW can delete<br>
=A0=A0 if current_user <> 'postgresW' then<br>=A0=A0=A0=A0=A0=
-- trying to mount the SQL<br>=A0=A0=A0=A0=A0 --qry :=3D 'UPDATE '=
||arg_table||' set userexc =3D ' ||chr(39)||current_user||chr(39)||=
', dtalt =3D '||'''now'''||' where '=
; || arg_id ||' =3D OLD.'||TG_ARGV[1];<br>
=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' set userexc =
=3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '||'&#=
39;'now'''||' where ' || arg_id ||' =3D '||=
to_char(arg_old,'999999');<br>
<br>=A0=A0=A0=A0=A0 --qry :=3D 'update '||quote_ident(arg_table)||&=
quot;set dtexc =3D now, userexc =3D current_user "||"where "=
||quote_ident(arg_id)||"=3DOLD."||quote_ident(arg_id)||";&qu=
ot;;<br><br>=A0=A0=A0=A0=A0 raise notice 'QRY =3D %', qry;<br>
=A0=A0=A0=A0=A0 EXECUTE qry;<br>=A0=A0=A0=A0=A0 --EXECUTE 'UPDATE '=
||arg_table||' set userexc =3D ' ||chr(39)||current_user||chr(39)||=
', dtalt =3D '||'''now'''||' where '=
; || arg_id ||' =3D OLD.'||TG_ARGV[1];<br>
=A0=A0=A0=A0=A0 --EXECUTE 'update '||quote_ident(arg_table)||' =
set userexc =3D'|| current_user ||' where '||quote_ident(arg_id=
)||' =3D OLD.'||quote_ident(arg_id)||';';<br>=A0=A0=A0=A0=
=A0 --update opcao set dtexc =3D 'now', userexc =3D current_user<br=
>
=A0=A0=A0=A0=A0 -- where idopcao =3D OLD.idopcao;<br>=A0=A0=A0=A0=A0 return=
NULL;</b><br>=A0=A0 else<br>=A0=A0=A0=A0=A0 return OLD;<br>=A0=A0 end if;<=
br>end if;<br>END;$BODY$<br>=A0 LANGUAGE 'plpgsql' VOLATILE<br>=A0 =
COST 100;<br>ALTER FUNCTION logdata() OWNER TO postgres;<br>
<br><br>To each table:<br>CREATE TRIGGER logdatatable<br>=A0 BEFORE INSERT =
OR UPDATE OR DELETE<br>=A0 ON opcao<br>=A0 FOR EACH ROW<br>=A0 EXECUTE PROC=
EDURE logdata('op', 'idop', idop);<br><br>I could not send =
the current idop (integer) to mount a SQL without OLD.<br>
The goal is to use the same trigger changing just the parameters in each ta=
ble.<br><br>Thanks in advance,<br>Josi Perez<br><br><br><br><div class=3D"g=
mail_quote">2010/5/24 Szymon Guz <span dir=3D"ltr"><<a href=3D"mailto:ma=
bewlun [at] gmail.com">mabewlun [at] gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class=3D"gma=
il_quote">2010/5/24 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=
=3D"mailto:josiperez3t [at] gmail.com" target=3D"_blank">josiperez3t [at] gmail.com</=
a>></span><div>
<div></div><div class=3D"h5"><br><blockquote class=3D"gmail_quote" style=3D=
"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padd=
ing-left: 1ex;">
Sorry for the inconvenience, but no one have ideas to solve this problem? A=
m I in the wrong list to ask this?<br>Need I create triggers for each table=
?<br><br>Thanks in advance for any suggestions.<br>Josi Perez<br><br><div c=
lass=3D"gmail_quote">


2010/5/19 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=3D"mailto:j=
osiperez3t [at] gmail.com" target=3D"_blank">josiperez3t [at] gmail.com</a>></span=
><div><div></div><div><br><blockquote class=3D"gmail_quote" style=3D"margin=
: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-lef=
t: 1ex;">


<span style=3D"font-family: verdana,sans-serif;">To avoid to delete registe=
rs I created one trigger activated "before delete" with lines lik=
e that:</span><br style=3D"font-family: verdana,sans-serif;"><span style=3D=
"font-family: verdana,sans-serif;">UPDATE tableX=A0 set dtExc =3D 'now&=
#39;, userExc =3D current_user where idTableX =3D OLD.idTableX;</span><br s=
tyle=3D"font-family: verdana,sans-serif;">



<span style=3D"font-family: verdana,sans-serif;">return NULL;</span><br sty=
le=3D"font-family: verdana,sans-serif;"><br style=3D"font-family: verdana,s=
ans-serif;"><span style=3D"font-family: verdana,sans-serif;">but, I need do=
the same for many tables and I don't catch how.</span><br style=3D"fon=
t-family: verdana,sans-serif;">



<span style=3D"font-family: verdana,sans-serif;">I created an sql variable =
to construct the update command using parameters on trigger</span><br style=
=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: verdana,s=
ans-serif;">=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' se=
t userexc =3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '=
;||'''now'''||' where ' || arg_id ||' =
=3D OLD.'||TG_ARGV[1];</span><br style=3D"font-family: verdana,sans-ser=
if;">



<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">but when "EXECUTE qry" I lost the OLD.variab=
le.</span><br style=3D"font-family: verdana,sans-serif;"><br style=3D"font-=
family: verdana,sans-serif;">



<span style=3D"font-family: verdana,sans-serif;">I can't send the bigin=
t id to delete in trigger parameters.</span><br style=3D"font-family: verda=
na,sans-serif;"><br style=3D"font-family: verdana,sans-serif;"><span style=
=3D"font-family: verdana,sans-serif;">Any suggestions?</span><br style=3D"f=
ont-family: verdana,sans-serif;">



<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">Thanks in advance,</span><br style=3D"font-family: ver=
dana,sans-serif;"><font color=3D"#888888"><span style=3D"font-family: verda=
na,sans-serif;">Josi Perez</span><br style=3D"font-family: verdana,sans-ser=
if;">



<br><div style=3D"display: inline;"></div>
</font></blockquote></div></div></div><br><div style=3D"display: inline;"><=
/div>
</blockquote></div></div></div><br><div>What is the problem? What do you me=
an by "lost the OLD.variable"? Better show us the whole trigger c=
ode as I really don't get it.</div><div><br></div><div>regards</div>
<div>Szymon Guz</div>
</blockquote></div><br><div style=3D"visibility: hidden; display: inline;" =
id=3D"avg_ls_inline_popup"></div><style type=3D"text/css">#avg_ls_inline_po=
pup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0=
px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-w=
ord; color: black; font-size: 10px; text-align: left; line-height: 13px=
;}</style>

--0016e643594a35f57104875b8e81--
josiperez3t [ Mo, 24 Mai 2010 20:53 ] [ ID #2041948 ]

Re: Trigger with dynamic SQL

--0016367b6c7274bb1304876fae43
Content-Type: text/plain; charset=ISO-8859-1

Alex Hunsaker, thank you for your suggestion, but, the processor do not
replace OLD.TG_ARGV[1] by the content.
If I use OLD in EXECUTE it is not recognized.
I didn't get how to pass an integer variable to the trigger.

I already create repeteadly times the trigger changing the UPDATE comand
inside the TG_OPER DELETE for each table, but, I really appreciate to know
if there is a solution for this.

Thank you in advance,
Josi Perez


2010/5/24 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>

> Thank you.
>
> The trigger:
> CREATE OR REPLACE FUNCTION logdata()
> RETURNS trigger AS
> $BODY$DECLARE
> arg_table varchar;
> arg_id varchar;
> arg_old integer;
> qry text;
>
> BEGIN
> arg_table := TG_ARGV[0];
> arg_id := TG_ARGV[1]; --field to use OLD.id
> arg_old := TG_ARGV[2]; --value
>
> if TG_OP = 'INSERT' then
> new.userinc := current_user;
> new.dtinc := 'now';
> return new;
> elseif TG_OP = 'UPDATE' then
> new.useralt := current_user;
> new.dtalt := 'now';
> return new;
>
> *elseif TG_OP = 'DELETE' then
> ---just user postgresW can delete
> if current_user <> 'postgresW' then
> -- trying to mount the SQL
> --qry := 'UPDATE '||arg_table||' set userexc = '
> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
> arg_id ||' = OLD.'||TG_ARGV[1];
> qry := 'UPDATE '||arg_table||' set userexc = '
> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
> arg_id ||' = '||to_char(arg_old,'999999');
>
> --qry := 'update '||quote_ident(arg_table)||"set dtexc = now, userexc
> = current_user "||"where
> "||quote_ident(arg_id)||"=OLD."||quote_ident(arg_id)||";";
>
> raise notice 'QRY = %', qry;
> EXECUTE qry;
> --EXECUTE 'UPDATE '||arg_table||' set userexc = '
> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
> arg_id ||' = OLD.'||TG_ARGV[1];
> --EXECUTE 'update '||quote_ident(arg_table)||' set userexc ='||
> current_user ||' where '||quote_ident(arg_id)||' =
> OLD.'||quote_ident(arg_id)||';';
> --update opcao set dtexc = 'now', userexc = current_user
> -- where idopcao = OLD.idopcao;
> return NULL;*
> else
> return OLD;
> end if;
> end if;
> END;$BODY$
> LANGUAGE 'plpgsql' VOLATILE
> COST 100;
> ALTER FUNCTION logdata() OWNER TO postgres;
>
>
> To each table:
> CREATE TRIGGER logdatatable
> BEFORE INSERT OR UPDATE OR DELETE
> ON opcao
> FOR EACH ROW
> EXECUTE PROCEDURE logdata('op', 'idop', idop);
>
> I could not send the current idop (integer) to mount a SQL without OLD.
> The goal is to use the same trigger changing just the parameters in each
> table.
>
> Thanks in advance,
> Josi Perez
>
>
>
> 2010/5/24 Szymon Guz <mabewlun [at] gmail.com>
>
> 2010/5/24 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>
>>
>> Sorry for the inconvenience, but no one have ideas to solve this problem?
>>> Am I in the wrong list to ask this?
>>> Need I create triggers for each table?
>>>
>>> Thanks in advance for any suggestions.
>>> Josi Perez
>>>
>>> 2010/5/19 Josi Perez (3T Systems) <josiperez3t [at] gmail.com>
>>>
>>> To avoid to delete registers I created one trigger activated "before
>>>> delete" with lines like that:
>>>> UPDATE tableX set dtExc = 'now', userExc = current_user where idTableX
>>>> = OLD.idTableX;
>>>> return NULL;
>>>>
>>>> but, I need do the same for many tables and I don't catch how.
>>>> I created an sql variable to construct the update command using
>>>> parameters on trigger
>>>> qry := 'UPDATE '||arg_table||' set userexc = '
>>>> ||chr(39)||current_user||chr(39)||', dtalt = '||'''now'''||' where ' ||
>>>> arg_id ||' = OLD.'||TG_ARGV[1];
>>>>
>>>> but when "EXECUTE qry" I lost the OLD.variable.
>>>>
>>>> I can't send the bigint id to delete in trigger parameters.
>>>>
>>>> Any suggestions?
>>>>
>>>> Thanks in advance,
>>>> Josi Perez
>>>>
>>>>
>>>
>> What is the problem? What do you mean by "lost the OLD.variable"? Better
>> show us the whole trigger code as I really don't get it.
>>
>> regards
>> Szymon Guz
>>
>
>

--0016367b6c7274bb1304876fae43
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Alex Hunsaker, thank you for your suggestion, but, the processor do not rep=
lace OLD.TG_ARGV[1] by the content.<br>If I use OLD in EXECUTE it is not re=
cognized.<br>I didn't get how to pass an integer variable to the trigge=
r.<br>
<br>I already create repeteadly times the trigger changing the UPDATE coman=
d inside the TG_OPER DELETE for each table, but, I really appreciate to kno=
w if there is a solution for this.<br><br>Thank you in advance,<br>Josi Per=
ez<br>
<br><br><div class=3D"gmail_quote">2010/5/24 Josi Perez (3T Systems) <span =
dir=3D"ltr"><<a href=3D"mailto:josiperez3t [at] gmail.com">josiperez3t [at] gmail.=
com</a>></span><br><blockquote class=3D"gmail_quote" style=3D"margin: 0p=
t 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1=
ex;">
Thank you.<br><br>The trigger:<br>CREATE OR REPLACE FUNCTION logdata()<br>=
=A0 RETURNS trigger AS<br>$BODY$DECLARE<br>=A0=A0 arg_table=A0 varchar;<br>=
=A0=A0 arg_id=A0=A0=A0=A0 varchar;<br>=A0=A0 arg_old=A0=A0=A0 integer;<br>=
=A0=A0 qry=A0=A0=A0=A0=A0=A0=A0 text;<br><br>BEGIN<br>

arg_table :=3D TG_ARGV[0];=A0 <br>arg_id=A0=A0=A0 :=3D TG_ARGV[1];=A0=A0=A0=
--field to use OLD.id<br>arg_old=A0=A0 :=3D TG_ARGV[2];=A0=A0 --value<br><=
br>if TG_OP =3D 'INSERT' then<br>=A0=A0 new.userinc :=3D current_us=
er;<br>=A0=A0 new.dtinc :=3D 'now';<br>

=A0=A0 return new;<br>elseif TG_OP =3D 'UPDATE' then<br>=A0=A0 new.=
useralt :=3D current_user;<br>=A0=A0 new.dtalt :=3D 'now';<br>=A0=
=A0 return new;<br><br><b>elseif TG_OP =3D 'DELETE' then<br>=A0=A0 =
---just user postgresW can delete<br>

=A0=A0 if current_user <> 'postgresW' then<br>=A0=A0=A0=A0=A0=
-- trying to mount the SQL<br>=A0=A0=A0=A0=A0 --qry :=3D 'UPDATE '=
||arg_table||' set userexc =3D ' ||chr(39)||current_user||chr(39)||=
', dtalt =3D '||'''now'''||' where '=
; || arg_id ||' =3D OLD.'||TG_ARGV[1];<br>

=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' set userexc =
=3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '||'&#=
39;'now'''||' where ' || arg_id ||' =3D '||=
to_char(arg_old,'999999');<br>

<br>=A0=A0=A0=A0=A0 --qry :=3D 'update '||quote_ident(arg_table)||&=
quot;set dtexc =3D now, userexc =3D current_user "||"where "=
||quote_ident(arg_id)||"=3DOLD."||quote_ident(arg_id)||";&qu=
ot;;<br><br>=A0=A0=A0=A0=A0 raise notice 'QRY =3D %', qry;<br>

=A0=A0=A0=A0=A0 EXECUTE qry;<br>=A0=A0=A0=A0=A0 --EXECUTE 'UPDATE '=
||arg_table||' set userexc =3D ' ||chr(39)||current_user||chr(39)||=
', dtalt =3D '||'''now'''||' where '=
; || arg_id ||' =3D OLD.'||TG_ARGV[1];<br>

=A0=A0=A0=A0=A0 --EXECUTE 'update '||quote_ident(arg_table)||' =
set userexc =3D'|| current_user ||' where '||quote_ident(arg_id=
)||' =3D OLD.'||quote_ident(arg_id)||';';<br>=A0=A0=A0=A0=
=A0 --update opcao set dtexc =3D 'now', userexc =3D current_user<br=
>

=A0=A0=A0=A0=A0 -- where idopcao =3D OLD.idopcao;<br>=A0=A0=A0=A0=A0 return=
NULL;</b><br>=A0=A0 else<br>=A0=A0=A0=A0=A0 return OLD;<br>=A0=A0 end if;<=
br>end if;<br>END;$BODY$<br>=A0 LANGUAGE 'plpgsql' VOLATILE<br>=A0 =
COST 100;<br>ALTER FUNCTION logdata() OWNER TO postgres;<br>

<br><br>To each table:<br>CREATE TRIGGER logdatatable<br>=A0 BEFORE INSERT =
OR UPDATE OR DELETE<br>=A0 ON opcao<br>=A0 FOR EACH ROW<br>=A0 EXECUTE PROC=
EDURE logdata('op', 'idop', idop);<br><br>I could not send =
the current idop (integer) to mount a SQL without OLD.<br>

The goal is to use the same trigger changing just the parameters in each ta=
ble.<br><br>Thanks in advance,<br>Josi Perez<br><br><br><br><div class=3D"g=
mail_quote">2010/5/24 Szymon Guz <span dir=3D"ltr"><<a href=3D"mailto:ma=
bewlun [at] gmail.com" target=3D"_blank">mabewlun [at] gmail.com</a>></span><div>
<div></div><div class=3D"h5"><br>
<blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; borde=
r-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class=3D"gma=
il_quote">2010/5/24 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=
=3D"mailto:josiperez3t [at] gmail.com" target=3D"_blank">josiperez3t [at] gmail.com</=
a>></span><div>

<div></div><div><br><blockquote class=3D"gmail_quote" style=3D"margin: 0pt =
0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex=
;">
Sorry for the inconvenience, but no one have ideas to solve this problem? A=
m I in the wrong list to ask this?<br>Need I create triggers for each table=
?<br><br>Thanks in advance for any suggestions.<br>Josi Perez<br><br><div c=
lass=3D"gmail_quote">



2010/5/19 Josi Perez (3T Systems) <span dir=3D"ltr"><<a href=3D"mailto:j=
osiperez3t [at] gmail.com" target=3D"_blank">josiperez3t [at] gmail.com</a>></span=
><div><div></div><div><br><blockquote class=3D"gmail_quote" style=3D"margin=
: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-lef=
t: 1ex;">



<span style=3D"font-family: verdana,sans-serif;">To avoid to delete registe=
rs I created one trigger activated "before delete" with lines lik=
e that:</span><br style=3D"font-family: verdana,sans-serif;"><span style=3D=
"font-family: verdana,sans-serif;">UPDATE tableX=A0 set dtExc =3D 'now&=
#39;, userExc =3D current_user where idTableX =3D OLD.idTableX;</span><br s=
tyle=3D"font-family: verdana,sans-serif;">




<span style=3D"font-family: verdana,sans-serif;">return NULL;</span><br sty=
le=3D"font-family: verdana,sans-serif;"><br style=3D"font-family: verdana,s=
ans-serif;"><span style=3D"font-family: verdana,sans-serif;">but, I need do=
the same for many tables and I don't catch how.</span><br style=3D"fon=
t-family: verdana,sans-serif;">




<span style=3D"font-family: verdana,sans-serif;">I created an sql variable =
to construct the update command using parameters on trigger</span><br style=
=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: verdana,s=
ans-serif;">=A0=A0=A0=A0=A0 qry :=3D 'UPDATE '||arg_table||' se=
t userexc =3D ' ||chr(39)||current_user||chr(39)||', dtalt =3D '=
;||'''now'''||' where ' || arg_id ||' =
=3D OLD.'||TG_ARGV[1];</span><br style=3D"font-family: verdana,sans-ser=
if;">




<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">but when "EXECUTE qry" I lost the OLD.variab=
le.</span><br style=3D"font-family: verdana,sans-serif;"><br style=3D"font-=
family: verdana,sans-serif;">




<span style=3D"font-family: verdana,sans-serif;">I can't send the bigin=
t id to delete in trigger parameters.</span><br style=3D"font-family: verda=
na,sans-serif;"><br style=3D"font-family: verdana,sans-serif;"><span style=
=3D"font-family: verdana,sans-serif;">Any suggestions?</span><br style=3D"f=
ont-family: verdana,sans-serif;">




<br style=3D"font-family: verdana,sans-serif;"><span style=3D"font-family: =
verdana,sans-serif;">Thanks in advance,</span><br style=3D"font-family: ver=
dana,sans-serif;"><font color=3D"#888888"><span style=3D"font-family: verda=
na,sans-serif;">Josi Perez</span><br style=3D"font-family: verdana,sans-ser=
if;">




<br><div style=3D"display: inline;"></div>
</font></blockquote></div></div></div><br><div style=3D"display: inline;"><=
/div>
</blockquote></div></div></div><br><div>What is the problem? What do you me=
an by "lost the OLD.variable"? Better show us the whole trigger c=
ode as I really don't get it.</div><div><br></div><div>regards</div>

<div>Szymon Guz</div>
</blockquote></div></div></div><br><div style=3D"display: inline;"></div>
</blockquote></div><br><div style=3D"visibility: hidden; display: inline;" =
id=3D"avg_ls_inline_popup"></div><style type=3D"text/css">#avg_ls_inline_po=
pup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0=
px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-w=
ord; color: black; font-size: 10px; text-align: left; line-height: 13px=
;}</style>

--0016367b6c7274bb1304876fae43--
josiperez3t [ Di, 25 Mai 2010 20:54 ] [ ID #2042009 ]

Partitioned Tables

--_000_BD69807DAE0CE44CA00A8338D0FDD08302E4F39BFEoma00cexmbx 03_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

If I create a parent table that lives in a specific tablespace, when I crea=
te child tables that inherit the parent and then subsequently index and cre=
ate a PK on the child, will all of the index objects default to the tablesp=
ace that the parent is built in?


Regards,

Joe Plugge

--_000_BD69807DAE0CE44CA00A8338D0FDD08302E4F39BFEoma00cexmbx 03_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" xmlns:p=3D"urn:schemas-m=
icrosoft-com:office:powerpoint" xmlns:a=3D"urn:schemas-microsoft-com:office=
:access" xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s=3D"=
uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs=3D"urn:schemas-microsof=
t-com:rowset" xmlns:z=3D"#RowsetSchema" xmlns:b=3D"urn:schemas-microsoft-co=
m:office:publisher" xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadshee=
t" xmlns:c=3D"urn:schemas-microsoft-com:office:component:spread sheet" xmlns=
:odc=3D"urn:schemas-microsoft-com:office:odc" xmlns:oa=3D"urn:schemas-micro=
soft-com:office:activation" xmlns:html=3D"http://www.w3.org/TR/REC-html40" =
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc=3D"http://m=
icrosoft.com/officenet/conferencing" xmlns:D=3D"DAV:" xmlns:Repl=3D"http://=
schemas.microsoft.com/repl/" xmlns:mt=3D"http://schemas.microsoft.com/share=
point/soap/meetings/" xmlns:x2=3D"http://schemas.microsoft.com/office/excel=
/2003/xml" xmlns:ppda=3D"http://www.passport.com/NameSpace.xsd" xmlns:ois=
=3D"http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir=3D"http://=
schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds=3D"http://www.w3=
..org/2000/09/xmldsig#" xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint=
/dsp" xmlns:udc=3D"http://schemas.microsoft.com/data/udc" xmlns:xsd=3D"http=
://www.w3.org/2001/XMLSchema" xmlns:sub=3D"http://schemas.microsoft.com/sha=
repoint/soap/2002/1/alerts/" xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#"=
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/" xmlns:sps=3D"http://=
schemas.microsoft.com/sharepoint/soap/" xmlns:xsi=3D"http://www.w3.org/2001=
/XMLSchema-instance" xmlns:udcs=3D"http://schemas.microsoft.com/data/udc/so=
ap" xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile " xmlns:udc=
p2p=3D"http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf=3D"http:/=
/schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss=3D"http://sche=
mas.microsoft.com/office/2006/digsig-setup" xmlns:dssi=3D"http://schemas.mi=
crosoft.com/office/2006/digsig" xmlns:mdssi=3D"http://schemas.openxmlformat=
s.org/package/2006/digital-signature" xmlns:mver=3D"http://schemas.openxmlf=
ormats.org/markup-compatibility/2006" xmlns:m=3D"http://schemas.microsoft.c=
om/office/2004/12/omml" xmlns:mrels=3D"http://schemas.openxmlformats.org/pa=
ckage/2006/relationships" xmlns:spwp=3D"http://microsoft.com/sharepoint/web=
partpages" xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/service s/20=
06/types" xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/service s/200=
6/messages" xmlns:pptsl=3D"http://schemas.microsoft.com/sharepoint/soap/ Sli=
deLibrary/" xmlns:spsl=3D"http://microsoft.com/webservices/SharePointPor tal=
Server/PublishedLinksService" xmlns:Z=3D"urn:schemas-microsoft-com:" xmlns:=
st=3D"" xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
[at] font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Tahoma","sans-serif";
color:black;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
..MsoChpDefault
{mso-style-type:export-only;}
[at] page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DWordSection1>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'>If I create a parent table that lives in a specific tablespace=
,
when I create child tables that inherit the parent and then subsequently in=
dex
and create a PK on the child, will all of the index objects default to the
tablespace that the parent is built in?<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'>Regards,<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'><o:p> </o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Tahoma","=
sans-serif";
color:black'>Joe Plugge<o:p></o:p></span></p>

</div>

</body>

</html>

--_000_BD69807DAE0CE44CA00A8338D0FDD08302E4F39BFEoma00cexmbx 03_--
JRPlugge [ Di, 13 Juli 2010 17:40 ] [ ID #2044402 ]
Datenbanken » gmane.comp.db.postgresql.admin » Trigger with dynamic SQL

Vorheriges Thema: cache lookup for operator ...
Nächstes Thema: postgresql failover