how to perform minus (-) operation in a dynamic query - Mailing list pgsql-sql

From Anoop G
Subject how to perform minus (-) operation in a dynamic query
Date
Msg-id 1a027d210807132251l3cc6780eq8edde7c70469b1f5@mail.gmail.com
Whole thread Raw
Responses Re: how to perform minus (-) operation in a dynamic query
Re: how to perform minus (-) operation in a dynamic query
Re: how to perform minus (-) operation in a dynamic query
List pgsql-sql

Hai all,

I am new to plpgsql ,I have a  table  structure:

 Column |       Type       | Modifiers
--------+------------------+-----------
 mf     | double precision |
 sf     | double precision |
 comm   | integer          |

I create a  the following funtion

create or replace function test_perc() returns setof record as $body$

declare

vchr_query VARCHAR(100);

r record;

begin

vchr_query:= 'SELECT mf,sf,(mf – mf * comm /100) – (sf – sf * comm/100) as flt_claim';

FOR r in EXECUTE vchr_query LOOP

RETURN NEXT r;

END LOOP;

RETURN;

end$body$
language 'plpgsql'


function created

but when I am traing to run this function I got the following error

ERROR:  syntax error at or near "–" at character 18
QUERY:  SELECT mf,sf,(mf – mf * comm /100) – (sf – sf * comm/100) as flt_claim
CONTEXT:  PL/pgSQL function "test_perc" line 7 at for over execute statement
LINE 1: SELECT mf,sf,(mf – mf * comm /100) – (sf – sf * comm/100) as...

How I can solve this ,pls help me


thanks in advance:
Anoop



pgsql-sql by date:

Previous
From: Milan Oparnica
Date:
Subject: Re: PERSISTANT PREPARE (another point of view)
Next
From: "A. Kretschmer"
Date:
Subject: Re: how to perform minus (-) operation in a dynamic query