Lists: | pgsql-es-ayuda |
---|
From: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
---|---|
To: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Ayuda con Funcion y C++ |
Date: | 2006-11-16 22:26:36 |
Message-ID: | ceb7e03d0611161426mdc3b138yff2b6b8a1aadbbd4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
Buenas a todos, soy nuevo en esta lista y estoy buscando ayuda, resulta
que cree una funcion que retorna un valor void, cuando la ejecuto en el
pgAdminIII en el editor de SQL me manda un error que dice:
ERROR: SELECT query has no destination for result data
HINT: If you want to discard the results, use PERFORM instead.
CONTEXT: PL/pgSQL function "funciona" line 2 at SQL statement
sentencia SQL: ëSELECT funciona( $1 , $2 , $3 , $4 )û
PL/pgSQL function "modifica_pto_dig" line 6 at perform
Este mismo error me da si lo hago dentro del codigo de C++ utilizando las
librerias libpqxx.
Como puedo hacer para que no me de este error....
Gracias.
From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-17 03:12:04 |
Message-ID: | c2d9e70e0611161912t4648d7b9sb96c24808d0f4b8@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
On 11/16/06, Daniel <daniel(dot)delaluz(at)gmail(dot)com> wrote:
> Buenas a todos, soy nuevo en esta lista y estoy buscando ayuda, resulta
> que cree una funcion que retorna un valor void, cuando la ejecuto en el
> pgAdminIII en el editor de SQL me manda un error que dice:
>
retorna un valor void? podemos ver la definicion de la funcion?
> ERROR: SELECT query has no destination for result data
> HINT: If you want to discard the results, use PERFORM instead.
> CONTEXT: PL/pgSQL function "funciona" line 2 at SQL statement
> sentencia SQL: «SELECT funciona( $1 , $2 , $3 , $4 )»
> PL/pgSQL function "modifica_pto_dig" line 6 at perform
>
> Este mismo error me da si lo hago dentro del codigo de C++ utilizando las
> librerias libpqxx.
>
> Como puedo hacer para que no me de este error....
>
trata con:
PERFORM funciona(parametro1, parametro2, parametro3, parametro4 )
--
Atentamente,
Jaime Casanova
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook
From: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
---|---|
To: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-17 14:49:20 |
Message-ID: | ceb7e03d0611170649vcd7c554id0c15a676fdeb9d3@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
La definicion es:
CREATE OR REPLACE FUNCTION funciona(int4, int4, int4, int4, int4) RETURNS
void AS..
El problema es que ya use el comando PERFORM
funciona(parametros....,..,..,..);
me sigue mandando el error, esto tambien lo pobre en psql y me da el mismo
error como si no existiera el comando me da el error
ERROR: error de sintaxis en o cerca de ëPERFORMû at character 1
todo esto es en posgresql 8.1.
Gracias.
On 11/16/06, Jaime Casanova <systemguards(at)gmail(dot)com> wrote:
>
> On 11/16/06, Daniel <daniel(dot)delaluz(at)gmail(dot)com> wrote:
> > Buenas a todos, soy nuevo en esta lista y estoy buscando ayuda,
> resulta
> > que cree una funcion que retorna un valor void, cuando la ejecuto en el
> > pgAdminIII en el editor de SQL me manda un error que dice:
> >
>
> retorna un valor void? podemos ver la definicion de la funcion?
>
> > ERROR: SELECT query has no destination for result data
> > HINT: If you want to discard the results, use PERFORM instead.
> > CONTEXT: PL/pgSQL function "funciona" line 2 at SQL statement
> > sentencia SQL: «SELECT funciona( $1 , $2 , $3 , $4 )»
> > PL/pgSQL function "modifica_pto_dig" line 6 at perform
> >
> > Este mismo error me da si lo hago dentro del codigo de C++ utilizando
> las
> > librerias libpqxx.
> >
> > Como puedo hacer para que no me de este error....
> >
>
> trata con:
> PERFORM funciona(parametro1, parametro2, parametro3, parametro4 )
>
> --
> Atentamente,
> Jaime Casanova
>
> "Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs and the universe trying
> to produce bigger and better idiots.
> So far, the universe is winning."
> Richard Cook
>
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
Cc: | Jaime Casanova <systemguards(at)gmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-17 18:35:28 |
Message-ID: | 20061117183528.GM32174@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
Daniel escribió:
> La definicion es:
> CREATE OR REPLACE FUNCTION funciona(int4, int4, int4, int4, int4) RETURNS
> void AS..
>
> El problema es que ya use el comando PERFORM
> funciona(parametros....,..,..,..);
> me sigue mandando el error, esto tambien lo pobre en psql y me da el mismo
> error como si no existiera el comando me da el error
>
> ERROR: error de sintaxis en o cerca de ëPERFORMû at character 1
Que tal si nos muestras la funcion completa y como la estas invocando,
en vez de tanto mover las manos en el aire?
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
From: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
---|---|
To: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-17 19:20:30 |
Message-ID: | ceb7e03d0611171120q141b5e48w6741c2f152a63b30@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
CREATE OR REPLACE FUNCTION inserta_valor(int4, int4, int4, int4)
RETURNS void AS
$BODY$
BEGIN
select * from valores where canal = $1;
if not found then
if $4 ISNULL then
insert into valores values($1,$2,$3);
else
insert into valores values($1,$2,$3,$4);
end if;
end if;
END;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION inserta_valor_dig(int4, int4, int4, int4) OWNER TO postgres;
GRANT EXECUTE ON FUNCTION inserta_valor(int4, int4, int4, int4) TO public;
GRANT EXECUTE ON FUNCTION inserta_valor(int4, int4, int4, int4) TO postgres;
y desde C++ llamo la funcion asi.
......
connection Con("dbname=scada ");
result R( T.exec("PERFORM inserta_valor(1,47,0,0,0)") );
.....
hago los mismo de psql y tambien me da el error.....
On 11/17/06, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
>
> Daniel escribió:
> > La definicion es:
> > CREATE OR REPLACE FUNCTION funciona(int4, int4, int4, int4, int4)
> RETURNS
> > void AS..
> >
> > El problema es que ya use el comando PERFORM
> > funciona(parametros....,..,..,..);
> > me sigue mandando el error, esto tambien lo pobre en psql y me da el
> mismo
> > error como si no existiera el comando me da el error
> >
> > ERROR: error de sintaxis en o cerca de «PERFORM» at character 1
>
> Que tal si nos muestras la funcion completa y como la estas invocando,
> en vez de tanto mover las manos en el aire?
>
> --
> Alvaro Herrera
> http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-17 19:41:41 |
Message-ID: | 20061117194141.GQ32174@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
Daniel escribió:
> CREATE OR REPLACE FUNCTION inserta_valor(int4, int4, int4, int4)
> RETURNS void AS
> $BODY$
> BEGIN
> select * from valores where canal = $1;
> if not found then
> if $4 ISNULL then
> insert into valores values($1,$2,$3);
> else
> insert into valores values($1,$2,$3,$4);
> end if;
> end if;
> END;$BODY$
> LANGUAGE 'plpgsql' VOLATILE;
> ALTER FUNCTION inserta_valor_dig(int4, int4, int4, int4) OWNER TO postgres;
> GRANT EXECUTE ON FUNCTION inserta_valor(int4, int4, int4, int4) TO public;
> GRANT EXECUTE ON FUNCTION inserta_valor(int4, int4, int4, int4) TO postgres;
>
> y desde C++ llamo la funcion asi.
> ......
> connection Con("dbname=scada ");
> result R( T.exec("PERFORM inserta_valor(1,47,0,0,0)") );
Bueno, el SELECT que tenias que cambiar por PERFORM no era el que
invocaba a inserta_valor(), sino el que examina la tabla valores. Es
decir la segunda linea de la funcion:
perform * from valores where canal = $1;
PERFORM es una sentencia del lenguaje PL/pgSQL, no SQL. Es bueno
entender la diferencia.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | Daniel <daniel(dot)delaluz(at)gmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: Ayuda con Funcion y C++ |
Date: | 2006-11-18 05:25:10 |
Message-ID: | c2d9e70e0611172125r1faf56f9q5e00d2d706bd8121@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-es-ayuda |
On 11/17/06, Daniel <daniel(dot)delaluz(at)gmail(dot)com> wrote:
>
> CREATE OR REPLACE FUNCTION inserta_valor(int4, int4, int4, int4)
> RETURNS void AS
> $BODY$
> BEGIN
> select * from valores where canal = $1;
> if not found then
> if $4 ISNULL then
> insert into valores values($1,$2,$3);
> else
> insert into valores values($1,$2,$3,$4);
> end if;
otro error aparte del que ya te menciono Alvaro...
si la tabla tiene 4 columnas debes darle un valor a todas, sino deseas
hacerlo debes especificar a que columnas estas asignando valores, algo
asi:
if $4 ISNULL then
insert into valores(campo1, campo2, campo3) values($1,$2,$3);
else
insert into valores values($1,$2,$3,$4);
end if;
aunque no veo para que tanto lio si igual estarias grabando NULL en la
4ta columna
--
Atentamente,
Jaime Casanova
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook