 | 
June 9th, 2008, 02:33 PM
| | Newbie | | Join Date: May 2008
Posts: 26
| | 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';
| 
June 9th, 2008, 03:40 PM
| | Moderator | | Join Date: Dec 2006
Posts: 250
| | 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 -
select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);
-
between apos. -
z:='select xpath('/F/@CT:I',''||$1||'',ARRAY[ARRAY['CT','urn:PointCross-ChangeTracker']]);'
-
and why do you write ''||$1||'' are you using there quotation or is it double apos?
| 
June 10th, 2008, 07:08 AM
| | Newbie | | Join Date: May 2008
Posts: 26
| |
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..
| 
June 10th, 2008, 07:39 AM
| | Moderator | | Join Date: Dec 2006
Posts: 250
| | 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
work? if not maybe you should write your own cast function.
| 
June 10th, 2008, 07:57 AM
| | Newbie | | Join Date: May 2008
Posts: 26
| |
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..
| 
June 10th, 2008, 09:31 AM
| | Moderator | | Join Date: Dec 2006
Posts: 250
| | 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 -
execute 'select xpath()' into x;
-
produce?
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | 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.
|