咨询热线0898-88889999
网站首页 关于傲世皇朝 傲世皇朝注册 傲世皇朝动态 傲世皇朝登录 傲世皇朝平台 傲世皇朝入口 傲世皇朝代理 联系我们
咨询热线
0898-88889999
地址:海南省海口市
邮箱:admin@youweb.com

傲世皇朝平台

当前位置: 首页 > 傲世皇朝平台

DBI, Placeholders, and a nested query

发布时间:2025-07-05 08:59:21 点击量:

Edit: Solution found and described below.
Hello all,

I'm attempting to insert/update into an MSSQL database. The source of the data is another database. Sometimes the source database has new records, and other times there are existing records.

So I'm attempting to do this:

IF NOT EXISTS(SELECT * FROM dbTable WHERE library_no=:library_no)
BEGIN
   INSERT INTO dbTable (...library_no1...) 
   VALUES ( ... :library_no2...);
END
ELSE
   BEGIN
      UPDATE dbTable
      SET=cut fields=end
      WHERE library_no=:library_no3;
   END
GO

(DBI returns an error if I try to reuse a label, so for this I've had to create different labels with the same content, which isn't a huge problem; this is not related to the problem).

I'm getting the following error:

Can't bind unknown placeholder ':library_no'...

This is in the first line and is supposed to be related to a sub-query used to determine if we're updating or inserting data.

Is DBI unable to bind to nested queries, or am I missing something? I'd prefer to do this in one query instead of checking each record to decide on whether to insert vs. update.

Thanks!

Update: Solution

The issue is that the ODBC connection in Perl does not not work with the : before the named parameter. So while you can have , needs it address as "name", not ":name". This appears to be specific to ODBC, so depending on how you connect to your database, this may or may not apply.

Thanks thread!

平台注册入口