writing a dynamic sql

From: "Senthil Kumar S" <ssakkaravel(at)ivesia(dot)com>
To: "psql" <pgsql-sql(at)postgresql(dot)org>
Subject: writing a dynamic sql
Date: 2004-02-10 09:48:27
Message-ID: 01b201c3efbb$097a2af0$7502a8c0@hdsc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message beyaNet Consultancy 2004-02-10 12:04:42 Trace for postgreSQL
Previous Message Kumar 2004-02-10 09:44:59 Re: Error in declaring %rowtype for recurrence