Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    Cool Unanswered: Insert into the_table select from an other table

    First :------------------------
    I want just to create a function that gets a primary key of a table then synchonise 4 rowns into an other one, in the psql prompt I was able to do it , but when trying to make a function it returns errors :

    CREATE FUNCTION sync_mens(bigint) RETURNS bool AS 'Insert into tmensualite (id_pret,annee,montant) select id_pret,annee,montpret from tpret where id_pret=$1'
    LANGUAGE 'SQL';

    ERROR: return type mismatch in function declared to return boolean
    DETAIL: Function's final statement must be a SELECT.

    First:---------------------------
    The debt does not only create one record , but depends on the number of monts 'X', so ...
    Attached Thumbnails Attached Thumbnails debt.jpg  
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

  2. #2
    Join Date
    Jun 2004
    Posts
    31
    Change the last line from

    LANGUAGE 'SQL';

    to

    LANGUAGE plpgsql;

    and you should be set (assuming you have plpgsql installed).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •