问题标签 [dml]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
20591 浏览

sql-server - 动态替换 XML DML 中节点的值

我现在正在为此苦苦挣扎:如何在文本等于某个变量值的无类型 XML 列中替换节点的值?是否可以?

我的 XML:

我的尝试:

信息: (0 row(s) affected)

信息:

预期结果:

0 投票
3 回答
3658 浏览

mysql - 选择每组中的 SECOND LAST 记录

有一个Remark包含数据的表,如下所示:

什么查询将返回以下结果:

也就是应该返回每组倒数第二条记录?

假设 SerialNo 的所有 RemarkNo 都是连续的。备注编号越大,备注越晚。因此,序列号 10 的倒数第二个 RemarkNo 是 1,其中 Desp 为“rainy”。

0 投票
3 回答
2256 浏览

mysql - MySQL 5.5.30 cascaded triggers not working

For some reason, on a MySQL 5.5.30 machine, a trigger which deletes a row from a second table does no longer fire the delete trigger on the second table.

This works perfectly on our local MySQL version 5.5.25

I did not find any documentation that would explain this behaviour, does somebody maybe have an equal problem?

This is either a bug which occurs in MySQL version greater than 5.5.25 or a "feature" which is enabled accidently.

OK here my reproduce steps:

Database

Tables

Triggers

Q: Why do you quote identifiers using double quotes? (instead of backticks)

Because I don't like "niche syntax"

Testcase 1: Expected behaviour (database version 5.2.20)

testing insert trigger

expected table contents:

testing update trigger, set active

expected table contents:

testing update trigger, set inactive

expected table contents:


Testcase2: unexpected behaviour (MySQL Version 5.5.30)

Holy triggers grml - You know what? Shame that I didn't test the second case first - unfortunately I was not able to reproduce the error.. the test worked on 5.5.30 as well, will keep you updated :)

EDIT Trigger did not cascade because of an unknown definer which was remaining in the sql dump made for production. Removing DEFINER= in the trigger dumps (alternative solution would be to create the user or to change DEFINER= to an existing one) solved the problem, solved a part of he problem.

The unknown definer did not cause any log file output

0 投票
1 回答
62 浏览

sql - 如何在您的桌子上查看过去的 DML?

一位朋友问我是否有办法查看过去的 dml 语句,我不确定如何回答这个问题。他想看到的是最后一组插入语句。所以这意味着它可能超过 1 条记录。起初我只是说要检查最新的身份,但后来他问如果同时执行更多插入会怎样。你们能帮帮我吗?是否有我不知道的 DMV 我应该使用?谢谢。

0 投票
0 回答
330 浏览

java - alter table waiting for select query to get executed

I have a use case where i dynamically add new columns to db.The alter table works fine when no select queries are running on the db table.But if alter query is running at the same time when some heavy (i mean time consuming ) select query is running then alter query waits for the select query to finish.

My data is huge and select query may take a very long time .So the jdbc connections for alter table times out.

How can i go about this problem? Can i some how do this asynchronously? I mean fire alter query to db and break the connection and then let alter query be executed whever db can execute it.

Is this possible. Id i break the jdbc connection is the query execution aborted?

0 投票
1 回答
139 浏览

sql - 更新相关表(Postgres)

我正在 Postgres 中创建两个表。

第一个表有一个主列和其他列,并且在第二个表中有一个主列“MLeaseId”,这些列在第一个表中相同(不是第一个表的主列)和其他列。

如何将数据从第一个表列复制到第二列数据?

0 投票
1 回答
331 浏览

sql - SQL:如果在特定时间内 DB2 运行“sql”

我们公司正在使用 DB2,并且我们有一个调度程序(我无权访问),它每 5 分钟运行一组 SQL 文件。虽然我可以控制 SQL 语句

一个文件中的一条 SQL 每天只需要运行两次,而且它真的很重。因此,每 5 分钟运行一次会杀死系统。

因此我的问题/情况是,

  • 有没有一种聪明的方法来修改 SQL,以便它检查它是否在规定的时间段内,然后运行它。(即不执行逻辑,如果它在特定时间之外)?
  • 我无法将脚本或 if 循环作为纯 SQL。所以修改需要在数据操作语言(DML)语句中
  • 如果我只是简单地添加一个硬编码的时间参数,DB2 将执行逻辑然后进行时间检查。否则,将硬编码的时间参数放入 SQL 中会非常简单。

提前致谢

0 投票
1 回答
869 浏览

sql-server - 设置容器事务“必需”后 SSIS 包冻结

我正在尝试创建一个 SSIS 包,其中某个容器中的故障会导致该容器(并且只有该容器)的数据流回滚。这个包冻结,只有当我停止运行它或者我通过管理工作室终止进程时才会终止。

我还不能发布图片,所以我会给出一个简短的描述。

我有两个容器。第一个有:

  1. 包含从平面文件中选择到两个表中的数据流,我将其称为 t_imp 和 h_imp。
  2. 接下来是这两个表中字段 ObjCde 的更新任务。
  3. 容器中的最后一个数据流使用 t_imp 作为源,进一步操作和移动数据到其他表。

第三项是出错的地方。我已经看到 t_imp 表被锁定了。

包的事务选项是支持的,第一个容器是必需的,第二个容器是不支持的。(第二个容器包含流程任务和一个不应回滚的数据流任务。)所有隔离级别都在 ReadCommitted。

我在这里想念什么?

我是否不允许在同一个容器中使用表作为源和目标?

我需要设置其他参数吗?

0 投票
1 回答
59 浏览

oracle - 如何从 DML 中删除冗余数据

MDW_BILL1有以下列

MDW_BILL_TRANSACTION1具有以下列:

这是我要执行的查询:

o/p 是:

如何删除重复ACCOUNT_ID并为每组计费详细信息显示一个 account_id

我将代码修改为

但我仍然得到相同的结果

0 投票
2 回答
1530 浏览

c# - SQL server - 插入带单引号的字符串

我遍历外部源并获取字符串列表。然后我使用以下方法将它们插入数据库:

其中 commandString 是插入命令。IE

有时字符串包含 ' 或 " 或 \ 并且插入失败。
有没有一种优雅的方法来解决这个问题(即 @"" 或类似的)?