Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old June 9th, 2008, 02:33 PM
Newbie
 
Join Date: May 2008
Posts: 26
Default how to make this function work....

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';
Reply
  #2  
Old June 9th, 2008, 03:40 PM
Moderator
 
Join Date: Dec 2006
Posts: 250
Default

Quote:
Originally Posted by ravysters
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?
Reply
  #3  
Old June 10th, 2008, 07:08 AM
Newbie
 
Join Date: May 2008
Posts: 26
Default

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..
Reply
  #4  
Old June 10th, 2008, 07:39 AM
Moderator
 
Join Date: Dec 2006
Posts: 250
Default

Quote:
Originally Posted by ravysters
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.
Reply
  #5  
Old June 10th, 2008, 07:57 AM
Newbie
 
Join Date: May 2008
Posts: 26
Default

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..
Reply
  #6  
Old June 10th, 2008, 09:31 AM
Moderator
 
Join Date: Dec 2006
Posts: 250
Default

Quote:
Originally Posted by ravysters
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?
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles