Oracle stored procedures are as follows:
create or replace procedure pro_demo
is
begin
select * from k_cicpa;
end
Error message:
> ORA-24344: success with compilation error
In SQL, the stored procedure exEC displays the query results normally, as shown below.
--drop PROCEDURE pro_demo
create procedure pro_demo
as
begin
select * from k_cicpa;
end
exec pro_demo;
This is the first time I have been exposed to Oracle stored procedures
Reason for error:
Oracle stored procedures cannot be written in such a way as to write simple SELECT… The from… This is different from SQL Server
--Either write
select field into variable from student;
--either written as
execute immediate 'select * from student;'
--either store with a cursor
process is in the form of selet col into v_col from tb
--Change it to look like this.
create or replace procedure p1
as
v_sql varchar2(4000);
begin
v_sql:='select * from xs';
execute immediate v_sql;
end;
Execute IMMEDIATE: Used in a stored procedure. Dynamic execution of SQL statements, such as using local dynamic SQL to execute DDL statements dynamically based on table names entered by the user and parameters such as field names, field types, etc.
create or replace procedure proc_test
(
table_name in varchar2,
field1 in varchar2,
datatype1 in varchar2,
field2 in varchar2,
datatype2 in varchar2
) as
str_sql varchar2(500);
begin
str_sql:='create table '||table_name||'('||field1||' '||datatype1||','||field2||' '||datatype2||')';
execute immediate str_sql;
exception
when others then
null;
end ;
Read More:
- SQL Server calls Database Mail to send mail error: Msg 229, Level 14, State 5, Procedure sp_send_dbmail, Line 1 EXECUTE
- DB2, create stored procedure error, sqlcode = – 104, sqlstate = 42601, PSM_ semicolon
- How to debug stored procedure/function in TOAD
- How to call stored procedure in Hibernate
- DB2 timed task execution stored procedure cannot complete scheduler thread’s initialization
- Slim error “failed to execute login command”
- Failed to create Oracle Oracle home user solution appears in oracle12c installation
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0
- SVN: Please execute the ‘Cleanup‘ command.
- The solution of PL / SQL can’t connect to the remote server after installing Oracle locally
- How to Solve Error: Failed to execute goal org.codehaus.mojo:……..
- Oracle login error: Oracle error 6 initializing SQL * plus (normal before)
- How to execute Makefile
- Springbatch failed to execute commandlinerunner
- The problem encountered in pyinstaller packaging “failed to execute script × *”
- UnhandledPromiseRejectionWarning: MongoError: not authorized on elm to execute comman
- How to Fix Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
- 解决Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile
- Mac ports installation software prompts “warning: xcodebuild exists but failed to execute”
- Failed to execute goal