简体   繁体   English

如何在 Oracle 中重新创建 SAP 查询?

[英]How to recreate SAP queries in Oracle?

I need to recreate some SAP stored procedures in Oracle.我需要在 Oracle 中重新创建一些 SAP 存储过程。 I've been trying to find tutorials, similar questions, examples, etc about this but apparently no one had to do this before我一直在尝试寻找有关此的教程、类似问题、示例等,但显然之前没有人必须这样做

What Oracle SQL query can be similar to this SAP query ?什么 Oracle SQL 查询可以与此 SAP 查询相似?

SELECT * FROM A
 INTO CORRESPONDING FIELDS OF TABLE B
 FOR ALL ENTRIES IN C
 WHERE a = C-a
 AND x = y.

 LOOP AT B INTO D.
   D-b = E-b.

 INSERT c FROM D.
 IF SY-SUBRC <> 0.
   WRITE: / 'error on insert', D-b, D-a.
 ENDIF.

Any help will be appreciated, Thanks.任何帮助将不胜感激,谢谢。

I recommend you to use transaction 'ST05' to trace your program.我建议您使用事务“ST05”来跟踪您的程序。 This tool will show details of the queries on the database including the exact SQL executed.此工具将显示数据库查询的详细信息,包括执行的确切 SQL。

EDIT: As a demonstration of the queries generated by SAP for Oracle let's execute this code and trace it with transaction 'ST05'.编辑:作为 SAP 为 Oracle 生成的查询的演示,让我们执行此代码并使用事务“ST05”跟踪它。 Remember to run 'ST05' before executing the program.请记住在执行程序之前运行“ST05”。

tables: mara.
data: it_mara type standard table of mara,
      it_eina type standard table of eina.

select-options so_matnr for mara-matnr.

start-of-selection.

select matnr from mara into corresponding fields of table it_mara 
up to 100 rows where matnr in so_matnr.

check sy-subrc eq 0.

select * from eina into table it_eina for all entries in it_mara
  where matnr eq it_mara-matnr.

After execution check the output in transaction 'ST05':执行后检查交易“ST05”中的输出:

在此处输入图片说明

If you want more details select an SQL statement in the screen and then click the button 'Explain'.如果您想了解更多详细信息,请在屏幕中选择一条 SQL 语句,然后单击“解释”按钮。 You will see the following:您将看到以下内容:

在此处输入图片说明

For better reference on transaction 'ST05' check this link .有关交易“ST05”的更好参考,请查看此链接

Hope it helps.希望能帮助到你。

The FOR ALL ENTRIES statement usually produces many queries which results are then grouped by UNION or UNION ALL . FOR ALL ENTRIES语句通常会产生许多查询,然后将结果按UNIONUNION ALL分组。

Here is a really nice analysis for Microsoft SQL Server. 是对 Microsoft SQL Server 的非常好的分析。

Because of the fact that UNION and UNION ALL are part of SQL standard I think it is implemented exactly the same for any other SQL database.由于UNIONUNION ALL是 SQL 标准的一部分,我认为它对任何其他 SQL 数据库的实现完全相同。

[EDIT] [编辑]

As Mr Miranda stated it looks differently when it comes to Oracle database.正如 Miranda 先生所说,在 Oracle 数据库方面,情况有所不同。 I googled a bit and found this article where it is said that IN-LIST s are used which seems also to be plausible.我用谷歌搜索了一下,发现这篇文章说使用了IN-LIST ,这似乎也是合理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM