From: | Lee Kindness <lkindness(at)csl(dot)co(dot)uk> |
---|---|
To: | "Marc G(dot) Fournier" <scrappy(at)hub(dot)org> |
Cc: | Lee Kindness <lkindness(at)csl(dot)co(dot)uk>, pgsql-hackers(at)postgresql(dot)org |
Subject: | ecpg "problem" ... |
Date: | 2002-11-13 09:29:58 |
Message-ID: | 15826.7062.975.548240@kelvin.csl.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Marc,
Marc G. Fournier writes:
> if (ic_flag == 1) {
> /*only select those non-IC/Spyder nodes that has full update set*/
> EXEC SQL DECLARE full_dyn_node CURSOR FOR
> SELECT node_name FROM NODE
> WHERE dynamic_community = 'f' AND ic_flag='n' AND machine_type!=22
> AND node_id != 0 AND NODE_NAME != :nodename;
> }
> else{
> EXEC SQL DECLARE full_dyn_node CURSOR FOR
> SELECT node_name FROM NODE
> WHERE dynamic_community = 'f'
> AND node_id != 0 AND NODE_NAME != :nodename; (line#493)
> }
>
> the above code generates the following error:
>
> The compiler complains:
> ../subapi.pgc:493: ERROR: cursor full_dyn_node already defined
>
> since its envelop'd in an if/else clause, shouldn't it work?
Unfortuantely no, you can only ever have one "EXEC SQL DECLARE" for a
given cursor name due to ecpg/ESQL simple parsing. What you would do
in a situation like this is something like:
if( ic_flag == 1 )
/* only select those non-IC/Spyder nodes that has full update set */
sprintf(stmt, "SELECT node_name FROM NODE WHERE dynamic_community = 'f' AND ic_flag = 'n' AND machine_type != 22 AND node_id != 0 AND NODE_NAME != %s", nodename);
else
sprintf(stmt, "SELECT node_name FROM NODE WHERE dynamic_community = 'f' AND node_id != 0 AND NODE_NAME != %s", nodename);
EXEC SQL PREPARE s_statement FROM :stmt;
EXEC SQL DECLARE full_dyn_node CURSOR FOR s_statement;
Regards, Lee.
From | Date | Subject | |
---|---|---|---|
Next Message | Verger Nicolas | 2002-11-13 10:40:26 | RE : RE : Stability problems |
Previous Message | Tommi Maekitalo | 2002-11-13 08:28:38 | Re: performance regression, 7.2.3 -> 7.3b5 w/ VIEW |