sintax???

Started by Alfonso Penicheabout 25 years ago7 messagesgeneral
Jump to latest
#1Alfonso Peniche
alfonso@iteso.mx

I have the following:

CREATE FUNCTION RegistrarConexion(char(8),char(16),char(20))
RETURNS integer
AS '
DECLARE ret integer;

BEGIN
INSERT INTO BitacoraConexion(username, IPmaquina,
nombremaquina, conexion)
VALUES ($1, $2, $3, CURRENT_TIMESTAMP);

SELECT INTO ret
currval('bitacoraconex_idbitacoracon_seq');

RETURN ret;
END;'
LANGUAGE 'plpgsql';

and if I execute this file I get the following error:

psql:SPRegConex.sql:20: ERROR: parser: parse error at or near
"bitacoraconex_idbitacoracon_seq"

I asume it's due to a sintax error having to do with "currval", but I
can't find what the proper sintax would be for 'plpgsql' for getting the
last sequence value assigned (I even tried

select currval('bitacoraconex_idbitacoracon_seq') as ret

with equal result).

Can someone help me out here??????

Thanx

P.S. Is there a manual for plpgsql sintax, instructions, functions....
somewhere?

#2Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Alfonso Peniche (#1)
Re: sintax???

On Thu, 1 Feb 2001, Alfonso Peniche wrote:

I have the following:

CREATE FUNCTION RegistrarConexion(char(8),char(16),char(20))
RETURNS integer
AS '
DECLARE ret integer;

BEGIN
INSERT INTO BitacoraConexion(username, IPmaquina,
nombremaquina, conexion)
VALUES ($1, $2, $3, CURRENT_TIMESTAMP);

SELECT INTO ret
currval('bitacoraconex_idbitacoracon_seq');

RETURN ret;
END;'
LANGUAGE 'plpgsql';

and if I execute this file I get the following error:

psql:SPRegConex.sql:20: ERROR: parser: parse error at or near
"bitacoraconex_idbitacoracon_seq"

