pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Senthil Kumar S <ssakkaravel@ivesia.com>
To: psql <pgsql-sql@postgresql.org>
Subject: writing a dynamic sql
Date: Tue, 10 Feb 2004 15:18:27 +0530
Message-ID: <01b201c3efbb$097a2af0$7502a8c0@hdsc.com> (raw)

Dear friends,

I am having an lengthy SQL, which will be called every conditions of if...else statement. I tried with passing that via a string and execute it.
But I got error.

v_sql :=
  'INSERT INTO activities(
    activity_id,
    parent_activity_id,
    activity_type_id,
    subject,
    description,
    category_id,
    priority_id,
    activity_start_time,
    activity_end_time,
)
 VALUES   (
    NEXTVAL(\'seq_activities\'),
    rec_recurrence.activity_id,
    rec_activity.activity_type_id,
    rec_activity.subject,
    rec_activity.description,
    rec_activity.category_id,
    rec_activity.priority_id,
    rec_activity.activity_start_time,
    rec_activity.activity_end_time
);';

  execute v_sql;

I got an error saying that the record variable which I declared earlier is
not having reference (or it does not exists).

Any suggestion to pack this inside a dynamic function and call it inside
many if conditions.

Pls shed some light.

Regards
kumar

view thread (2+ messages)  latest in thread

Message-ID: <01b201c3efbb$097a2af0$7502a8c0@hdsc.com>
Permalink:  ../01b201c3efbb$097a2af0$7502a8c0@hdsc.com/
Also on:    postgresql.org/message-id/01b201c3efbb$097a2af0$7502a8c0@hdsc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ssakkaravel@ivesia.com
  Subject: Re: writing a dynamic sql
  In-Reply-To: <01b201c3efbb$097a2af0$7502a8c0@hdsc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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