pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Function compile error
4+ messages / 3 participants
[nested] [flat]

* Function compile error
@ 2011-02-16 12:35  Sivannarayanreddy <sivannarayanreddy@subexworld.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Sivannarayanreddy @ 2011-02-16 12:35 UTC (permalink / raw)
  To: pgsql-sql

Hello,
I am trying to create the function as below but it is throwing error 
'ERROR:  syntax error at or near "DECLARE"', Could some one help me please

CREATE FUNCTION check_password(databasename text, tablename text, 
indexname text)RETURNS VOID AS
DECLARE v_count INTEGER;
BEGIN
   select  count(1) into v_count  from  pg_index inx where  
inx.indexrelid in
  (select oid from pg_class where relname=$3 and relowner in
  (select oid from pg_authid where rolname=$1))
  and inx.indrelid in
  (select oid from pg_class where relname=$2 and relowner in
  (select oid from pg_authid where rolname=$1));
  if v_count = 0 then
execute immediate 'create unique index $3 on $2 (acn_id)';
end if;
END;

*Sivannarayanareddy Nusum****| **System Analyst(Moneta GDO)*

Subex Limited, Adarsh Tech Park, Outer Ring Road, Devarabisannalli, 
Bangalore -- 560037, India.
*Phone:*+91 80 6696 3371; *Mobile:*+91 9902065831*Fax:*+91 80 6696 3333;

*Email:*sivannarayanreddy@subexworld.com 
<mailto:email.id@subexworld.com>; *URL:*www.subexworld.com 
<http://www.subexworld.com/;

/Disclaimer: This e-mail is bound by the terms and conditions described 
at //http://www.subexworld.com/mail-disclaimer.html/

Attachments:

  [image/gif] graphics1 (5.5K, ../../4D5BC495.5000605@subexworld.com/3-graphics1)
  download | view image

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

* Re: Function compile error
@ 2011-02-16 12:49  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Sivannarayanreddy <sivannarayanreddy@subexworld.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Pavel Stehule @ 2011-02-16 12:49 UTC (permalink / raw)
  To: sivannarayanreddy@subexworld.com; +Cc: pgsql-sql

Hello

please, look to page
http://www.postgresql.org/docs/9.0/interactive/plpgsql-porting.html

It can be faster, if you try to read PL/pgSQL documentation first. PL/pgSQL
is near PL/SQL, but it is a different language and environment still.

http://www.postgresql.org/docs/9.0/interactive/plpgsql.html

Regards

Pavel Stehule


2011/2/16 Sivannarayanreddy <sivannarayanreddy@subexworld.com>

>  Hello,
> I am trying to create the function as below but it is throwing error
> 'ERROR:  syntax error at or near "DECLARE"', Could some one help me please
>
> CREATE FUNCTION check_password(databasename text, tablename text, indexname
> text)RETURNS VOID AS
> DECLARE v_count INTEGER;
> BEGIN
>   select  count(1) into v_count  from  pg_index inx where  inx.indexrelid
> in
>  (select oid from pg_class where relname=$3 and relowner in
>  (select oid from pg_authid where rolname=$1))
>  and inx.indrelid in
>  (select oid from pg_class where relname=$2 and relowner in
>  (select oid from pg_authid where rolname=$1));
>  if v_count = 0 then
> execute immediate 'create unique index $3 on $2 (acn_id)';
> end if;
> END;
>
> *Sivannarayanareddy Nusum** **| **System Analyst(Moneta GDO)*
>
> Subex Limited, Adarsh Tech Park, Outer Ring Road, Devarabisannalli,
> Bangalore – 560037, India.
> *Phone:* +91 80 6696 3371; *Mobile:* +91 9902065831  *Fax:* +91 80 6696
> 3333;
>
> *Email:*  sivannarayanreddy@subexworld.com <email.id@subexworld.com>; *
> URL:*  www.subexworld.com
>
>
>
> *Disclaimer: This e-mail is bound by the terms and conditions described at
> **http://www.subexworld.com/mail-disclaimer.html*<http://www.subexworld.com/mail-disclaimer.html;
>

Attachments:

  [image/gif] graphics1 (5.5K, ../../AANLkTi=vwg+0WYe5SZ5_4ZJj2fgnrk01WzENs0BW4ceF@mail.gmail.com/3-graphics1)
  download | view image

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

* Re: Function compile error
@ 2011-02-16 16:24  Igor Neyman <ineyman@perceptron.com>
  parent: Sivannarayanreddy <sivannarayanreddy@subexworld.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Igor Neyman @ 2011-02-16 16:24 UTC (permalink / raw)
  To: sivannarayanreddy@subexworld.com; pgsql-sql

 

> -----Original Message-----
> From: Sivannarayanreddy [mailto:sivannarayanreddy@subexworld.com] 
> Sent: Wednesday, February 16, 2011 7:36 AM
> To: pgsql-sql@postgresql.org
> Subject: Function compile error
> 
> Hello,
> I am trying to create the function as below but it is 
> throwing error 'ERROR:  syntax error at or near "DECLARE"', 
> Could some one help me please
> 
> CREATE FUNCTION check_password(databasename text, tablename 
> text, indexname text)RETURNS VOID AS 
> DECLARE v_count INTEGER;
> BEGIN
>   select  count(1) into v_count  from  pg_index inx where  
> inx.indexrelid in
>  (select oid from pg_class where relname=$3 and relowner in 
>  (select oid from pg_authid where rolname=$1)) 
>  and inx.indrelid in 
>  (select oid from pg_class where relname=$2 and relowner in 
>  (select oid from pg_authid where rolname=$1)); 
>  if v_count = 0 then  
> execute immediate 'create unique index $3 on $2 (acn_id)';  
> end if; 
> END;
> 
> 
> 
> Sivannarayanareddy Nusum | System Analyst(Moneta GDO) 
> 
> 
> 
> Subex Limited, Adarsh Tech Park, Outer Ring Road, 
> Devarabisannalli, Bangalore - 560037, India.
> Phone: +91 80 6696 3371; Mobile: +91 9902065831  Fax: +91 80 
> 6696 3333; 
> 
> Email:  sivannarayanreddy@subexworld.com 
> <mailto:email.id@subexworld.com> ; URL:  www.subexworld.com 
> <http://www.subexworld.com/;  
> 
>  
> 
> Disclaimer: This e-mail is bound by the terms and conditions 
> described at http://www.subexworld.com/mail-disclaimer.html 
> <http://www.subexworld.com/mail-disclaimer.html;  
> 



CREATE FUNCTION check_password(databasename text, tablename text,
indexname text)
RETURNS VOID AS $body$
DECLARE v_count INTEGER;
BEGIN
  select  count(1) into v_count  from  pg_index inx where
inx.indexrelid in
 (select oid from pg_class where relname=$3 and relowner in 
 (select oid from pg_authid where rolname=$1)) 
 and inx.indrelid in 
 (select oid from pg_class where relname=$2 and relowner in 
 (select oid from pg_authid where rolname=$1)); 
 if v_count = 0 then  
execute immediate 'create unique index $3 on $2 (acn_id)';  
end if; 
END;
$body$LANGUAGE PLPGSQL;

Regards,
Igor Neyman



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

* Re: Function compile error
@ 2011-02-18 05:44  Sivannarayanreddy <sivannarayanreddy@subexworld.com>
  parent: Igor Neyman <ineyman@perceptron.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Sivannarayanreddy @ 2011-02-18 05:44 UTC (permalink / raw)
  To: Igor Neyman <ineyman@perceptron.com>; +Cc: pgsql-sql

Thanks Igor Nayman!!! The function worked for me

*Sivannarayanareddy Nusum****| **System Analyst(Moneta GDO)*

