[英]SQLSTATE[42883]: Undefined function You might need to add explicit type casts
I'm using Laravel with postgres and i'm having this error: 我将Laravel与Postgres结合使用,但出现此错误:
SQLSTATE[42883]: Undefined function: 7 ERROR: function paymentrun(integer, date, double precision, text) does not exist LINE 1: SELECT paymentRun( ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. (SQL: SELECT paymentRun( :buyer_id::integer, :payment_date::DATE, :paid_amount::double precision, :paydetails::text);) SQLSTATE [42883]:未定义的函数:7错误:函数paymentrun(整数,日期,双精度,文本)不存在第1行:SELECT paymentRun(^提示:没有函数与给定的名称和参数类型匹配。您可能需要添加显式类型转换(SQL:SELECTpaymentRun(:buyer_id :: integer,:payment_date :: DATE,:paid_amount :: double precision,:paydetails :: text);)
Where I have this function: EDIT::the function is way bigger, but i think it's not needed to show 我在哪里有这个功能:编辑::功能更大,但我认为不需要显示
CREATE FUNCTION "paymentRun"(buyer_id integer, payment_date DATE, paid_amount double precision, payDetails text) RETURNS VOID AS
$$
DECLARE
row_STab "SearchTable"%rowtype;
curProd "KeysForSale"%rowtype;
totalPrice double precision;
returnedPID integer;
BEGIN
And I'm calling the fuction in this way: 我以这种方式称呼功能:
DB::select("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;");
DB::select('BEGIN TRANSACTION;');
$sendToSQL = '';
for($i = 0; $i<session('cart_number'); $i++)
$sendToSQL .= '(' . $cart_array[$i] . '),';
$sendToSQL = rtrim($sendToSQL,",");
$sendToSQL .= ';';
DB::select('INSERT INTO "SearchTable"(product_id) VALUES' . $sendToSQL);
//DB::select(DB::raw('SELECT paymentRun'))->where(Auth::id(), date('Y/m/d'),'PayPal', 10000, 'qualquer');
DB::select('SELECT paymentRun(
:buyer_id::integer,
:payment_date::DATE,
:paid_amount::double precision,
:paydetails::text);',
['buyer_id' => Auth::id(),
'payment_date' => date('Y/m/d'),
'paid_amount' => 10000,
'paydetails' =>'qualquer'
]);
//DB::select('DELETE FROM "SearchTable";');
DB::select('COMMIT;');
What i'm doing wrong? 我做错了什么? I tried several aways, but no a single one has come to a decent result.
我尝试了几次比赛,但没有一个取得令人满意的结果。
Thanks 谢谢
You created the function with the name within double quotes and different cases. 您使用双引号和不同大小写的名称创建了函数。
CREATE FUNCTION "paymentRun" ...
If you do so casing matters when the object is subsequently addressed. 如果这样做,则在随后处理该对象时,外壳很重要。 So you need to change
所以你需要改变
DB::select('SELECT paymentRun(
to 至
DB::select('SELECT "paymentRun"(
in order to address the function correctly. 为了正确解决该功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.