0
votes

I use Npgsql 2.2.5 with EntityFramework 6.1.3 database first and extended context to call some server functions one of them gives this error:

"ERROR: 42883: function insert_chempair(integer, unknown) does not exist"

ErrorSql: select * from insert_chempair(((50066)),(('C1(=O)C(c2ccccc2)(CC)C(=O)NC(=O)N1')))

With Code:

            public int AddChemPair(int cas,string smilesstr)
            {

                return this.Database.SqlQuery<int>("select * from insert_chempair(@p0,@p1)",(object)cas,(object)smilesstr).First();
            }

Googling suggested to use typed paremeters i`ve changed object params to NpgsqlParameter types but the eror is not much different :

BaseMessage "function insert_chempair(integer, text) does not exist" string Using SQLManagemnet studio i`m able to execute the function.

CREATE FUNCTION insert_chem_pair(new_cas integer,new_smiles text) RETURNS integer
    LANGUAGE plpgsql STRICT
 AS $$
DECLARE new_id integer;
DECLARE new_smiles_id integer;
BEGIN
  select  * into new_smiles_id    from insert_smiles(new_smiles);
  select id into new_id  from chempair where cas=new_cas and smiles_id=new_smiles_id;
  if( new_id is NULL) then
    insert into chempair(cas,smiles_id) values(new_cas,new_smiles_id) returning chempair.id into new_id;
  end if;
  RETURN new_id;
END;
$$;

Am i doing something wrong.

1
I found it (insert_chem_pair != insert_chempair) - danisius

1 Answers

0
votes

The devil is in details:

Function is defined like this insert_chem_pair but i call insert_chempair

It seems DST affected me.