Subex Limited, Adarsh Tech Park, Outer Ring Road, Devarabisannalli, 
Bangalore -- 560037, India.
*Phone:*+91 80 6696 3371; *Mobile:*+91 9902065831*Fax:*+91 80 6696 3333;

*Email:*sivannarayanreddy@subexworld.com 
<mailto:email.id@subexworld.com>; *URL:*www.subexworld.com 
<http://www.subexworld.com/;

/Disclaimer: This e-mail is bound by the terms and conditions described 
at //http://www.subexworld.com/mail-disclaimer.html/


On 2/16/2011 9:54 PM, Igor Neyman wrote:
>
>
>> -----Original Message-----
>> From: Sivannarayanreddy [mailto:sivannarayanreddy@subexworld.com]
>> Sent: Wednesday, February 16, 2011 7:36 AM
>> To: pgsql-sql@postgresql.org
>> Subject: Function compile error
>>
>> Hello,
>> I am trying to create the function as below but it is
>> throwing error 'ERROR:  syntax error at or near "DECLARE"',
>> Could some one help me please
>>
>> CREATE FUNCTION check_password(databasename text, tablename
>> text, indexname text)RETURNS VOID AS
>> DECLARE v_count INTEGER;
>> BEGIN
>>    select  count(1) into v_count  from  pg_index inx where
>> inx.indexrelid in
>>   (select oid from pg_class where relname=$3 and relowner in
>>   (select oid from pg_authid where rolname=$1))
>>   and inx.indrelid in
>>   (select oid from pg_class where relname=$2 and relowner in
>>   (select oid from pg_authid where rolname=$1));
>>   if v_count = 0 then
>> execute immediate 'create unique index $3 on $2 (acn_id)';
>> end if;
>> END;
>>
>>
>>
>> Sivannarayanareddy Nusum | System Analyst(Moneta GDO)
>>
>>
>>
>> Subex Limited, Adarsh Tech Park, Outer Ring Road,
>> Devarabisannalli, Bangalore - 560037, India.
>> Phone: +91 80 6696 3371; Mobile: +91 9902065831  Fax: +91 80
>> 6696 3333;
>>
>> Email:  sivannarayanreddy@subexworld.com
>> <mailto:email.id@subexworld.com>  ; URL:  www.subexworld.com
>> <http://www.subexworld.com/;
>>
>>
>>
>> Disclaimer: This e-mail is bound by the terms and conditions
>> described at http://www.subexworld.com/mail-disclaimer.html
>> <http://www.subexworld.com/mail-disclaimer.html;
>>
>
>
> CREATE FUNCTION check_password(databasename text, tablename text,
> indexname text)
> RETURNS VOID AS $body$
> DECLARE v_count INTEGER;
> BEGIN
>    select  count(1) into v_count  from  pg_index inx where
> inx.indexrelid in
>   (select oid from pg_class where relname=$3 and relowner in
>   (select oid from pg_authid where rolname=$1))
>   and inx.indrelid in
>   (select oid from pg_class where relname=$2 and relowner in
>   (select oid from pg_authid where rolname=$1));
>   if v_count = 0 then
> execute immediate 'create unique index $3 on $2 (acn_id)';
> end if;
> END;
> $body$LANGUAGE PLPGSQL;
>
> Regards,
> Igor Neyman
> .
>

Attachments:

  [image/gif] graphics1 (5.5K, ../../4D5E0755.2080304@subexworld.com/3-graphics1)
  download | view image

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


end of thread, other threads:[~2011-02-18 05:44 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 12:35 Function compile error Sivannarayanreddy <sivannarayanreddy@subexworld.com>
2011-02-16 12:49 ` Pavel Stehule <pavel.stehule@gmail.com>
2011-02-16 16:24 ` Igor Neyman <ineyman@perceptron.com>
2011-02-18 05:44   ` Sivannarayanreddy <sivannarayanreddy@subexworld.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