简体   繁体   English

SQLSTATE [42883]:未定义的函数,您可能需要添加显式类型强制转换

[英]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.

相关问题 PostgreSQL:没有运算符匹配给定的名称和参数类型。 您可能需要使用存在函数在 codeigniter 中添加显式类型转换 - PostgreSQL: No operator matches the given name and argument types. You might need to add explicit type casts in codeigniter using exist function 将“您可能感兴趣的”产品添加到magento中的交易电子邮件中 - Add “you might be interested in” products to transactional emails in magento SQLSTATE[42000],未定义密码 - SQLSTATE[42000], undefined password 需要增加功能 - Need to add function 无法检测到 ReaderType 或 WriterType。 确保您将有效的扩展名传递给文件名或传递显式类型 - No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type Mysql:SQLSTATE[42000]:语法错误或访问冲突:1171 PRIMARY KEY 的所有部分必须不是 NULL; 如果您需要 NULL 键,请使用 UNIQUE inst - Mysql: SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE inst 调用未定义函数 mime_content_type() - Call to undefined function mime_content_type() 未定义的add_menu_page()wordpress函数 - Undefined add_menu_page() wordpress function 我需要在myClickHandler()函数中添加一些内容 - I need to add something in myClickHandler() function WordPress插件-需要添加PHP功能 - Wordpress plugin- need add PHP function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM