parameter type is unknown error

Started by Günce Kayaabout 9 years ago14 messagesgeneral
Jump to latest
#1Günce Kaya
guncekaya14@gmail.com

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice
(
id bigserial NOT NULL,
orderid integer NOT NULL,
cargoid integer NOT NULL,
invoiceowner integer NOT NULL,
invoiceaddress character(250) NOT NULL,
receiverfname character varying(50) NOT NULL,
receiverlname character varying(50) NOT NULL,
receiverphone integer NOT NULL,
sendingdatetime timestamp without time zone DEFAULT now(),
distance real NOT NULL,
weight numeric NOT NULL,
addedtax numeric NOT NULL DEFAULT 8,
invoiceamount money DEFAULT 0,
cargocreateddate date,
cargoupdateddate timestamp without time zone,
cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)
values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance,
fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate,
fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)
values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(),
10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

Any help would be appreciated.

Regards,

--
Gunce Kaya

#2Günce Kaya
guncekaya14@gmail.com
In reply to: Günce Kaya (#1)
Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice
(
id bigserial NOT NULL,
orderid integer NOT NULL,
cargoid integer NOT NULL,
invoiceowner integer NOT NULL,
invoiceaddress character(250) NOT NULL,
receiverfname character varying(50) NOT NULL,
receiverlname character varying(50) NOT NULL,
receiverphone integer NOT NULL,
sendingdatetime timestamp without time zone DEFAULT now(),
distance real NOT NULL,
weight numeric NOT NULL,
addedtax numeric NOT NULL DEFAULT 8,
invoiceamount money DEFAULT 0,
cargocreateddate date,
cargoupdateddate timestamp without time zone,
cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)
values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance,
fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate,
fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)
values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(),
10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

Any help would be appreciated.

Regards,

--
Gunce Kaya

