Execute a precedure in some procedure
Hello expert,
Can I execute a precedure in some procedure?
Many Thanks,
My point is:
How can one use 'precedure' and 'procedure' in one subject line and post it, without noticing?
Yes, that awakes the nit-picker in me {noformat};){noformat}
Usually I'll ignore a typo, but not always.
If you don't spell a SQL or PL/SQL statement correctly, then the compiler will warn you.
But when you write human language, there's no compiler to warn you and you might look silly (happened to me more than once) to other humans, regardless of your intentions.
Anyway, since all who replied before me already pointed OP to the right answer, I just wanted to go a little more in-depth.
Let's not forget that one of the purposes of calling a procedure from another procedure is modularization.
I am saying that you only caught such a small mistake.Small mistakes can have big consequences.
It doesn' matter if it is a coding mistake, or a spelling mistake.
Finding the right syntax or words is sometimes hard enough already {noformat};){noformat}
Similar Messages
-
How to create and execute PL/SQL program or Procedure from Java (JDBC)
hi all,
user will enter the Pl/Sql program from User-Interface. that program has to be create in DB and execute that.
due to some confusions, how to execute this from Java, i (user) entered the same logic through a Procedure.
my Java code is
Statement st = con.createStatement();
Statement.execute(procedure_query); // procedure name is myPro
CallableStatement cs = con.prepareCall("{call myPro}");
(as given in SUN docs - http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html)
but its not creating the procedure.
and i tried to run a procedure (which is already created) with CallableStatement, and this is also not working.
how to get this.
thanks and regards
pavanHi,
SInce the PL/SQL block is keyed in dynamically, you probably want to use the anonymous PL/SQL syntax for invoking it:
// begin ? := func (?, ?); end; -- a result is returned to a variable
CallableStatement cstmt3 =
conn.prepareCall(“begin ? := func3(?, ?); end;”);
// begin proc(?, ?); end; -- Does not return a result
CallableStatement cstmt4 =
Conn.prepareCall(“begin proc4(?, ?); end;”);
SQLJ covered in chapter 10, 11, and 12 of my book furnish a more versatile dynamic SQl or PL/SQL mechanisms.
Kuassi
- blog http://db360.blogspot.com/
- book http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html -
How to execute .sql file in Stored Procedure?
Hi,
I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
This .sql file will have set of update statement. I need to pass value to this update statement.
Kindly please help me.
Regards,
IrfanThis is required as part of Data Migration where i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
How have you determined that it's "better" to have seperate scripts? I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
Question: Why do you have tables with different names that all need the same process doing to them?
Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
e.g.
create procedure update_table(tbl_name varchar2) is
begin
execute immediate 'update '||tbl_name||' set lastupdate = null';
end;
As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer. Please do take the time to read the FAQ and post appropriate details so people can help you. -
How to execute unix command from ODI Procedure
Hi,
I am trying to execute below unix command from ODI Procedure (Command on Target tab) but I am getting the error "java.io.IOException: Cannot run program "cd": error=2, No such file or directory" but when I try to execute the same command using OdiOSCommand, it is executing successfully. I don't want to use shell script to execute this command. Is there any specific syntax am I missing to execute this command from ODI procedure?
cd /project3/tmt/;ls *.dmp > dmplist.lst
Please help me on this...
Thanks
MTHi nahlikh,
Thank you for the reply.
I used below command in Procedure but still getting the same error as "java.io.IOException: Cannot run program "OdiOSCommand": error=2, No such file or directory".
OdiOSCommand "-COMMAND=cd /project3/tmt/;ls *.dmp > dmplist.lst"
as I mentioned earlier if I use the command cd /project3/tmt/;ls *.dmp > dmplist.lst in OdiOSCommand tool it is executing successfully without any issues.
any thoughts appreciated to get a solution for this issue.
Thanks
MT -
Problem with execute SSIS package from stored procedure
Hi,
I would like to execute SSIS package from stored procedure. Therefore, I implemented sp which exec SSISDB.CATALOG.CREATE_EXECUTION method. When I try to test it from SSMS on remote server, I got error that
I was able to solve by adding “WITH EXECUTE AS …”. Then I got another error: The server principal "Domain\user" is not able to access the database "SSISDB" under the current security context. On Internet, I found a couple post that describe
how to access SSIS catalog (one of them by Ke Yang -
http://blogs.msdn.com/b/mattm/archive/2012/03/20/ssis-catalog-access-control-tips.aspx). It didn’t help. I’m still getting the error message.
How to debug this issue?
Any suggestion?
Thanks
SQL Server 2014 BISSMS does not propagate user credentials thus the error
Arthur
MyBlog
Twitter -
Can I execute a scenario from a procedure?
Can I execute a scenario from a procedure? I know I can execute scenarios from the command line. I was hoping to avoid that since I need my job to run in multiple envirnoments and may not reliably know where STARTSCEN is located or if it will always work. Basically, I would like to execute several jobs multiple times, depending on values in a table that will be changed between runs.
Hi,
Yes you can exetute an ODI scenario from an ODI procedure.
Technology for that procedure will be Sunopsis API
code OdiStartScen "-SCEN_NAME=<scenario name>" " -SCEN_VERSION=<scenario version>" "-CONTEXT=<context code name>"
Thanks,
Sutirtha -
Issue with Executing OS commands from Stored Procedure
I am trying to execute the scripts provided at :
http://github.com/xtender/XT_SHELL
provided by xtender user.
As required, I have asked my DBAs to grant privileges by executing the following scripts:
Begin
--change to needed permissions and execute
dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/factiva/ODS/bin/CVIM_Rpt_ExportCSVFile’, 'read,write,execute' );
end;
/where CVIM_Rpt_ExportCSVFile is my script residing in the Unix server where my Oracle is installed.
The error I am facing when I try to execute the following command is:
select * from table(xt_shell.shell_exec('/var/scripts/CVIM_Rpt_ExportCSVFile',100))
Exception:the Permission (java.io.FilePermission /var/scripts/CVIM_Rpt_ExportCSVFile execute) has not been granted to ODS. The PL/SQL to grant this is dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )I have asked my DBA to also execute the following scripts: - But I still see the same error as above. I am not able to figure out whats going on. Can anyone pls help me out??
EXEC Dbms_Java.Grant_Permission('ODS', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC Dbms_Java.Grant_Permission(ODS', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
dbms_java.grant_permission( 'ODS', 'SYS:java.io.FilePermission', '/var/scripts/CVIM_Rpt_ExportCSVFile', 'execute' )DUPLICATE
===============================================================
Issue with Executing OS commands from Stored Procedure
============================================================== -
Executing OS command from sql procedure
i want to execute an OS command from the procedure, can i do this way? looks like it is not executing the command move....
declare
begin
dbms_output.put_line(' moving...');
host;
move c:\file1\test.txt C:\moved
exit;
/True. But that job is going to run in a separate session, some time after the current transaction commits (depending on the number of jobs queued up to run). So if you need to pass information back from the job, or you want the procedure to handle exceptions thrown by the job, or you want to tie job related failures back to a particular application level event, or you want the rest of your procedure to wait for the operating system command to finish, using the DBMS_SCHEDULER for this sort of thing is going to require a fair amount of additional coordination/ monitoring/ infrastructure code. It's certainly not a Herculean task to write that additional code, and it's reasonable in some situations, but the Java stored procedure approach strikes me as substantially easier to deal with in most cases.
Justin -
Unable to Grant execute permissoin for all Stored Procedures.
Hi,
We have a DB called ABC, which has two schema of it ABC_DEV and ABCR1.
there are 2 login users (userdev for ABC_DEV) and (userR1 for ABCR1).
I careated a package and some stored procedure with userR1 for schema ABCR1.
Now I want these package and stored procedures to be available for execution for userdev.
How to do this usegin Oracle SQL Developer.
Thanks in AdvanceConnect as ABCR1, or any other user that has GRANT EXECUTE privilege with the ADMIN option on the objects in the schema and select the object in the connections tab and right-click on it, select grant and then select the appropriate user and privilege.
Chris -
EXECUTE sql file in an procedure,just like sql prompt.
Hi,
I am using ORACLE 11g on an AIX box.
Just to explain first :- Assume we have an .sql file in which i have 20 DML statements. Like 10 inserts,5 updates and 5 deletes. Now if i want to run this file in any particular DB , the best thing for one file i can do is .. simply go to the prompt i.e. SQL> on that DB and run that file :-
SQL>@/oracle/scripts/metadata_update.sql
just this will execute the whole file. Also here i can spool and keep the log of execution.
Now i want the same functionality but this time their are many files and and i have to run them on different DB's.
Can anyone suggest me some code in which if i pass the filename and the DB's name .. it should execute in that DB and create a log file in the same directory as the sql file.
Something like procedure, which will take file name and DB name as parameter
and then we will read file using UTL_FILE
and then go to the destination DB with the help of TNSENTRIES we have.
execute it and store the log for the same.
Please suggest some sample code or ideas.
thanks in advance.VIRU wrote:
Our team gets those scripts on regular basis. We need to apply them on different DB's around 4 of them.
So i wanted a utility by which i can apply it from one procedure.PL/SQL is wrong tool for this job.
When your only tool is a hammer, all problems are viewed as nails.
While a hammer is a GREAT tool, it is suboptimal to divide 1 board into 2 pieces
sqlplus user/pass@remote1 @new_script.sql
sqlplus user/pass@remote2 @new_script.sql
sqlplus user/pass@remote3 @new_script.sql
sqlplus user/pass@remote4 @new_script.sql -
How to execute a statement in forms procedure like SQL EXECUTE IMMEDIATE
Hi to all,
In a form I have created this procedure:
PROCEDURE insert_rows (
tbName IN VARCHAR2,
list_of_fields IN VARCHAR2,
origin_table IN VARCHAR2,
wCondition IN VARCHAR2 DEFAULT NULL)
IS
where_clause VARCHAR2 (2000) := ' WHERE ' || wCondition ;
table_to_fill VARCHAR2 (30);
BEGIN
-- Exist the table ?
SELECT OBJECT_NAME INTO table_to_fill FROM USER_OBJECTS
WHERE OBJECT_NAME = UPPER(origin_table) AND OBJECT_TYPE = 'TABLE' ;
IF wCondition IS NULL THEN
where_clause := NULL;
END IF ;
EXECUTE IMMEDIATE 'INSERT INTO ' || table_to_fill || ' SELECT ' || list_of_fields || ' FROM ' || origin_table || where_clause ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
-- Here the Alert
END;
But, when I compile this error is displayed:
Function not supported from client side application corresponding to SQL statement EXECUTE IMMEDIATE
How can to correct this script for my form ?
I hope in Your help.
Best Regards
GaetanoYou have two options:
1)To create this procedure in database
2)Yo use the forms built-in FORMS_DDL instead of execute immediate , altering the one provided
Sim -
How to execute commit statement in a procedure optionally?
We have a procedure which has DML operations and at the end there is a commit statement.
I want to execute commit statement optionally.
Like, when procedure runs directly it must execute commit statement, but when this procedure is called from a trigger don't run commit.
As you know commit operation is not allowed in triggers.
How can I understant the code is triggered from a trigger or any other (manuel exec or from another procedure).
I am looking for the reserved word that solve my problem. Like INSERTING, DELETING ....
Serkan
Thanks.Hi oraserkan,
You do of course know it's dangerous to have a commit inside a procedure?
Consider this:
SQL> create table t (text varchar2(25))
Table created.
SQL> create or replace procedure p
as
begin
insert into t(text)
values ('Insert PROCEDURE');
commit;
end p;
Procedure created.
SQL> insert into t(text)
values ('Insert SQL')
1 row created.
SQL> exec p
PL/SQL procedure successfully completed.
SQL> rollback
Rollback complete.
SQL> select * from t
TEXT
Insert SQL
Insert PROCEDURE
2 rows selected.You should instead clearly state the procedure has a commit by making it autonomous, and then have two procedures, one that commits, and one that don't
SQL> drop procedure p
Procedure dropped.
SQL> drop table t purge
Table dropped.
SQL> create table t (text varchar2(25))
Table created.
SQL> create or replace procedure p_transactional
as
begin
insert into t(text)
values ('Insert PROCEDURE');
end p_transactional;
Procedure created.
SQL> create or replace procedure p_autonomous
as
pragma autonomous_transaction;
begin
p_transactional;
commit;
end p_autonomous;
Procedure created.
SQL> insert into t(text)
values ('Insert SQL')
1 row created.
SQL> exec p_autonomous
PL/SQL procedure successfully completed.
SQL> rollback
Rollback complete.
SQL> select * from t
TEXT
Insert PROCEDURE
1 row selected.
SQL> drop procedure p_transactional
Procedure dropped.
SQL> drop procedure p_autonomous
Procedure dropped.
SQL> drop table t purge
Table dropped.Regards
Peter -
Problem wile EXECUTE IMMEDIATE DDL statement in procedure
Hi ,
This is my procedure and it's getting compiled but while executing procedure getting this error,
can anyone please tell me how to fix this?
create or replace procedure construct_Table (name_table IN VARCHAR2)
IS
v_tab_name varchar2(40):=NULL;
v_sql_Stmt varchar2(32767) := NULL;
finalquery varchar2(32767) :=NULL;
cursor tp is
select COLUMN_NAME,DATA_TYPE,DATA_PRECISION,CHAR_LENGTH from all_tab_cols where table_name=name_table;
BEGIN
begin
select TABLE_NAME into v_tab_name from user_tables where table_name=name_table;
EXCEPTION
WHEN no_Data_found
THEN
DBMS_OUTPUT.PUT_LINE('No such table exist');
end;
if(v_tab_name IS NOT NULL)then
finalquery := 'CREATE TABLE '||v_tab_name||'_DUMMY (';
FOR I IN tp LOOP
if(I.data_type='VARCHAR2') then
v_sql_stmt := finalquery ||I.column_name||' '||I.data_type||'('||I.char_length||') ';
elsif(I.data_type='NUMBER') then
v_sql_stmt := finalquery ||I.column_name||' '||I.data_type||'('||I.DATA_PRECISION ||') ';
else
v_sql_stmt := finalquery ||I.column_name||' '||I.data_type ;
end if;
finalquery := v_sql_stmt || ',';
END LOOP;
finalquery := SUBSTR(finalquery,1,LENGTH(finalquery) - 1)||')';
dbms_output.put_line(finalquery);
EXECUTE IMMEDIATE'grant create any table to cmsuser';
EXECUTE IMMEDIATE finalquery;
end if;
END;
/This is the error I am getting
Error starting at line 1 in command:
begin
construct_Table ('EMP');
end;
Error report:
ORA-01031: insufficient privileges
ORA-06512: at "CMSUSER.CONSTRUCT_TABLE", line 30
ORA-06512: at line 2
01031. 00000 - "insufficient privileges"
*Cause: An attempt was made to change the current username or password
without the appropriate privilege. This error also occurs if
attempting to install a database without the necessary operating
system privileges.
When Trusted Oracle is configure in DBMS MAC, this error may occur
if the user was granted the necessary privilege at a higher label
than the current login.
*Action: Ask the database administrator to perform the operation or grant
the required privileges.
For Trusted Oracle users getting this error although granted the
the appropriate privilege at a higher label, ask the database
administrator to regrant the privilege at the appropriate label.Thanks ,
Deekay.Deekay,
If you grant create table privilege and create table in the same procedure, then how you will differentiate that which user you granted the privilege and in which schema, you are creating the table. Here, you are granting to "cmuser", but in the same schema, you are creating the table also. How can a user grant privilege to himself?
Login as DBA, grant create any table privilege to "cmuser" from dba. Then, you can execute you procedure in "cmuser" schema. -
Execute Dynamic SQL statement using procedure builder
i want to execute a dynamic SQL statment using procedure builder not using forms
because my statement depending on a variable table name
i know that i can do that from forms using
FORMS_DDL('SQL_STAT');
but i wanna to use the procedure builder
which function i should use and how?
please explain in example if you don't mind.
thanksHi,
You can very well use DBMS_SQL Package supplied by Oracle for doing this.
Search for DBMS_SQL in OTN. You will get all info regarding this.
Regards.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by itslul:
i want to execute a dynamic SQL statment using procedure builder not using forms
because my statement depending on a variable table name
i know that i can do that from forms using
FORMS_DDL('SQL_STAT');
but i wanna to use the procedure builder
which function i should use and how?
please explain in example if you don't mind.
thanks<HR></BLOCKQUOTE>
null -
Execute report from pl/sql procedure
hi all
please, can i know whether there's any way to execute a report from pl/sql stored procedure??
thank you.Hallo,
usually you would use 21.1 The Event-Driven Publishing API
You can search the forum for examples Google: site:forums.oracle.com call report from pl/sql
Regards
Marcus
Maybe you are looking for
-
Help comparing the value of a button using the Property Node (I get a variant)
Dear Sirs: (I'm using LabView 6. I guess the solution is different for 6.1) Currently I have created an array of Boolean RefNums (which point to many, many buttons). When I need to know when any (and which) of the buttons was pressed I just compare e
-
I can't switch in Shuffle Off mode iTunes 11.1.3 (8)
I can't switch in Shuffle Off mode iTunes 11.1.3 (8) - its not work now
-
Download of Lion is paused and won't resume
I've just bought a new MacBook Pro. I went to Apple's site and got my free code for Lion. I typed it in and the Lion icon leapt across to my Dock. (I have not migrated data from my previous MacBook Pro: this new one has no added files/apps yet.) Afte
-
For some reason Openoffice.org will crash if I try to do something with it. Starting it with command 'soffice' from terminal window will display empty window (as expected, some menus, some buttons), but I can't push any button or open any menu - it w
-
Button click in AFD on Glassfish does nothing
HI. I am on Jdev 11g R3 (11.1.2.3) I developed an application that is deployed into ADF jar file In other application I include this jar into application and drag and drop the task-flow from the jar into the page. I have a button in the view in the