By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,965 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,965 IT Pros & Developers. It's quick & easy.

how to make this function work....

P: 27
hi.. i have this procedure.. but its not working.. its showing some syntax errors.. how can i make this work.. please help



create or replace function test(text)
returns integer
as
$$
Declare
x varchar;
y varchar;
z varchar;
Begin
z := select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);
execute z into y;
return y;
end;
$$
language 'plpgsql';
Jun 9 '08 #1
Share this Question
Share on Google+
5 Replies


Expert 100+
P: 700
hi.. i have this procedure.. but its not working.. its showing some syntax errors.. how can i make this work.. please help



create or replace function test(text)
returns integer
as
$$
Declare
x varchar;
y varchar;
z varchar;
Begin
z := select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);
execute z into y;
return y;
end;
$$
language 'plpgsql';
Maybe you'll show that errors. By the way if z is varchar shouldn't you put
Expand|Select|Wrap|Line Numbers
  1. select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);
  2.  
between apos.
Expand|Select|Wrap|Line Numbers
  1. z:='select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);'
  2.  
and why do you write ''||$1||'' are you using there quotation or is it double apos?
Jun 9 '08 #2

P: 27
i am sorry.. i accidentally reported instead of replying...

thanks for the reply...the function is working...

but i have a new problem.. type casting..how can i do that in postgres...
i went through the manual... but wasn't that helpful...

consider the following..

declare x varchar;
execute 'select xpath()' into x;
return x;

how can i convert x from varchar to integer...
help me..
Jun 10 '08 #3

Expert 100+
P: 700
i am sorry.. i accidentally reported instead of replying...

thanks for the reply...the function is working...

but i have a new problem.. type casting..how can i do that in postgres...
i went through the manual... but wasn't that helpful...

consider the following..

declare x varchar;
execute 'select xpath()' into x;
return x;

how can i convert x from varchar to integer...
help me..
doesn't simple
Expand|Select|Wrap|Line Numbers
  1. return x::integer
  2.  
work? if not maybe you should write your own cast function.
Jun 10 '08 #4

P: 27
hi.. even after doing that i am gettting this error..

invalid input syntax for integer: ...


i even used select cast( x as integer)..


dint work either man..
Jun 10 '08 #5

Expert 100+
P: 700
hi.. even after doing that i am gettting this error..

invalid input syntax for integer: ...


i even used select cast( x as integer)..


dint work either man..
What does
Expand|Select|Wrap|Line Numbers
  1. execute 'select xpath()' into x;
  2.  
produce?
Jun 10 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.