愿所有的美好和期待都能如约而至

“无法在查询中执行 DML 操作"的解决方案?

发布时间:  来源:互联网  作者:匿名  标签:error Solution to "cannot perform a DML operation inside a query&am  热度:37.5℃

本文介绍了“无法在查询中执行 DML 操作"的解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用数据分析工具,我的要求是接受来自用户的值,将其作为参数传递并将其存储在表中.很直接,所以我坐下来写这个

I am using a Data Analysis tool and the requirement I have was to accept a value from the user, pass that as a parameter and store it in a table. Pretty straighforward so I sat to write this

create or replace
procedure complex(datainput in VARCHAR2)
is
begin
insert into dumtab values (datainput);
end complex;

我在 SQL Developer 中使用以下语句执行了此操作

I executed this in SQL Developer using the following statement

begin
complex('SomeValue');  
end;

它工作正常,并且值被插入到表中.但是,数据分析工具不支持上述语句,因此我使用函数代替.以下是该函数的代码,它编译.

It worked fine, and the value was inserted into the table. However, the above statements are not supported in the Data Analysis tool, so I resorted to use a function instead. The following is the code of the function, it compiles.

create or replace
function supercomplex(datainput in VARCHAR2)
return varchar2
is
begin
insert into dumtab values (datainput);
return 'done';
end supercomplex;   

我再次尝试在 SQL Developer 中执行它,但是我在执行以下代码时无法在查询中执行 DML 操作

Once again I tried executing it in SQL Developer, but I got cannot perform a DML operation inside a query upon executing the following code

select supercomplex('somevalue') from dual;

我的问题是- 我需要一个可以在 SQL Developer 中运行上述函数的语句或- 一个可以执行我正在寻找的可以由 select 语句执行的函数.- 如果无法执行我要求的操作,我需要一个原因,以便我可以通知我的经理,因为我对 PL/SQL 非常陌生(比如一个星期大?),所以我不了解规则和语法.

My question is
– I need a statement that can run the mentioned function in SQL Developer or
– A function that can perform what I am looking for which can be executed by the select statement.
– If it is not possible to do what I’m asking, I would like a reason so I can inform my manager as I am very new (like a week old?) to PL/SQL so I am not aware of the rules and syntaxes.

附言我多么希望这是 C++ 甚至是 Java

勇敢去编程!

勇敢的热爱编程,未来的你一定会大放异彩,未来的生活一定会因编程更好!

TOP