#3Charles Clavadetscher
clavadetscher@swisspug.org
In reply to: Günce Kaya (#2)
Re: Fwd: parameter type is unknown error

Hello

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 12:36
To: pgsql-general@postgresql.org
Subject: [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script. When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, unknown, unknown, unknown, integer, timestamp with time zone, integer, integer, money, timestamp with time zone, timestamp with time zone, timestamp with time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress, freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2', 12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(), 10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check them in order to find out which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

In reply to: Günce Kaya (#2)
Re: Fwd: parameter type is unknown error

On 06/03/17 11:36, Günce Kaya wrote:

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer,
*unknown, unknown, unknown*, integer, timestamp with time zone, integer,
integer, money, timestamp with time zone, timestamp with time zone,
timestamp with time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice
(
id bigserial NOT NULL,
orderid integer NOT NULL,
cargoid integer NOT NULL,
invoiceowner integer NOT NULL,
invoiceaddress character(250) NOT NULL,
receiverfname character varying(50) NOT NULL,
receiverlname character varying(50) NOT NULL,
receiverphone integer NOT NULL,
sendingdatetime timestamp without time zone DEFAULT now(),
distance real NOT NULL,
weight numeric NOT NULL,
addedtax numeric NOT NULL DEFAULT 8,
invoiceamount money DEFAULT 0,
cargocreateddate date,
cargoupdateddate timestamp without time zone,
cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner,
invoiceaddress, receiverfname, receiverlname, receiverphone,
sendingdatetime, distance, weight, addedtax, invoiceamount,
cargocreateddate, cargoupdateddate, cargocancelled)
values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime,
fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate,
fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

You've declared the function with type "character" for the fourth
parameter, but you're trying to pass a varchar or text value.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5Günce Kaya
guncekaya14@gmail.com
In reply to: Charles Clavadetscher (#3)
Re: Fwd: parameter type is unknown error

Hi Charles,

Thank you for your response. I used pg_typeof() function to show parameters
type.

select pg_typeof('asdasdasd');

result -> "unknown"

but I can use this parameter without custom function as successfully and
using cast is doesn't work to get result as successful.

do you have any advice for that?

Regards,

Gunce

2017-03-06 14:51 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org

:

Hello

*From:* pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@
postgresql.org] *On Behalf Of *Günce Kaya
*Sent:* Montag, 6. März 2017 12:36
*To:* pgsql-general@postgresql.org
*Subject:* [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is
following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime,
fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate,
fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner,
invoiceaddress, receiverfname, receiverlname, receiverphone,
sendingdatetime, distance, weight, addedtax, invoiceamount,
cargocreateddate, cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(),
10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check
them in order to find out which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without
time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

--
Gunce Kaya

#6Günce Kaya
guncekaya14@gmail.com
In reply to: Günce Kaya (#5)
Re: Fwd: parameter type is unknown error

Hi Ray,

I think the problem is not associated with you suggestion cause I changed
both of two parameter type as varchar(by the way, I deleted address column
and I only have two column that got me crazy!) still doesn't insert any
data.

you can see changes as I emphasized as bold.

create or replace function cargo.insertinvoice (forderid integer, fcargoid
integer, finvoiceowner integer, freceiverfname *varchar*, freceiverlname
*varchar*, 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 $$
declare v_id bigint;
begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, receiverfname,
receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax,
invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled)
values(forderid,fcargoid,finvoiceowner,freceiverfname,freceiverlname,freceiverphone,
fsendingdatetime,
fdistance,fweight,faddedtax,finvoiceamount,fcargocreateddate,fcargoupdateddate,fcargocancelled)
returning id;
end;
$$ language plpgsql;

I used bellow code to execute function;

select * from cargo.insertinvoice(1013, 10, 44,cast('test1' as
varchar),cast('test2' as varchar) , 12345, now(), 10000,30, 8,
400,now(),now(),now());

and I got another error;

ERROR: function cargo.insertinvoice(integer, integer, integer, character
varying, character varying, integer, timestamp with time zone, integer,
integer, integer, integer, timestamp with time zone, timestamp with time
zone, timestamp with time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44,cast('test1' ...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

It seems nothing changed.

Yours sincerely,

Gunce

2017-03-06 15:00 GMT+03:00 Günce Kaya <guncekaya14@gmail.com>:

Hi Charles,

Thank you for your response. I used pg_typeof() function to show
parameters type.

select pg_typeof('asdasdasd');

result -> "unknown"

but I can use this parameter without custom function as successfully and
using cast is doesn't work to get result as successful.

do you have any advice for that?

Regards,

Gunce

2017-03-06 14:51 GMT+03:00 Charles Clavadetscher <
clavadetscher@swisspug.org>:

Hello

*From:* pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@po
stgresql.org] *On Behalf Of *Günce Kaya
*Sent:* Montag, 6. März 2017 12:36
*To:* pgsql-general@postgresql.org
*Subject:* [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is
following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner,
invoiceaddress, receiverfname, receiverlname, receiverphone,
sendingdatetime, distance, weight, addedtax, invoiceamount,
cargocreateddate, cargoupdateddate, cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime,
fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate,
fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner,
invoiceaddress, receiverfname, receiverlname, receiverphone,
sendingdatetime, distance, weight, addedtax, invoiceamount,
cargocreateddate, cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(),
10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check
them in order to find out which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without
time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

--
Gunce Kaya

--
Gunce Kaya

#7Charles Clavadetscher
clavadetscher@swisspug.org
In reply to: Günce Kaya (#5)
Re: Fwd: parameter type is unknown error

Hello Günce

From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 13:01
To: Charles Clavadetscher <clavadetscher@swisspug.org>
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Fwd: parameter type is unknown error

Hi Charles,

Thank you for your response. I used pg_typeof() function to show parameters type.

select pg_typeof('asdasdasd');

result -> "unknown"

Well, a string in single quotes is not necessarily a text:

db=> select pg_typeof('{"hello": "world"}');

pg_typeof

-----------

unknown

(1 row)

db=> select pg_typeof('{"hello": "world"}'::varchar);

pg_typeof

-------------------

character varying

(1 row)

db=> select pg_typeof('{"hello": "world"}'::text);

pg_typeof

-----------

text

(1 row)

db.archivedb=> select pg_typeof('{"hello": "world"}'::json);

pg_typeof

-----------

json

(1 row)

You probably need to specify that your string is a text.

Bye

Charles

but I can use this parameter without custom function as successfully and using cast is doesn't work to get result as successful.

do you have any advice for that?

Regards,

Gunce

2017-03-06 14:51 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org <mailto:clavadetscher@swisspug.org> >:

Hello

From: pgsql-general-owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> [mailto:pgsql-general-owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> ] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 12:36
To: pgsql-general@postgresql.org <mailto:pgsql-general@postgresql.org>
Subject: [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script. When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, unknown, unknown, unknown, integer, timestamp with time zone, integer, integer, money, timestamp with time zone, timestamp with time zone, timestamp with time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress, freceiverfname,freceiverlname,freceiverphone, fsendingdatetime, fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2', 12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress, receiverfname, receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(), 10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check them in order to find out which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

--

Gunce Kaya

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Günce Kaya (#6)
Re: Fwd: parameter type is unknown error

=?UTF-8?Q?G=C3=BCnce_Kaya?= <guncekaya14@gmail.com> writes:

I think the problem is not associated with you suggestion cause I changed
both of two parameter type as varchar(by the way, I deleted address column
and I only have two column that got me crazy!) still doesn't insert any
data.

There are a lot of moving parts there, but I think probably the one that
is actually failing is that you're passing "400" to a parameter declared
as "money". There's no implicit integer-to-money cast so that doesn't
work. (That cast is assignment level which is why failing to cast works
if you insert directly.)

Or at least that's what it appears from your sample call, but I'm confused
about why your error message reads

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

I do not think this message corresponds to the sample call you showed us,
because the whole point is that the eleventh parameter wasn't already of
type "money".

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#9Günce Kaya
guncekaya14@gmail.com
In reply to: Charles Clavadetscher (#7)
Re: Fwd: parameter type is unknown error

Hi Charles,

You are right about parameter types. When I use function with cast as you
mentioned, I don't see "unknown". I see data types. but still doesn't
insert with my custom function. It's really weird cause I did same thing
for different function and It works.

Regards,

Gunce

2017-03-06 15:22 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org

:

Hello Günce

*From:* pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@
postgresql.org] *On Behalf Of *Günce Kaya
*Sent:* Montag, 6. März 2017 13:01
*To:* Charles Clavadetscher <clavadetscher@swisspug.org>
*Cc:* pgsql-general@postgresql.org
*Subject:* Re: [GENERAL] Fwd: parameter type is unknown error

Hi Charles,

Thank you for your response. I used pg_typeof() function to show
parameters type.

select pg_typeof('asdasdasd');

result -> "unknown"

Well, a string in single quotes is not necessarily a text:

db=> select pg_typeof('{"hello": "world"}');

pg_typeof

-----------

unknown

(1 row)

db=> select pg_typeof('{"hello": "world"}'::varchar);

pg_typeof

-------------------

character varying

(1 row)

db=> select pg_typeof('{"hello": "world"}'::text);

pg_typeof

-----------

text

(1 row)

db.archivedb=> select pg_typeof('{"hello": "world"}'::json);

pg_typeof

-----------

json

(1 row)

You probably need to specify that your string is a text.

Bye

Charles

but I can use this parameter without custom function as successfully and
using cast is doesn't work to get result as successful.

do you have any advice for that?

Regards,

Gunce

2017-03-06 14:51 GMT+03:00 Charles Clavadetscher <
clavadetscher@swisspug.org>:

Hello

*From:* pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@
postgresql.org] *On Behalf Of *Günce Kaya
*Sent:* Montag, 6. März 2017 12:36
*To:* pgsql-general@postgresql.org
*Subject:* [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script.
When I execute the function I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, *unknown,
unknown, unknown*, integer, timestamp with time zone, integer, integer,
money, timestamp with time zone, timestamp with time zone, timestamp with
time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is
following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress,
receiverfname, receiverlname, receiverphone, sendingdatetime, distance,
weight, addedtax, invoiceamount, cargocreateddate, cargoupdateddate,
cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress,
freceiverfname,freceiverlname,freceiverphone, fsendingdatetime,
fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate,
fcargoupdateddate, fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2',
12345, now(), 10000,30, 400, now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner,
invoiceaddress, receiverfname, receiverlname, receiverphone,
sendingdatetime, distance, weight, addedtax, invoiceamount,
cargocreateddate, cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(),
10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check
them in order to find out which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without
time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

--

Gunce Kaya

--
Gunce Kaya

#10Charles Clavadetscher
clavadetscher@swisspug.org
In reply to: Günce Kaya (#9)
Re: Fwd: parameter type is unknown error

Hello Günce

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 13:37
To: Charles Clavadetscher <clavadetscher@swisspug.org>
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Fwd: parameter type is unknown error

Hi Charles,

You are right about parameter types. When I use function with cast as you mentioned, I don't see "unknown". I see
data types. but still doesn't insert with my custom function. It's really weird cause I did same thing for different
function and It works.

This works:

CREATE TABLE cargo.invoice
(
id bigserial NOT NULL,
orderid integer NOT NULL,
cargoid integer NOT NULL,
invoiceowner integer NOT NULL,
invoiceaddress character(250) NOT NULL,
receiverfname character varying(50) NOT NULL,
receiverlname character varying(50) NOT NULL,
receiverphone integer NOT NULL,
sendingdatetime timestamp without time zone DEFAULT now(),
distance real NOT NULL,
weight numeric NOT NULL,
addedtax numeric NOT NULL DEFAULT 8,
invoiceamount money DEFAULT 0,
cargocreateddate date,
cargoupdateddate timestamp without time zone,
cargocancelled timestamp without time zone
);

create or replace function cargo.insertinvoice (forderid integer,
fcargoid integer,
finvoiceowner integer,
finvoiceaddress varchar(250),
freceiverfname varchar,
freceiverlname varchar,
freceiverphone integer,
fsendingdatetime timestamp without time zone,
fdistance real,
faddedtax numeric,
fweight numeric,
finvoiceamount money,
fcargocreateddate date,
fcargoupdateddate timestamp,
fcargocancelled timestamp without time zone) returns numeric as $$
declare v_id bigint;
begin

insert into cargo.invoice (orderid,
cargoid,
invoiceowner,
invoiceaddress,
receiverfname,
receiverlname,
receiverphone,
sendingdatetime,
distance,
weight,
addedtax,
invoiceamount,
cargocreateddate,
cargoupdateddate,
cargocancelled)
values(forderid,
fcargoid,
finvoiceowner,
finvoiceaddress,
freceiverfname,
freceiverlname,
freceiverphone,
fsendingdatetime,
fdistance,
fweight,
faddedtax,
finvoiceamount,
fcargocreateddate,
fcargoupdateddate,
fcargocancelled)
returning id into v_id;
return v_id;
end;
$$ language plpgsql;

select * from cargo.insertinvoice(1013,
10,
44,
'Wherever'::varchar(250),
'test1'::varchar,
'test2'::varchar,
12345,
now()::timestamp,
10000.30::real,
1000::numeric,
8::numeric,
400::money,
now()::date,
now()::timestamp,
now()::timestamp);

As Tom pointed out there were many problems:
- List of parameter not matching the table.
- List of parameters types not matching the list in the function call.
- Returning the id from the function.

Some of the casting may not be mandatory, but it is up to you now to check this.

Hope this helps.
Bye
Charles

Regards,

Gunce

2017-03-06 15:22 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org <mailto:clavadetscher@swisspug.org> >:

Hello Günce

From: pgsql-general-owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> [mailto:pgsql-general-
owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> ] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 13:01
To: Charles Clavadetscher <clavadetscher@swisspug.org <mailto:clavadetscher@swisspug.org> >
Cc: pgsql-general@postgresql.org <mailto:pgsql-general@postgresql.org>
Subject: Re: [GENERAL] Fwd: parameter type is unknown error

Hi Charles,

Thank you for your response. I used pg_typeof() function to show parameters type.

select pg_typeof('asdasdasd');

result -> "unknown"

Well, a string in single quotes is not necessarily a text:

db=> select pg_typeof('{"hello": "world"}');

pg_typeof

-----------

unknown

(1 row)

db=> select pg_typeof('{"hello": "world"}'::varchar);

pg_typeof

-------------------

character varying

(1 row)

db=> select pg_typeof('{"hello": "world"}'::text);

pg_typeof

-----------

text

(1 row)

db.archivedb=> select pg_typeof('{"hello": "world"}'::json);

pg_typeof

-----------

json

(1 row)

You probably need to specify that your string is a text.

Bye

Charles

but I can use this parameter without custom function as successfully and using cast is doesn't work to get
result as successful.

do you have any advice for that?

Regards,

Gunce

2017-03-06 14:51 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org
<mailto:clavadetscher@swisspug.org> >:

Hello

From: pgsql-general-owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> [mailto:pgsql-
general-owner@postgresql.org <mailto:pgsql-general-owner@postgresql.org> ] On Behalf Of Günce Kaya
Sent: Montag, 6. März 2017 12:36
To: pgsql-general@postgresql.org <mailto:pgsql-general@postgresql.org>
Subject: [GENERAL] Fwd: parameter type is unknown error

Hi all,

I created a dummy table and related function that include insert script. When I execute the function
I'm getting error like bellow;

ERROR: function cargo.insertinvoice(integer, integer, integer, unknown, unknown, unknown, integer,
timestamp with time zone, integer, integer, money, timestamp with time zone, timestamp with time zone, timestamp
with time zone) does not exist

LINE 1: select * from cargo.insertinvoice(1013, 10, 44, 'asda','test...

^

HINT: No function matches the given name and argument types. You might need to add explicit type
casts.

Table's create script as bellow;

CREATE TABLE cargo.invoice

(

id bigserial NOT NULL,

orderid integer NOT NULL,

cargoid integer NOT NULL,

invoiceowner integer NOT NULL,

invoiceaddress character(250) NOT NULL,

receiverfname character varying(50) NOT NULL,

receiverlname character varying(50) NOT NULL,

receiverphone integer NOT NULL,

sendingdatetime timestamp without time zone DEFAULT now(),

distance real NOT NULL,

weight numeric NOT NULL,

addedtax numeric NOT NULL DEFAULT 8,

invoiceamount money DEFAULT 0,

cargocreateddate date,

cargoupdateddate timestamp without time zone,

cargocancelled timestamp without time zone);

The function that content insert script to cargo.invoice table is following;

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 $$

declare v_id bigint;

begin

insert into cargo.invoice (orderid, cargoid, invoiceowner, invoiceaddress, receiverfname,
receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate,
cargoupdateddate, cargocancelled)

values(forded, fcargoid, finvoiceowner, finvoiceaddress, freceiverfname,freceiverlname,freceiverphone,
fsendingdatetime, fdistance, fweight, faddedtax, finvoiceamount, fcargocreateddate, fcargoupdateddate,
fcargocancelled);

select max(id) into v_id from cargo.invoice;

return v_id;

end;

$$ language plpgsql;

So, when I execute the function like;

select * from cargo.insertinvoice(1013, 10, 44, 'asda','test1','test2', 12345, now(), 10000,30, 400,
now(), now(), now());

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,

insert into cargo.invoice ( orderid, cargoid, invoiceowner, invoiceaddress, receiverfname,
receiverlname, receiverphone, sendingdatetime, distance, weight, addedtax, invoiceamount, cargocreateddate,
cargoupdateddate, cargocancelled)

values( 1012, 10, 44, 'asdasdasd','xx', 'xxx', 12345, now(), 10000,30,8,400,now(),now(),now());

I can insert data successfully. Do you have any idea about that?

One or more parameter don’t have the expected data type. You should check them in order to find out
which ones are giving trouble.

In the short you may try to cast your calls to now() to timezone without time stamp: now()::timestamp.

The function now() returns:

db=> select pg_typeof(now());

pg_typeof

--------------------------

timestamp with time zone

(1 row)

And this is different from without time zone.

Hope this helps.

Bye

Charles

Any help would be appreciated.

Regards,

--

Gunce Kaya

--

Gunce Kaya

--

Gunce Kaya

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#11Samed YILDIRIM
samed@reddoc.net
In reply to: Günce Kaya (#1)
Re: parameter type is unknown error

<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@gmail.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>

#12Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Günce Kaya (#9)
Re: Fwd: parameter type is unknown error

On 03/06/2017 04:36 AM, Günce Kaya wrote:

Hi Charles,

You are right about parameter types. When I use function with cast as
you mentioned, I don't see "unknown". I see data types. but still
doesn't insert with my custom function. It's really weird cause I did
same thing for different function and It works.

If I am following correctly could not the function be eliminated by using?:

insert into cargo.invoice ( orderid, .... ) RETURNING id;

Regards,

Gunce

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#13Charles Clavadetscher
clavadetscher@swisspug.org
In reply to: Adrian Klaver (#12)
Re: Fwd: parameter type is unknown error

Hallo Adrian

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Adrian Klaver
Sent: Montag, 6. März 2017 15:13
To: Günce Kaya <guncekaya14@gmail.com>; Charles Clavadetscher <clavadetscher@swisspug.org>
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Fwd: parameter type is unknown error

On 03/06/2017 04:36 AM, Günce Kaya wrote:

Hi Charles,

You are right about parameter types. When I use function with cast as
you mentioned, I don't see "unknown". I see data types. but still
doesn't insert with my custom function. It's really weird cause I did
same thing for different function and It works.

If I am following correctly could not the function be eliminated by using?:

insert into cargo.invoice ( orderid, .... ) RETURNING id;

Yes, of course. I assume that this was a simplified example from the OP.
Bye
Charles

Regards,

Gunce

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#14Günce Kaya
guncekaya14@gmail.com
In reply to: Charles Clavadetscher (#13)
Re: Fwd: parameter type is unknown error

Good morning,

Sorry for delay. I looked at your suggestions and also tried all of them.

Charles, thank you for your advise. I changed my function structure as you
said and I executed the function as Samed mentioned so It works now. I did
not want to use cast for varchar parameters cause in my previous functions,
I didn't require it. I knew this problem is not only associated with
varchar parameters due to my experienced.

Thank you for sharing your experiences. I could accomplished this case with
your helps.

Regards,

Gunce

2017-03-06 17:20 GMT+03:00 Charles Clavadetscher <clavadetscher@swisspug.org

:

Hallo Adrian

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@

postgresql.org] On Behalf Of Adrian Klaver

Sent: Montag, 6. März 2017 15:13
To: Günce Kaya <guncekaya14@gmail.com>; Charles Clavadetscher <

clavadetscher@swisspug.org>

Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Fwd: parameter type is unknown error

On 03/06/2017 04:36 AM, Günce Kaya wrote:

Hi Charles,

You are right about parameter types. When I use function with cast as
you mentioned, I don't see "unknown". I see data types. but still
doesn't insert with my custom function. It's really weird cause I did
same thing for different function and It works.

If I am following correctly could not the function be eliminated by

using?:

insert into cargo.invoice ( orderid, .... ) RETURNING id;

Yes, of course. I assume that this was a simplified example from the OP.
Bye
Charles

Regards,

Gunce

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

--
Gunce Kaya