问题标签 [sql-pl]

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 投票
2 回答
410 浏览

db2 - 如何在sql/pl中做一个子过程

我正在执行从 pl / sql (oracle) 到 sql / pl (DB2) 的过程迁移,但我不知道如何将子过程传递给 DB2

由于我不是系统管理员,我无法将 DB2 更改为 pl / sql 兼容

例子

0 投票
1 回答
66 浏览

stored-procedures - 将过程从 Oracle 转换为 DB2,尝试在运行时更新表时出错

您好 DB2 专家,我需要您的帮助来将下面的过程转换为更动态的东西。我们必须为每个表更新具有最大 id 列的多个序列。

这是我从上面的代码中写的: 这里我希望 N_PRI_KEY 是动态的,并且 mySchema.myTable 在运行时使用表中的值进行更新。

这是我尝试创建过程时遇到的错误。

当我运行这一行时,它会工作并在 TEMPOUTPUT 表中插入最大值。

我试过这样做,但没有奏效。

仅供参考 - 这是一个用 Oralce 编写的程序,它正在做类似的事情。

0 投票
1 回答
41 浏览

sql - 如何在 SQL Plus/SQL-PL 中使用迭代或作为函数运行查询?

SQL Plus 的新手,对迭代和函数如何使用它有点困惑。希望有人可以告诉我如何使用以下脚本完成:

所以我想做的是多次重复这个脚本,每次都改变 x 和文件路径。在 SQL Plus 中解决这个问题的最佳方法是什么?

谢谢!

0 投票
1 回答
151 浏览

sql - DB2 SQLPL - 无法退出无限循环

我创建了一个存储过程,通过遍历 DB2 示例数据库中员工表中的每一行来手动计算标准偏差 -

但是,该过程陷入了无限循环。我不确定它为什么会卡住,因为我SQLSTATE在阅读桌子上的最后一行并希望退出后预计不会是“00000”。问题是什么?我该如何调试?我如何解决它?

0 投票
1 回答
503 浏览

oracle - SQL Script using Data Pump Import/Export executing in Oracle SQL developer?

I'm trying to better understand the Oracle Data pump functionality used to export data from one database and import it into a different database in a different location. My goal is to create a SQL script so I can automate most of the work and execute the script anytime I need to transfer data over and reduce dependency on the DBA. I am hoping I would not need to get in touch with the DBA each time (I have some limited admin access over the databases).

From my research so far, I have seen examples where people were writing some PL-SQL scripts and running them in SQL Plus (I think). I read that most PL-SQL scripts can be run in SQL Developer but not sure if Data pump commands work in there. If it is possible, I wonder if I could simply just take the same script and use it in either SQL Plus or SQL Developer interchangeably or I would need to make some minor modifications. I'm not sure if I have access to SQL Plus (still learning about it) so preferably want to use SQL developer.

I did find out that there is some Data pump wizard within SQL developer where you can run it but you would need to do it from the DBA panel in the program which I don't think I have the necessary credentials/permissions for that when I try to add my limited admin account connection in there. Also saw a database copy wizard functionality under the Tools file menu which I could use but looking to see if there are commands I can call within my own script.

Thanks.

0 投票
1 回答
28 浏览

db2 - SQL0628N 在创建表函数时使用 MODIFIES SQL DATA

我正在尝试将这里示例代码中的功能封装在一个表函数中。

我可以单独运行示例而没有任何问题。

但是当我创建一个表函数时,只需一次调用 OPEN_CURSOR ,我就会收到SQL0577N

看来,OPEN_CURSOR 要求指定 MODIFY SQL DATA.. 好的.. 走吧!但是,当我指定它时,我会收到以下错误:

-628 错误的错误详细信息过于笼统,无法帮助我确定这里到底发生了什么。

我需要使用 DBMS_SQL 模块执行动态 SQL 查询,并使用 PIPE 返回结果集,就像这里的其他示例一样。

我一整天都在阅读传播文件。到目前为止,我无法确定我到底违反了什么规则。

另外,在文档上发现了一些我不明白的不一致之处:此页面说:

  • SQL 表函数不能包含已编译的复合语句。

而来自RETURN 语句的规则则相反,并与 PIPE 示例代码匹配:

  • 在使用复合 SQL(编译)语句的 SQL 表函数中,不能指定表达式、NULL 或全查询。使用 PIPE 语句从函数返回行,并且需要 RETURN 语句作为函数退出时执行的最后一条语句 (SQLSTATE 2F005)。

感谢任何帮助!

0 投票
1 回答
31 浏览

db2 - SQL0526N 在 FUNCTION 中引用 DGTT(声明的全局临时表)时

我想从预先创建的 DGTT 返回内容作为表函数的结果集。

但是当我引用它时,我得到 SQL SQL0526N / SQLSTATE 42995 错误。

我不明白为什么。 文档只说明了 42995 sqlstate 错误的 3 个原因:

但是它们都没有被使用。这个功能非常简单:

这次我违反了什么规则?