pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Function Doubt
2+ messages / 2 participants
[nested] [flat]

* Function Doubt
@ 2005-01-27 17:32 Wilton <wilton.wonrath@microwork.inf.br>
  2005-01-27 17:13 ` Re: Function Doubt Richard Huxton <dev@archonet.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Wilton @ 2005-01-27 17:32 UTC (permalink / raw)
  To: pgsql-sql

Inside a function of trigger type, i have:

Declare
    qCampos record;
    StrCampo string;
    StrInsert string;
Begin

    StrCampo = '''';
    StrInsert = '''';

    For qCampos in select pga.attname from pg_class pgc, pg_attribute pga
                   where pgc.relname = '''' || tg_relname || '''' and
                   pgc.oid = pga.attrelid and pga.attnum > 0 and
                   attisdropped <> ''t'' Loop

       StrCampo = ''new.'' || qCampos.attname;
       StrInsert = StrInsert || virgula || StrCampo || '' - '';
    End Loop;

    Return new;
End;

What i need to do for the variable StrCampo returns to me "SP", "RJ", i 
mean, return a value inserted into the field.
I do not want to use static command new.campo1, new.campo2....

Thanks,

Wilton Ruffato Wonrath



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.6 - Release Date: 27/1/2005




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Function Doubt
  2005-01-27 17:32 Function Doubt Wilton <wilton.wonrath@microwork.inf.br>
@ 2005-01-27 17:13 ` Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2005-01-27 17:13 UTC (permalink / raw)
  To: Wilton <wilton.wonrath@microwork.inf.br>; +Cc: pgsql-sql

Wilton wrote:
>       StrCampo = ''new.'' || qCampos.attname;
>       StrInsert = StrInsert || virgula || StrCampo || '' - '';
>    End Loop;
> 
>    Return new;
> End;
> 
> What i need to do for the variable StrCampo returns to me "SP", "RJ", i 
> mean, return a value inserted into the field.
> I do not want to use static command new.campo1, new.campo2....

Ah - you can't. Not in plpgsql, anyway. You should perhaps look at pltcl 
or plperl.

--
   Richard Huxton
   Archonet Ltd



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-01-27 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-01-27 17:32 Function Doubt Wilton <wilton.wonrath@microwork.inf.br>
2005-01-27 17:13 ` Richard Huxton <dev@archonet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox