Re: parameter type is unknown error

From: Samed YILDIRIM <samed(at)reddoc(dot)net>
To: Günce Kaya <guncekaya14(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: parameter type is unknown error
Date: 2017-03-06 13:27:10
Message-ID: 2907741488806830@web31j.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

<div>Hi Günce,<br /> </div><div>Your insert statement has following problems. faddedtax is not a parameter of your function. Also bolded parts of your create function statement was missing.</div><div> </div><div>Also you should call your function with casting like following.</div><div><span style="font-family:courier new,monospace;">select insertinvoice(1013, 10, 44, 'asda','test1','test2', 12345, now()<strong>::timestamp(0)</strong>, 10000,30, 400<strong>::money</strong>, now()<strong>::date</strong>, now()<strong>::timestamp</strong>, now()<strong>::timestamp(0)</strong>);</span></div><div> </div><div> </div><div> </div><div><div><div><span style="font-family:courier new,monospace;">create or replace function cargo.insertinvoice (forderid integer, fcargoid integer, finvoiceowner integer, finvoiceaddress character <strong>varying,</strong> freceiverfname character varying, freceiverlname character varying, freceiverphone integer, fsendingdatetime timestamp without time zone, fdistance real, fweight numeric,  finvoiceamount money, fcargocreateddate date, fcargoupdateddate timestamp, fcargocancelled timestamp without time zone) returns numeric as $$</span></div><div> </div><div><span style="font-family:courier new,monospace;">declare v_id bigint;</span></div><div> </div><div><span style="font-family:courier new,monospace;">begin</span></div><div> </div><div><span style="font-family:courier new,monospace;">insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled) </span></div><div><span style="font-family:courier new,monospace;">values(<strong>forderid</strong>, fcargoid, finvoiceowner, finvoiceaddress, freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance, fweight, <strong><u><em>faddedtax,</em></u></strong> finvoiceamount, fcargocreateddate, fcargoupdateddate, fcargocancelled);</span></div><div> </div><div><span style="font-family:courier new,monospace;">select max(id) into v_id from cargo.invoice;</span></div><div> </div><div><span style="font-family:courier new,monospace;">return v_id;</span></div><div> </div><div><span style="font-family:courier new,monospace;">end;</span></div><div> </div><div><span style="font-family:courier new,monospace;">$$ language plpgsql;</span></div></div></div><div> </div><div> </div><div>İyi çalışmalar.</div><div>Samed YILDIRIM</div><div> </div><div> </div><div> </div><div>06.03.2017, 14:30, "Günce Kaya" &lt;guncekaya14(at)gmail(dot)com&gt;:</div><blockquote type="cite"><div><div><span style="color:#000000;font-size:12.8px;">Hi all,</span></div><div> </div><div><font color="#000000"><span style="font-size:12.8px;">I created a dummy table and related function that include insert script. When I execute the function I'm getting error like bellow;</span></font></div><div> </div><div><p style="margin:0px;font-size:12px;line-height:normal;font-family:monaco;">ERROR:  function cargo.insertinvoice(integer, integer, integer, <strong>unknown, unknown, unknown</strong>, integer, timestamp with time zone, integer, integer, money, timestamp with time zone, timestamp with time zone, timestamp with time zone) does not exist</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:monaco;">LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:monaco;">                      ^</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:monaco;">HINT:  No function matches the given name and argument types. You might need to add explicit type casts.</p><div> </div><div>Table's create script as bellow;</div><div> </div><div><div><font face="monospace, monospace">CREATE TABLE cargo.invoice</font></div><div><font face="monospace, monospace">(</font></div><div><font face="monospace, monospace">  id bigserial NOT NULL,</font></div><div><font face="monospace, monospace">  orderid integer NOT NULL,</font></div><div><font face="monospace, monospace">  cargoid integer NOT NULL,</font></div><div><font face="monospace, monospace">  invoiceowner integer NOT NULL,</font></div><div><font face="monospace, monospace">  invoiceaddress character(250) NOT NULL,</font></div><div><font face="monospace, monospace">  receiverfname character varying(50) NOT NULL,</font></div><div><font face="monospace, monospace">  receiverlname character varying(50) NOT NULL,</font></div><div><font face="monospace, monospace">  receiverphone integer NOT NULL,</font></div><div><font face="monospace, monospace">  sendingdatetime timestamp without time zone DEFAULT now(),</font></div><div><font face="monospace, monospace">  distance real NOT NULL,</font></div><div><font face="monospace, monospace">  weight numeric NOT NULL,</font></div><div><font face="monospace, monospace">  addedtax numeric NOT NULL DEFAULT 8,</font></div><div><font face="monospace, monospace">  invoiceamount money DEFAULT 0,</font></div><div><font face="monospace, monospace">  cargocreateddate date,</font></div><div><font face="monospace, monospace">  cargoupdateddate timestamp without time zone,</font></div><div><font face="monospace, monospace">  cargocancelled timestamp without time zone);</font></div></div><div> </div><div>The function that content insert script to cargo.invoice table is following;</div><div> </div><div><div><font face="monospace, monospace">create or replace function cargo.insertinvoice (forderid integer, fcargoid integer, finvoiceowner integer, finvoiceaddress character, freceiverfname character varying, freceiverlname character varying, freceiverphone integer, fsendingdatetime timestamp without time zone, fdistance real, fweight numeric,  finvoiceamount money, fcargocreateddate date, fcargoupdateddate timestamp, fcargocancelled timestamp without time zone) returns numeric as $$</font></div><div> </div><div><font face="monospace, monospace">declare v_id bigint;</font></div><div> </div><div><font face="monospace, monospace">begin</font></div><div> </div><div><font face="monospace, monospace">insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled) </font></div><div><font face="monospace, monospace">values(forded, fcargoid, finvoiceowner, finvoiceaddress, freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate, fcargocancelled);</font></div><div> </div><div><font face="monospace, monospace">select max(id) into v_id from cargo.invoice;</font></div><div> </div><div><font face="monospace, monospace">return v_id;</font></div><div> </div><div><font face="monospace, monospace">end;</font></div><div> </div><div><font face="monospace, monospace">$$ language plpgsql;</font></div></div><div> </div><div> </div><div>So, when I execute the function like;</div><div> </div><div><div><font face="monospace, monospace">select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2', 12345, now(), 10000,30, 400, now(), now(), now());</font></div></div><div> </div><div>I'm getting error as you can see in second paragraph even I use cast for three "unknown" parameter in insert script which is in function , I can not overcome with this issue so I still get same error.  If I use only following script to insert values to cargo.invoice table,</div><div> </div><div><font face="monospace, monospace">insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled) </font></div><div><font face="monospace, monospace">values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(), 10000,30,8,400,now(),now(),now());</font></div><div> </div><div>I can insert data successfully. Do you have any idea about that? </div><div> </div><div>Any help would be appreciated.</div><div> </div><div>Regards,</div><div> </div>--<div><div>Gunce Kaya</div></div></div></div></blockquote>

Attachment Content-Type Size
unknown_filename text/html 8.2 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-03-06 14:12:59 Re: Fwd: parameter type is unknown error
Previous Message Charles Clavadetscher 2017-03-06 12:51:54 Re: Fwd: parameter type is unknown error

Browse pgsql-sql by date

  From Date Subject
Next Message Adrian Klaver 2017-03-06 14:12:59 Re: Fwd: parameter type is unknown error
Previous Message Charles Clavadetscher 2017-03-06 12:51:54 Re: Fwd: parameter type is unknown error