Failure of EXECUTE IMMEDIATE when in a stored procedure
Hello,
this concerns behaviour observed in Oracle 10g on Windows.
As user "system", I execute from the command line the following:
SQL> select COUNT(1) from sys.dba_sequences;
COUNT(1)
645
Again I try the same thing from the command line:
SQL> declare
2 CNT INTEGER:=0;
3 STMT VARCHAR2(300);
4 BEGIN
5 STMT:='select COUNT(1) from SYS.DBA_SEQUENCES';
6 EXECUTE IMMEDIATE STMT INTO CNT;
7 dbms_output.put_line('CNT='||CNT);
8 end;
9 /
CNT=645
So far so good, clearly this table exists and I have sufficient privileges to access SYS.DBA_SEQUENCES as user system.
However, if I put this in a stored procedure in a script TEST_SEQ.sql and then execute, I get ORA-00942:
1. Create or replace Procedure TEST_A1
2. IS
3. CNT INTEGER:=0;
4. STMT VARCHAR2(300);
5.
6. BEGIN
7. STMT:='select COUNT(1) from SYS.DBA_SEQUENCES';
8. EXECUTE IMMEDIATE STMT INTO CNT;
9. dbms_output.put_line('CNT='||CNT);
10. END;
SQL> @ TEST_SEQ.sql
SQL> exec TEST_A1;
ORA-00942: Table or view does not exist
ORA-06512: At "SYSTEM.TEST_A1", line 8
ORA-06512: At line 1
Why now does this table not seem to exist when accessed from a stored procedure?
http://www.google.com/search?btnG=1&q=ora-0942+procedure
Sybrand Bakker
Senior Oracle DBA
Experts: those who do read documentation.
Similar Messages
-
Unable to execute EXECUTE IMMEDIATE statement in a stored procedure...
Hi People,
I use oracle 10g.In which i tried a procedure with follwing code and am thrown with the error that says,
SQL> create or replace procedure ptable(ptab varchar2) is
2 lstmt varchar(200);
3 begin
4 lstmt:='CREATE TABLE '||ptab||'(a int,b varchar2(30)) ';
5 execute immediate lstmt;
6 end;
7 /
Procedure created.
SQL> exec ptable('hos');
BEGIN ptable('hos'); END;
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "VIDYA.PTABLE", line 5
ORA-06512: at line 1Procedure has been created but error occurs while executing it.why do i get this error even though i possess DBA privilege?.which permission is lagging for me?.help me with ur suggestions.thanks in advance.
With Regards
VIDSYep Yep.Perfect.It was the CREATE ANY TABLE privilege which i was lagging.I granted it to my schema and now got created with the table.Thanku so much for such a quick reply :).
With Regards
VIDS -
Execute Immediate with SQL in Stored Procedure
Dear Experts, Please help / guide on below statement which i want to execute in stored procedure,
EXECUTE IMMEDIATE 'INSERT INTO TABLE
SELECT COUNT(AGENTID) FROM TABLE_1 A,
TABLE_2 B, TABLE_3 C
WHERE A.COL = B.COL AND B.COL = C.COL AND
DT BETWEEN TRUNC(SYSDATE-1) + 1/24 + 0/12/60/60 AND TRUNC(SYSDATE-1) + 25/24 - 0/12/60/60';
Edited by: DBA on Dec 3, 2011 3:57 PMSo what's the problem? The only thing I can see is:
INSERT INTO TABLETABLE is reserved word, so name your table differently.
Also, I am assuming the above statement is actually generated from some variables based on some conditions, otherwise why would you need dynamic SQL, just issue:
INSERT INTO TABLE
SELECT COUNT(AGENTID) FROM TABLE_1 A,
TABLE_2 B, TABLE_3 C
WHERE A.COL = B.COL AND B.COL = C.COL AND
DT BETWEEN TRUNC(SYSDATE-1) + 1/24 + 0/12/60/60 AND TRUNC(SYSDATE-1) + 25/24 - 0/12/60/60; -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
when debugging SSIS, the "Execute SQL Task" runs a stored procedure and returns the expected value. When running the package a second time, the task returns an unexpected value. When running in VS2012 SQL editor, everything operates as expected.
Please help me debug how to get the stored proc to return the same value every time the SSIS Package is run. thanks!
Here is the sequence of events and what happens....
Look for a Positor that matches the Application, Host, and User
No matching PositorId is found, Creates new Positor row, returns that new PositorId
Use PositorId to upload some data (Every thing works)
re-run/debug the ssis pacakge
Look for a Positor that matches the Application, Host, and User
<No clue what is happening>
Returns -1 (SHOULD BE the same PositorId value returned in #2)
"Execute SQL Task" Setup: No edits to Result Set nor Expressions
"Execute SQL Task" Setup: GENERAL
"Execute SQL Task" Setup: PARAMETER MAPPING
SP called by "Execute SQL Task"
CREATE PROCEDURE [posit].[Return_PositorId]
AS
BEGIN
DECLARE @PositorId INT = [posit].[Get_PositorId]();
IF (@PositorId IS NULL)
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
END;
RETURN @PositorId;
END;
Supporting SQL Objects:
CREATE FUNCTION [posit].[Get_PositorId]
RETURNS INT
AS
BEGIN
DECLARE @PositorId INT = NULL;
SELECT TOP 1
@PositorId = [p].[PO_PositorId]
FROM [posit].[PO_Positor] [p]
WHERE [p].[PO_PositorApp] = APP_NAME()
AND [p].[PO_PositorHost] = HOST_NAME()
AND [p].[PO_PositorUID] = SUSER_ID();
RETURN @PositorId;
END;
GO
CREATE PROCEDURE [posit].[Insert_Positor]
@PositorNote NVARCHAR(348) = NULL
AS
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
DECLARE @Id TABLE
[Id] INT NOT NULL
INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
OUTPUT [INSERTED].[PO_PositorId]
INTO @Id([Id])
VALUES(@PositorNote);
RETURN (SELECT TOP 1 [Id] FROM @Id);
END;
GO
CREATE TABLE [posit].[PO_Positor]
[PO_PositorId] INT NOT NULL IDENTITY(0, 1),
[PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
[PO_PositorName] NVARCHAR(256) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
[PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
[PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
[PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
[PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
[PO_tsInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_tsInserted] DEFAULT(SYSDATETIMEOFFSET()),
[PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
CONSTRAINT [UK__Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC),
CONSTRAINT [PK__Positor] PRIMARY KEY ([PO_PositorId] ASC)
GO
ssdThe error is in item 7: Returns -1 (SHOULD BE the same PositorId value returned in #2); but no error message is returned or thrown from SSIS.
The error message indicated referential integrity is not upheld when inserting records. This error message occurs AFTER the Execute SQL Task successfully completes; the E.SQL Task returns -1. The executed SQL code will not allow values less than 0
([PO_PositorId] INT NOT NULL IDENTITY(0, 1),)
[Platts Valid [41]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E2F.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description:
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PricingPlatts_Posit_PositorId". The conflict occurred in database "Pricing", table "posit.PO_Positor", column 'PO_PositorId'.".
The aforementioned FOREIGN KEY constraint is due to the value being returned by the Execute SQL Task.; therefore, the error lies in the value returned by the Execute SQL Task. -
Executing a Variable in a Stored Procedure containing an Update Statement
Hi,
I have created a Stored Procedure, it has one input parameter. Inside the Stored Procedure there are 5 other variables are declared, based on the input parameter 4 of these variables are populated.
Fifth variable is a a concatenation of text and some of these variables and creates a dynamic Update Statement. Once it is created I want to execute this variable but it is not executing.
Could someone please help me in knowing how to execute a variable within a stored procedure that contains an update statement.
Thanks for your help.
Thanks
Vineesh
vineesh1701If you have set up the variable so that it contains a valid sql update, it should work. For example, see below, which does do an update
use tempdb
go
Create Table #Test(i int);
Insert #Test(i) Values(1);
go
Create Procedure TestProc As
Begin
Declare @SQL nvarchar(250);
Set @SQL = 'Update #Test Set i = 2';
--Print @SQL;
Exec sp_executesql @SQL;
End
go
Exec TestProc
-- Test Result
Select * From #Test;
go
Drop Procedure TestProc;
go
Drop Table #Test;
One thing I would recommend while testing is that you print out or select the variable that contains the dynamic sql. (Like the above code where I have a print statement. That lets you see exactly what you are executing and if there is any problem
with the update command.
As Naomi said, to get anything more than general help, you will probably have to show us your code and the parameter values you are passing when you execute the stored proc.
Tom -
How to execute multiple queries in one stored procedure.
Hi,
I am Kumar,
How to execute multiple queries in one stored procedure.
here is the my requirements,
1. get the max value from one table and sum of the that value.
2. insert the values and also sum of the max value.
using stored procedure
I am using SQL server 2000 database.
Please help me.
Advance thanks
by,
KumarThis is not a java question and it is not even a problem: your only problem is
1) lack of knowledge
2) lack of interest to find a manual
But you are going to have to change both by actually reading a book or a manual that explains the stored procedure language of SQL Server. It is the same as Sybase I think, so you could also look for a manual for that DBMS. -
We have a Java application for which the performance is very slow. For example, one particular screen takes 16 seconds to display. When we watch the Oracle database, we find that the application is issuing 23 separate queries to populate the screen (one query per display row). This screen could grow to need more rows in which case the application has been written to issue separate queries against the database for each. What is appropriate way for the application to obtain this data? We have written a stored procedure that takes .4 seconds to provide this data. When is a stored procedure appropriate? Are there any documents regarding best practices on this issue?
Just out of interest, why avoid stored procedures at
all costs? Are you joking, or is there a valid
reason? Stored procedures are in general faster than
using Statements.One reason would be because it limits the database portability, since not all databases support them.
This is generally only a concern when writing product software for smaller companiers. Larger companies will use databases that support stored procs and are much less likely to want to migrate. And are much more likely to have DBAs who will insist on it as well. -
How to execute Operating System commands from Stored procedure.
Any help on how to execute Operating System commands from stored procedures will be appreciated.
Nanditha.Search the forums for 'External Procedure' and you will find example code that has been posted before.
-
Error when running execute immediate to create synonym in Procedure
The following command
execute immediate 'create synonym EW6379_DM.kbr_v_tag_eq_new_tags for EW6379.kbr_v_tag_eq_new_tags';
runs fine if executed outside in a Stored procedure,
but if I add this command to a Procedure will fails with error ORA-01031 insuficient Privilegies
Very strange.Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as SYS
SQL>
SQL> drop role r1;
Role dropped
SQL> drop user u1 cascade;
User dropped
SQL> create user u1 identified by u1;
User created
SQL> grant connect, resource to u1;
Grant succeeded
SQL> create role r1;
Role created
SQL> grant create any synonym to r1;
Grant succeeded
SQL> grant create any procedure to r1;
Grant succeeded
SQL> grant r1 to u1;
Grant succeeded
SQL> conn u1/u1;
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as u1
SQL> create table t(i number);
Table created
SQL> create synonym s for t;
Synonym created
SQL> create table t2(i number);
Table created
SQL> create or replace procedure p
2 is
3 begin
4 execute immediate 'create synonym s2 for t2';
5 end;
6 /
Procedure created
SQL> show err;
No errors for PROCEDURE U1.P
SQL> exec p;
begin p; end;
ORA-01031: insufficient privileges
ORA-06512: at "U1.P", line 4
ORA-06512: at line 1
SQL> conn sys/0000 as sysdba;
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as SYS
SQL> grant create any synonym to u1;
Grant succeeded
SQL> conn u1/u1;
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as u1
SQL> exec p;
PL/SQL procedure successfully completed
SQL> -
EXECUTE IMMEDIATE dynamic statement and return procedure value
Hello guys,
How can i return values from procedure using EXECUTE IMMEDIATE statment?
I made easy example:
CREATE OR REPLACE PACKAGE pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER);
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER)
IS
BEGIN
v_out:=(p_age_1+p_age_2+p_age_3)/3;
END pro_calc_average;
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER)
IS
x number;
v_sql varchar2(4000);
BEGIN
v_sql:='pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x)';
dbms_output.put_line(v_sql);
EXECUTE IMMEDIATE v_sql;
dbms_output.put_line(' ====> '||x);
END pro_calc;
END;
-- Run procedures [Faild]
EXEC pac_test.pro_calc(2,9,19);
When i run:
DECLARE
x number;
BEGIN
pac_test.pro_calc_average(2,9,9,x);
dbms_output.put_line(' ====> '||x);
END;
It's works, but this is not what i am looking for.
Thank you guys,
Sam.Hi Sam,
Like this?
CREATE OR REPLACE PACKAGE pac_test
IS
pac_var number; /* added new*/
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER);
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER);
END;
CREATE OR REPLACE PACKAGE BODY pac_test
IS
PROCEDURE pro_calc_average( p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER,
v_out OUT NUMBER)
IS
BEGIN
v_out:=(p_age_1+p_age_2+p_age_3)/3;
END pro_calc_average;
PROCEDURE pro_calc(p_age_1 IN NUMBER,
p_age_2 IN NUMBER,
p_age_3 IN NUMBER)
IS
pack_local_var number;
v_sql varchar2(4000);
BEGIN
--v_sql:='pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x)';
v_sql:=' declare x number; begin pac_test.pro_calc_average('||p_age_1||','||p_age_2||','||p_age_3||',x);
dbms_output.put_line(x);
pac_test.pac_var:=x; /* added new*/
end;';
dbms_output.put_line(v_sql);
EXECUTE IMMEDIATE v_sql;
pack_local_var:=pac_var; /* added new*/
dbms_output.put_line(pack_local_var); /* added new*/
END pro_calc;
END;Declared a package variable.
But be aware this variable is accessible to everyone and they can read or change its value if they have the right privileges.
REgards,
Bhushan -
ORA-03115 error when calling a Stored Procedure
Hi All,
I'm in the process of porting a Pro/C app from NT to Linux. I've installed 8.1.5 on our Linux box and patched it up to 8.1.5.02.
It all kind of works ok, except that I'm sometimes getting ORA-03115 errors when the app calls a stored procedure. The call in question looks like this:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR resprows[50][3998];
int numret = 0;
int numrows= 50;
int done= 0;
unsigned long resp_id = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL AT DB_NAME EXECUTE
BEGIN pkg_something.getdata(
:resp_id, /* IN */
:numrows, /* IN */
:done, /* OUT */
:resprows, /* OUT */
:numret /* OUT */
END;
END-EXEC;
The stored procedure basically uses the resp_id value to select rows from a table;
in each row there is a VARCHAR2(4000) column which it copies into the hostarray resprows.
There may be anything from 1 to numrows returned from the SP.
Initially, the resprows rows were defined to be size [4000]. Unfortunately, this caused ORA-02005 errors - I then changed the size to [3998], which seemed to fix the 02005's (although I'm unclear as to the reasons why).
Now I'm getting the 03115 errors when calling the SP. The oracle manual is not very helpful on what this error means.
This all works chipper on NT.
Any ideas?
Thanks in advance,
Nigel.
PS: The database the app is talking to is still hosted on NT.
nullHiston FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM -
Execute immediate issue while calling a procedure from plsql block
Hi all,
I have the following simple code ,my execute immediate is not working(I am pasting the error below as well)
CREATE OR REPLACE PROCEDURE CALL_RAHUL_PROCEDURES
AS
strng varchar2(1000);
BEGIN
for i in (select proc_name,flag,id from rahul_procedures order by id)
loop
if (i.flag = 'Y')
then
strng := 'exec '||i.proc_name||'(''rahul'')';
dbms_output.put_line(strng);
execute immediate strng;
end if;
end loop;
END CALL_RAHUL_PROCEDURES;
Error:
Connecting to the database INQDWD.
ORA-00900: invalid SQL statement
ORA-06512: at "ETLADMIN.CALL_RAHUL_PROCEDURES", line 17
ORA-06512: at line 2
exec RAHUL_HELLO_WORLD2('rahul');
Process exited.
Disconnecting from the database INQDWD.
data in rahul_procedures table :
Proc_name flag Id
RAHUL_HELLO_WORLD N 1
RAHUL_HELLO_WORLD2 Y 2
RAHUL_HELLO_WORLD N 3
RAHUL_HELLO_WORLD3 N 4
please help.
Regards
RahulMac_Freak_Rahul wrote:
Well I have to call 26 procedures one by one and the names of the procedures would be in a table'rahul_procedures' Which is 100% wrong.
Data is stored in tables, program code is stored in procedures or view defintions.
http://en.wikipedia.org/wiki/Data_%28computing%29
>
Data vs programs
Typically, different files are used to store programs vs data. Executable files contain programs; all other files are data files.
>
So you have just violated the primary distinction between data and program code.
I dont find anything strange in my question,Only because you do not appear to know what you are doing or the difference between data and program code.
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:1943344500346351703
>
ugh, what an ugly "design". I can see your life will be full of performance issues, strange 'bugs', and other unpleasant side effects. I mean, it all looks "so cool", but it'll be a nightmare to maintain and enhance.
but then you have the issue of binds, which will be intractable. You'd have to know the binds at compile time, but you have hidden all of your sql in a magic generic table - so you cannot possibly know your binds at compile time.
I would suggest you discard all of this code (I am DEAD SERIOUS) and start over. This is a bad idea from the get go. Or at least do me a favor and do not use plsql (you make it look like a good database implementation, but it isn't)
The objective here is to store SQL Statements in a Table(a sql repository) and just call the required SQL from the application using the sqlid using the sql_execute procedure. ...
CHANGE YOUR OBJECTIVE.
How about this for a good objective:
the objective here is to store sql statement in a plsql routine (a sql repository, you call a procedure and we run sql) and just call the required sql form the applicatoin using the STORED PROCEDURE
sorry, can I think of hacks to get you going? yes, application contexts come to mind - a fixed number of binds comes to mind. Am I going to work them out? No - it is the wrong way to approach a database application. -
PLS-00201 error occurs when batching a stored procedure in SQL*Plus
I have a batch file to run a stored procedure and spool the results to file. When I enter the commands manually in sql*plus the output works fine and my results are spooled to the output file. But when I run the same commands in the batched script I get an error.
Any ideas?
Stored Procedure:
create or replace procedure MMP( p_cursor in out SYS_REFCURSOR)
as
begin
open p_cursorfor select name, id from table;
end;
batch file 1:
sqlplus -S user/pw@REPORTDV @sp_output_spooled.sql
script file sp_output_spooled.sql
Pasting these commands directly to the SQL*Plus command prompt spools the result set to file as expected.
set colsep '|'
set echo off
set feedback off
set termout off
set heading off
set linesize 9000
set pagesize 0
set trimspool on
set headsep off
spool output.TXT
var rc refcursor
execute MMP(:rc)
print rc
spool off
exit
The errors printed to output.TXT file after the batch is run and error occurs:
BEGIN MMP(:rc); END;
ERROR at line 1:
ORA-06550: line 1, column 8:
PLS-00201: identifier 'MMP' must be declared
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
ERROR:
ORA-24338: statement handle not executed
SP2-0625: Error printing variable "rc"Hi,
Your code worked fine for me.
Is MMP procedure owned by the same user that is running the batch file or does it have proper privileges and synonym?
vr,
Sudhakar -
User can Execute SQL Statement but not Stored Procedure
I have a function in Access that calls a stored procedure to update a table. When I run it, it works fine but when the users try to run it, they get an error.
If I change it run the actual SQL syntax that is in the stored procedure then the users can run it and update the table without any problems, which makes no sense to me. It's doing the same exact thing as the stored procedure. I'd much rather have them be
able to run the procedures then writing the SQL in VBA modules because that's going to end up being a lot of code.
Any idea on why it's like this and how to correct it? Any assistance would be appreciated.Hello,
When you give a user permission to run a stored procedure, everything on that procedure but Dynamic SQL will be executed
without evaluating user permissions on the objects the stored procedure deals with.
On the link I provided above, you will see how to provide permissions to stored procedures. Try creating database roles, add user to database roles, then assign permissions to database roles.
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com
Maybe you are looking for
-
My ON OFF button on the phone does not work. And my phone is warranted. What should I do?
-
System Variable not display properly
when i go sales>sales report> backorder report there is a feild for an example custoer name and i need to fetch this feild on PLD report but when i want to see the varible name it is not showing properly . screen short is attached for ur reference ec
-
Re: The country is not listed
same prob. here also i really want to get in skype bt my country INDIA is not listed
-
Safari 4.0.3 ate half my bookmarks
Once I downloaded Safari 4.0.3 my subfolders within my bookmarks vanished completely. When I go to "Show my bookmarks" I can only see the "loose" links I previously created ("loose" meaning those that were never placed within the subfolders). Hundred
-
Not compatible with OS X 10.5.8 on pre-Intel processor
I downloaded Firefox and when I tried to open it a message said it was not compatible with this architecture. I am running on a Mac mini with a pre-Intel processor and OS X10.5.8