Re: [pgsql-fr-generale] Problème avec une fonction

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Jean-Michel Caricand <jean-michel(dot)caricand(at)laposte(dot)net>
Cc: pgsql-fr-generale <pgsql-fr-generale(at)postgresql(dot)org>
Subject: Re: [pgsql-fr-generale] Problème avec une fonction
Date: 2014-09-06 06:27:10
Message-ID: CAECtzeU+qF=TvsCnCQvcSwnOOMJCcwHj2A1uqgXvwnjmk+PPNw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Le 6 sept. 2014 08:22, "Jean-Michel Caricand" <
jean-michel(dot)caricand(at)laposte(dot)net> a écrit :
>
> Bonjour,
>
> Je sais que cette liste n'est peut-être pas la bonne car le problème est
certainement lié à Perl... mais j'essaie quand même ;-)
>
> J'ai un petit souci avec une fonction en utilisant Perl. Voici les
informations pour PostgreSQL :
>
> CREATE TABLE personne (
> id bigserial NOT NULL PRIMARY KEY,
> nom varchar(64) NOT NULL,
> adresse_id bigint
> );
>
> CREATE TABLE personne_physique (
> id bigint NOT NULL PRIMARY KEY REFERENCES personne(id),
> civilite_id bigint,
> date_naissance date,
> lieu_naissance varchar(32)
> );
>
> CREATE OR REPLACE FUNCTION creer_personne_physique_avec_id(
> p_id bigint,
> p_civilite_id bigint,
> p_nom varchar,
> p_date_naissance date,
> p_lieu_naissance varchar)
>
> RETURNS type_personne_physique AS $$
>
> DECLARE
> v_result type_personne_physique;
>
> BEGIN
> INSERT INTO personne (id, nom) VALUES(p_id, p_nom);
> INSERT INTO personne_physique (id, civilite_id, date_naissance,
lieu_naissance)
> VALUES (p_id, p_civilite_id, p_date_naissance, p_lieu_naissance);
>
> -- affecte les valeurs à la variable de retour.
> v_result.id = p_id;
> v_result.civilite_id = p_civilite_id;
> v_result.nom = p_nom;
> v_result.date_naissance = p_date_naissance;
> v_result.lieu_naissance = p_lieu_naissance;
>
> return v_result;
> END
> $$ language plpgsql;
>
> Lorsque j'execute l'instruction suivante depuis pgadmin , tout fonctionne
:
>
> SELECT * FROM creer_personne_physique_avec_id(12, 1, 'Nom, '2010-10-2',
'Ville');
>
> Par contre, depuis Perl, l'instruction suivante échoue avec le message :
>
> $sth_crm = $dbh_crm->prepare("SELECT * FROM
creer_personne_physique_avec_id(12, 1, 'Nom', '2010-10-2', 'Ville')");
> $sth_crm->execute;
>
> DBD::Pg::st execute failed: ERROR: function
creer_personne_physique_avec_id(integer, integer, unknown, unknown,
unknown) does not exist
> LINE 1: SELECT * FROM creer_personne_physique_avec_id(12, 1, 'Nom', ...
> ^
> HINT: No function matches the given name and argument types. You might
need to add explicit type casts. at migration.pl line 53.
> DBD::Pg::st execute failed: ERROR: function
creer_personne_physique_avec_id(integer, integer, unknown, unknown,
unknown) does not exist
> LINE 1: SELECT * FROM creer_personne_physique_avec_id(12, 1, 'Nom', ...
^
> HINT: No function matches the given name and argument types. You might
need to add explicit type casts. at migration.pl line 53.
>
> Vous avez une idée ?
>

Soit vous ne vous connectez pas à la bonne base, soit vous ne vous
connectez pas avec le même utilisateur, ce qui vous donne un schéma par
défaut différent.

In response to

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Virginie Jourdan 2014-09-09 12:15:01 Découvrez Open PostgreSQL Monitoring (OPM)
Previous Message Cédric Villemain 2014-09-03 18:54:11 Re: [FDW] Table vide avec odbc_fdw