I asume it's due to a sintax error having to do with "currval", but I
can't find what the proper sintax would be for 'plpgsql' for getting the
last sequence value assigned (I even tried

I believe the problem is that you need to escape the single quotes,
otherwise it thinks you're ending the function text. Try
currval(''bitacoraconex_idbitacoracon_seq'');

#3Alfonso Peniche
alfonso@iteso.mx
In reply to: Stephan Szabo (#2)
Re: sintax???

Thanks, I just figured that out. Now I have another problem:

If I run select registrarconexion('mine', '201.201.201.1',''MYCPU); I
get a message

NOTICE: plpgsql: ERROR during compile of registrarconexion near line 1
"RROR: parse error at or near "

Any ideas?

Thanx.

Stephan Szabo wrote:

Show quoted text

On Thu, 1 Feb 2001, Alfonso Peniche wrote:

I have the following:

CREATE FUNCTION RegistrarConexion(char(8),char(16),char(20))
RETURNS integer
AS '
DECLARE ret integer;

BEGIN
INSERT INTO BitacoraConexion(username, IPmaquina,
nombremaquina, conexion)
VALUES ($1, $2, $3, CURRENT_TIMESTAMP);

SELECT INTO ret
currval('bitacoraconex_idbitacoracon_seq');

RETURN ret;
END;'
LANGUAGE 'plpgsql';

and if I execute this file I get the following error:

psql:SPRegConex.sql:20: ERROR: parser: parse error at or near
"bitacoraconex_idbitacoracon_seq"

I asume it's due to a sintax error having to do with "currval", but I
can't find what the proper sintax would be for 'plpgsql' for getting the
last sequence value assigned (I even tried

I believe the problem is that you need to escape the single quotes,
otherwise it thinks you're ending the function text. Try
currval(''bitacoraconex_idbitacoracon_seq'');

#4Alfonso Peniche
alfonso@iteso.mx
In reply to: Stephan Szabo (#2)
Re: sintax???

Thanks, Now I have another problem:

If I run select registrarconexion('mine', '201.201.201.1','MYCPU');

I get a message

NOTICE: plpgsql: ERROR during compile of registrarconexion near line 1
"RROR: parse error at or near "

Any ideas?

Thanx.

Stephan Szabo wrote:

Show quoted text

On Thu, 1 Feb 2001, Alfonso Peniche wrote:

I have the following:

CREATE FUNCTION RegistrarConexion(char(8),char(16),char(20))
RETURNS integer
AS '
DECLARE ret integer;

BEGIN
INSERT INTO BitacoraConexion(username, IPmaquina,
nombremaquina, conexion)
VALUES ($1, $2, $3, CURRENT_TIMESTAMP);

SELECT INTO ret
currval('bitacoraconex_idbitacoracon_seq');

RETURN ret;
END;'
LANGUAGE 'plpgsql';

and if I execute this file I get the following error:

psql:SPRegConex.sql:20: ERROR: parser: parse error at or near
"bitacoraconex_idbitacoracon_seq"

I asume it's due to a sintax error having to do with "currval", but I
can't find what the proper sintax would be for 'plpgsql' for getting the
last sequence value assigned (I even tried

I believe the problem is that you need to escape the single quotes,
otherwise it thinks you're ending the function text. Try
currval(''bitacoraconex_idbitacoracon_seq'');

#5tony
tony@animaproductions.com
In reply to: Alfonso Peniche (#4)
Re: sintax???

Are jokes allowed on this forum?

No I was just wondering about taxes on sin... Syntax would maybe be more on
subject.

<serious mode on>

I am about to plunge into messing about with Macromedia Dreamweaver
Ultradev 4, Postresql, Lutris Enhydra and or Tomcat.

Someone wrote me with some advice but my mail server was eating mail and I
lost the message. Could we:

- whip up a howto
- get some recognition from folk at Macromedia by putting adequate
code/documentation on Dreamweaver Exchange.

I am willing to play the role of Candide (the newbie for those not brushed
up on french literature) and document my procedings.

Cheers

Tony Grant

--
I am in my office right now and your autoresponder message is currently
being
proccessed. In a short time 5,000 copies of the same should arrive in your
mailbox.

#6Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Alfonso Peniche (#4)
Re: Re: sintax???

It looks like you also may have some dos style end of lines in whatever
you entered in. Did you cut and paste or copy a file from a windows
box?

That's why the " is over the E in ERROR because it's seeing the
CR character.

On Fri, 2 Feb 2001, Alfonso Peniche wrote:

Show quoted text

Thanks, Now I have another problem:

If I run select registrarconexion('mine', '201.201.201.1','MYCPU');

I get a message

NOTICE: plpgsql: ERROR during compile of registrarconexion near line 1
"RROR: parse error at or near "

Any ideas?

Thanx.

Stephan Szabo wrote:

On Thu, 1 Feb 2001, Alfonso Peniche wrote:

I have the following:

CREATE FUNCTION RegistrarConexion(char(8),char(16),char(20))
RETURNS integer
AS '
DECLARE ret integer;

BEGIN
INSERT INTO BitacoraConexion(username, IPmaquina,
nombremaquina, conexion)
VALUES ($1, $2, $3, CURRENT_TIMESTAMP);

SELECT INTO ret
currval('bitacoraconex_idbitacoracon_seq');

RETURN ret;
END;'
LANGUAGE 'plpgsql';

and if I execute this file I get the following error:

psql:SPRegConex.sql:20: ERROR: parser: parse error at or near
"bitacoraconex_idbitacoracon_seq"

I asume it's due to a sintax error having to do with "currval", but I
can't find what the proper sintax would be for 'plpgsql' for getting the
last sequence value assigned (I even tried

I believe the problem is that you need to escape the single quotes,
otherwise it thinks you're ending the function text. Try
currval(''bitacoraconex_idbitacoracon_seq'');

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alfonso Peniche (#3)
Re: Re: sintax???

Alfonso Peniche <alfonso@iteso.mx> writes:

NOTICE: plpgsql: ERROR during compile of registrarconexion near line 1
"RROR: parse error at or near "

The overwriting of the initial "E" suggests that the thing is
trying to complain about a carriage return (\r). Probably you
saved your script from an editor that stores newlines in DOS
style (\r\n) rather than Unix style (\n). plpgsql doesn't think
that \r is whitespace. That's been changed for 7.1, but in the
meantime you need a less Microsofty editor.

regards, tom lane