0

Hello i have this error

Error: psql:/Samsung/VisualCodeStudioWorkspace/1524335164735.pgsql:95: ERROR: function altaplayer(character varying, integer, integer, character varying, character varying) does not exist LINE 1: select altaPlayer( varchar 'Drazen Petrovic',52,80, varchar ... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. psql end.

I cant solve for more than two days... ive tried everyhing...

CREATE TYPE player AS (
    nom varchar(20),
    alçada integer,
    pes integer,
    posicio varchar(20),
    equip varchar(20)
);

CREATE TABLE player_list of player(
    primary key(nom)
);

CREATE TABLE team (
    jugador player
);

INSERT INTO team VALUES(row('Pepelu',190,90,'Base','Barça'));
INSERT INTO player_list VALUES('Asterix',50,30,'Base','Barça');
INSERT INTO player_list VALUES('Pepelui',100,90,'Alero','Barça');
INSERT INTO player_list VALUES('Manolo',10,50,'Base','Barça');
INSERT INTO player_list VALUES('Juan',50,30,'Base','Barça');
INSERT INTO player_list VALUES('Fernando Martin',50,30,'Pivot','Barça');
INSERT INTO player_list VALUES('Audie Norris',50,30,'Pivot','Barça');


create or replace function altaPlayer ( varchar(20),int,int,varchar(20),varchar(20)) as $$
    BEGIN   
        INSERT INTO player_list VALUES($1,$2,$3,$4,$5);
    END
$$ LANGUAGE plpgsql;



select altaPlayer('Drazen Petrovic',52,80,'Escolta','Cibona');

2 Answers 2

2

The function result type must be specified:

create or replace function altaplayer ( varchar(20),int,int,varchar(20),varchar(20)) 
returns void -- !!!
as $$
    begin   
        insert into player_list values($1,$2,$3,$4,$5);
    end
$$ language plpgsql;
Sign up to request clarification or add additional context in comments.

Comments

1

You missed to put the keyword RETURNS.

create or replace function altaPlayer
    (varchar(20),int,int,varchar(20),varchar(20)) 
        RETURNS void as $$

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.