473,503 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to make this function work....

27 New Member
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
5 3159
rski
700 Recognized Expert Contributor
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
ravysters
27 New Member
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
rski
700 Recognized Expert Contributor
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
ravysters
27 New Member
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
rski
700 Recognized Expert Contributor
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

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

Similar topics

4
5719
by: Mike Kamermans | last post by:
I have an XML document that, in order to save b/w for both server and users, uses a few emtpy tags a la "<add/>" and "<edit/>" in the source, which get javascript replaced once the document is...
1
4299
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
7
6239
by: Kapt. Boogschutter | last post by:
I'm trying to create a function that has at least 1 Argument but can also contain any number of Arguments (except 0 because my function would have no meaning for 0 argument). The arguments...
0
1621
by: Chris F Clark | last post by:
In our C++ project we have some internal bug reporting macros that we use to get useful information when the program does something unexpected. Essentially at the point of the error, we invoke an...
10
6976
by: Nicolas Fleury | last post by:
Hi everyone, I was wondering if it would make sense to make staticmethod objects callable, so that the following code would work: class A: @staticmethod def foo(): pass bar = foo() I...
6
4841
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
28
2907
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions!...
7
2675
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
4
2756
by: Kyote | last post by:
I'm trying to persist a list of filenames. I've made a custom collection and a FileName class: 'Class to hold file name information Public Class FileNames Public fullName As String Public...
19
2411
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.