Problem in framing a query in stored procedure
I have problem in framing a query string.
This query contains a link (ie hyperlink). In this i have to add single quotes and double quotes in the middle. I dont know how to frame this query. I am sending this query. I am getting an error message "missing double quotes in the expression". So kindly frame this query.
Thanks in advance.
Here is my query
sql_Query := 'SELECT DISTINCT(topic_name) TOPIC,course_title TITLE,'||'''''||course_description||'||
'''''"Description",'||'''COURSE''"ModuleName"'||
' FROM V_COURSE '||' WHERE COURSE_ID IN('||'''NOTHING'''||')';
Don't try to write a query like this in one time. Do it step by step (adding the next string every time), print the result with dbms_output.put_line, and see at which point the error occurs.
Similar Messages
-
Hi
I am using oracle 10g R2 and i am wondering if there is any way which i can query a stored procedure.
lets say have this table
EMP
1
2
3
and i want from a stored procedure to return all this values
like
select * from stored_proc;
is this possible in any way?
thx
Doronthe idea behind all this mess is because we have a hierarchic query which gets parameters to query by.
i thought of creating a view but then i colud not pass the parameters to it.
if no solution will be found i will have to change the code but we prefer to try and find this kind of solution
Doron -
Failed to retrieve all the results. Try running the query or stored procedure again
I have a Product table in Azure SQL Database. I can't open data in Product table. I got an error message like this.."Failed to retrieve all the results. Try running the query or stored procedure again". In my Database
all tables showing their data expect Product table. Please let me know why only Product table showing error message. Thanks in Advance.Hi,
I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience
As this requires an expert advice, I suggest you to open a support case and our experts would be able to assist you further.
http://support2.microsoft.com/common/international.aspx?RDPATH=%2fdefault.aspx%3fid%3dfh%253ben-us%253bofferprophone
Girish Prajwal -
Cursor with nested query in stored procedure problem
Hello
I'm trying to declare the folowing (example) cursor in a stored procedure in Oracle 8i:
CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
The nested part "(SELECT d.DUMMY FROM dual)" is not alowed, while the same query runs outside the stored procedure. Can someone explain why this is not alowed and how to solve the problem whitout rewriting the query?
TomWhen i run the same code in SQL plus:
SQL> declare
2 CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
3 begin
4 null;
5 end;
6 /
CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
FOUT in regel 2:
.ORA-06550: line 2, column 36:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
ORA-06550: line 2, column 66:
PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
; return returning and or
Different versions of Oracle? -
Problem with JDBC results calling simple stored procedure in VC 7.0
Hi all,
I am building a simple VC model which calls a stored procedure on a JDBC database. I have created the system in the portal, defined the alias and user mapping, the connection test is fine and the VC "find data" lists my bespoke stored procedure.
The stored procedure is :
CREATE PROCEDURE dbo.dt_getBieUsers
AS
select * from dbo.emailuserlink
GO
When I test it using query analyser, it returns 3 records each with the two fields I expect - user and email address.
I drag the model onto the workspace in VC and create an input form ( with just a submit button ). i drag the result port out to create a table. This has no fields in it.
I build and deploy as flex and the app runs, I click the submit button and SUCCESS! I get 3 records in my table each with 2 fields. The data is all correct. The problem with this is the fields are determined at runtime it seems.
I go back to the table and add 2 columns "email" and "address".
i build and deploy and run the app. Again I get 3 records, but this time the contents of all of the rows is not data, but "email" and "address". The data has been replaced by the header texts in all of the rows.
Can anyone help? Why isn't the data being put in my columns as I would expect?
I tried to build and deploy the app as Web Dynpro rather than Flex to see if it was a bug in Flex. The application starts but when I click the submit button to run the JDBC stored procedure I get a 500 Internal Server Error
com.sap.tc.wd4vc.intapi.info.exception.WD4VCRuntimeException: No configuration is defined for the entry JDBCFunction
at com.sap.tc.wd4vc.xglengine.XGLEngine.createComponentInternal(XGLEngine.java:559)
at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstanceFromUsage(XGLEngine.java:362)
at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstance(XGLEngine.java:329)
at com.sap.tc.wd4vc.xglengine.wdp.InternalXGLEngine.getCompInstance(InternalXGLEngine.java:167)
at com.sap.tc.wd4vc.xglengine.XGLEngineInterface.getCompInstance(XGLEngineInterface.java:165)
The JDBC connection I am using has a connection URL of jdbc:sap:sqlserver://localhost;DatabaseName=BIEUSERS
and a driver class of com.sap.portals.jdbc.sqlserver.SQLServerDriver
Can anyone solve my wierd problems?
Cheers
RichardHi Richard,
After you drag and drop the data service, right click on it and choose "Test data service". Then click on "Execute" and after you see the result on the right, click on "Add fields" button (inside the same window). Now you'll see that the fields are on the tabel. This is required only for JDBC data services, since this data (how the resultset is built) is not know in DT and it needs to be run firest - then analysed and only then you have to add the fields to the table).
Regards,
Natty -
Query in Stored Procedure accessing another schema
Hi - this is going to sound kind of strange and even i can't come up with an explanation. My JDK 1.1.7 applet uses a type 4 JDBC thin driver (i think v 8.04.06) to access an Oracle 7.3.4 database. We also have a link with full grants and synonymns to another Oracle schema in an Oracle 8 database. Has never been a problem - we can access anything we need to through queries or stored procedures from either of these databases.
So, i have a new stored procedure that needs to be called through JDBC that queries a table in the Oracle 8 database. For some reason, whenever i execute this stored procedure from java it hangs on this query and the instance needs to be restarted. If i execute that same stored procedure from SQL Plus, it runs fine.
I tried a little test. I put a straight query in my java code that goes directly to that table (no stored procedure involved). It runs great through java!
is this weird or what? my dbas have checked out all privelages and it seems that i have access to everything i could possibly need.
If anyone has any suggestions i would love to hear them.
thanks for your help...
Lori - [email protected]
nullYou can only access an object in another user's schema if you either:
(a) Specify the 'other' schema name explicitly: SCHEMA.OBJECT
(b) A synonymn has been created to access the object: CREATE SYNONYM OBJECT FOR SCHEMA.OBJECT.
The user requiring the synonym should create it, or the user owning the object can create a PUBLIC synonym, if they have the authority.
To check my hypothesis, try typing 'DESCRIBE procedure_name' from SQL*Plus as both users. -
Problem while running the report from stored procedure
Hi,
I using stored procedure to generate my report.
my stored procedure's code looks like this.
CREATE OR REPLACE PROCEDURE PROJECTOVERVIEWREPORT1(query in VARCHAR2)
IS
myPlist SRW_PARAMLIST;
myIdent SRW.Job_Ident;
myStatus SRW.Status_Record;
BEGIN
srw.start_Debugging;
myPlist := SRW_PARAMLIST(SRW_PARAMETER('',''));
srw.add_parameter(myPlist,'GATEWAY','http://localhost:8888/reports/rwservlet');
srw.add_parameter(myPlist,'SERVER','rep_kalyan1');
srw.add_parameter(myPlist,'REPORT','BillFormat.RDF');
srw.add_parameter(myPlist,'USERID','atl3_dev_jul04/atl3_dev_jul04@mgi');
srw.add_parameter(myPlist,'destype','file');
srw.add_parameter(myPlist,'desformat','pdf');
srw.add_parameter(myPlist,'documentnumber','17181');
srw.add_parameter(myPlist,'papertype','N');
srw.add_parameter(myPlist,'desname','c:\temp\17181.pdf');
myIdent := srw.run_report(myPlist);
myStatus := srw.report_status(myIdent);
srw.stop_Debugging;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
NULL;
END PROJECTOVERVIEWREPORT1;
Iam running the oc4j instance and the report server in my local machine.
when i have typed http://localhost:8888/reports/rwservlet
Iam able to see the help page.
My rdf file is placed in OralceHome/reports/integ folder.
Iam executing my stored procedure it is returning some error.
Iam doing any thing wrong.
Do i need to modify anything.
Is the place of rdf file correct.
plz help me solving the above problem.
--KalyanThis is the error message iam getting..
any idea????
* WELCOME TO EVENT-BASED-REPORTING API *
* API-Version : 9i *
* (C) Oracle Corporation, 2000 *
* Debugging turned ON *************************************
*** Length of Paramlist : 1
OK : Parameter added : GATEWAY=http://localhost:8888/reports/rwservlet
*** Length of Paramlist : 2
OK : Parameter added : SERVER=rep_kalyan1
*** Length of Paramlist : 3
OK : Parameter added : REPORT=BillFormat.RDF
*** Length of Paramlist : 4
OK : Parameter added : USERID=atl3_dev_jul04/atl3_dev_jul04@mgi
*** Length of Paramlist : 5
OK : Parameter added : DESTYPE=file
*** Length of Paramlist : 6
OK : Parameter added : DESFORMAT=pdf
*** Length of Paramlist : 7
OK : Parameter added : DOCUMENTNUMBER=17181
*** Length of Paramlist : 8
OK : Parameter added : PAPERTYPE=N
*** Length of Paramlist : 9
OK : Parameter added : DESNAME=c:\temp\17181.pdf
Starting run_report: building url
*** Building URL (RUN_REPORT)
OK : URL built : http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statu
*** Submitting HTTP Request
*** using URL :http://localhost:8888/reports/rwservlet?SERVER=rep%5Fkalyan1&REPORT=BillFormat%2ERDF&USERID=atl3%5Fdev%5Fjul04%2Fatl3%5Fdev%5Fjul04%40mgi&DESTYPE=file&DESFORMAT=pdf&DOCUMENTNUMBER=17181&PAPERTYPE=N&DESNAME=c%3A%5Ctemp%5C17181%2Epdf&statusf
ERROR : HTTP request failed -
Problem passing REF CURSOR to JAVA STORED PROCEDURE
Hi,
I've written a small Java class with a static method and
imported that into Oracle 8i. The method expects a
java.sql.ResultSet object as parameter. According to the
documentation of Oracle, a REF CURSOR (cursor variable) maps to
java.sql.ResultSet in JDBC.
The definition of the Java Stored Procedure was accepted without
problems:
CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
WASTypes.GenericCurType)
as language java
name 'sqlj.ResultSetPassingTest.testResultSetPassing
(java.sql.ResultSet)';
WASTypes is a package containing the definition of the generic
cursor:
CREATE OR REPLACE PACKAGE WASTYPES
is
TYPE GenericCurType IS REF CURSOR;
END WASTypes;
In a function I'm opening the cursor via
'Open cursorVariable for sqlStatement';
Then this cursor variable is passed to the java method and the
error ORA-03113 is shown.
I tried to solve the problem by changing the type of the
parameter to oracle.sql.REF without success.
Does anybody know what wents wrong?
Thanks in advance.
JanHi,
I've written a small Java class with a static method and
imported that into Oracle 8i. The method expects a
java.sql.ResultSet object as parameter. According to the
documentation of Oracle, a REF CURSOR (cursor variable) maps to
java.sql.ResultSet in JDBC.
The definition of the Java Stored Procedure was accepted without
problems:
CREATE OR REPLACE PROCEDURE RESULTSETPASSINGTESTPROC (row
WASTypes.GenericCurType)
as language java
name 'sqlj.ResultSetPassingTest.testResultSetPassing
(java.sql.ResultSet)';
WASTypes is a package containing the definition of the generic
cursor:
CREATE OR REPLACE PACKAGE WASTYPES
is
TYPE GenericCurType IS REF CURSOR;
END WASTypes;
In a function I'm opening the cursor via
'Open cursorVariable for sqlStatement';
Then this cursor variable is passed to the java method and the
error ORA-03113 is shown.
I tried to solve the problem by changing the type of the
parameter to oracle.sql.REF without success.
Does anybody know what wents wrong?
Thanks in advance.
Jan -
SELECT QUERY USING STORED PROCEDURE
Hi,
I am using stored procedure in package, i need to execute select statement using
stored procedure.
regards,
p.kumaran? not framed properly i think so if u dnt mind plz check it out once
if u wnt to invoke a proc from package 2 ways r there
1) execute pac_name.proc_name[(arg_list)];
2) pl/sql
[declare]
begin
pac_name.proc_name[(arg_list)];
end;
/ -
Index in Query inside Stored procedure
How to put a index on Select query inside a stored procedure.Please help me on below to write a index
Coalesce ((select sum (ICD.mAmount)
from ItemCommonData ICD (Index(PK_ItemCommonData))
Join ItemsInBundle IIBun on
(ICD.iBundleDocId = IIBun.iBundleDocId) and
(ICD.iDocId = IIBun.iDocId)
Join ItemsInBlock IIB (Index(ItemsInBlockbyBlockDoc)) on
(ICD.iDocId = IIB.iDocId)
where (Bundles.iDocId = ICD.iBundleDocId
and IIBun.fDeleted = False
and IIB.iBlockId = iBlockId)),Are you migrating to Oracle SQL and PL/SQL?
Anyway, you don't define an Index on the fly in Oracle. You create them ahead of time on the table. You can use hints to manipulate the query into using a certain execution path. -
I have a stored procedure that dynamically creates a pivot query. The procedure works and returns the correct data. Now I have a requirement to show this data in reporting system that can only pull from a table or view. Since you can not
create a dynamic query in a view I tried to do a select from using openquery.
Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
I get the error back "the linked server indicates the object has no columns". I assume this is because of the first select statement that is stuffing the variable with column names.
CODE FROM PROCEDURE
Alter PROCEDURE [dbo].[Procedure1]
AS
BEGIN
SET NOCOUNT ON
Declare @cols nvarchar(2000),
@Tcols nvarchar(2000),
@Sql nvarchar (max)
select @cols = stuff ((
Select distinct '], ['+ModelName + ' ' + CombustorName
from CombustorFuel cf
join Model m on cf.modelid = m.modelid
join Combustors cb on cf.CombustorID = cb.CombustorID
where cf.CombustorID > 0
for XML Path('')
),1,2,'')+']'
Set @Tcols = replace(@Cols, ']', '] int')
--Print @Tcols
--Print @Cols
Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
from
Select GasLiquid, FuelType, ModelName+ '' '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
from Frames f
join Family fa on f.Frameid = fa.frameid
join Model m on fa.FamilyID = m.FamilyID
join CombustorFuel cf on m.Modelid = cf.modelid
Join Combustors c on cf.CombustorId = c.CombustorID
join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
where cf.CombustorFuelID > 0
and CombustorName <> ''''
) up
Pivot
(max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
order by FuelType'
exec (@Sql)Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
SQL Reporting Services with Dynamic Column Reports
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
Displaying and reading are two very different things.
#1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
#2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
least it can't use it to auto build the field list from the proc)
I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
Jason Long -
Problems binding array in C# to stored procedure.
I'm having trouble trying to pass an array of ID's to a stored procedure that is expecting an array (listed the procedure definition below). My current interface doesn't return an error, but it also doesn't insert the proper id's.
STORED PROCEDURE DEFINITION:
TYPE source_ids IS TABLE OF wweb.DM_ASSOCIATIONS.source_id%TYPE INDEX BY PLS_INTEGER;
PROCEDURE add_message_associations
(p_dm_message_id IN wweb.dm_messages.dm_message_id%TYPE
,p_association_type IN wweb.dm_associations.association_type%TYPE
,p_sources IN source_ids
,p_create_user IN wweb.dm_associations.create_user%TYPE)
.......variable definitions here...
v_source_id := p_sources.First;
WHILE v_source_id IS NOT NULL
LOOP
-- Check if this association already exists.
-- If not add them.
v_assoc_exists := 0;
FOR r_chk IN
(SELECT 1 AS assoc_exists_flag
FROM dm_associations a
WHERE a.dm_message_id = p_dm_message_id
AND a.association_type = p_association_type
AND a.source_id = v_source_id)
LOOP
v_assoc_exists := r_chk.assoc_exists_flag;
END LOOP;
IF v_assoc_exists = 0 THEN
-- Add the association
INSERT INTO wweb.dm_associations
(dm_association_id
,dm_message_id
,association_type
,source_id
,source_column_name
,active_flag
,create_date
,create_user
,last_update_date
,last_update_user)
VALUES
(wweb.dm_associations_s.NEXTVAL
,p_dm_message_id
,p_association_type
,v_source_id
,v_source_column_name
,1
,SYSDATE
,p_create_user
,SYSDATE
,p_create_user);
END IF;
.......error handling here...
C# CODE:
OracleParameter[] param = new OracleParameter[4];
param[0] = new OracleParameter("p_dm_message_id", OracleDbType.Long);
param[1] = new OracleParameter("p_association_type", OracleDbType.Varchar2, 5);
param[2] = new OracleParameter("p_sources", OracleDbType.Int32);
param[3] = new OracleParameter("p_create_user", OracleDbType.Varchar2, 25);
param[0].Value = 1;
param[1].Value = "ER";
param[2].Value = new Int32 [] {1, 172, 412, 7953};
param[3].Value = "SVC-GDESAI";
param[2].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param[2].Size = 4;
param[2].ArrayBindStatus = new OracleParameterStatus[4]{OracleParameterStatus.Success, OracleParameterStatus.Success, OracleParameterStatus.Success, OracleParameterStatus.Success};
cn = new OracleConnection(ConnectionString);
cn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = cn;
cmd.CommandText= "dynamic_messages_api.add_message_associations";
cmd.CommandType= CommandType.StoredProcedure;
foreach (OracleParameter p in param)
if ((p.Direction == ParameterDirection.InputOutput || p.Direction == ParameterDirection.Input) && (p.Value == null || p.Value.ToString() == ""))
p.Value = DBNull.Value;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
This ran fine, and created four rows in the table, but the source id's were (1, 2, 3, 4) instead of (1, 172, 412, 7953) which were the ones I passed in.
Does anyone know what I'm doing wrong here?
Thanks,
GaurangaHi,
I think you have a problem in you PL/SQL procedure. When you receive an array in the procedure, it is your responsibility to parse it explicitely with a loop or to bulk insert with a "forall" (implicit).
For instance, here is an example of a procedure of mine. I don't catch exceptions as I want the C# calling code to know about them:
The type t_* are defined like yours.
procedure UpdateDistribDates(p_bannerid in t_bannerid,
p_promonumber in t_promonumber,
p_datenumber in t_datenumber,
p_actualdate in t_actualdate ) is
BEGIN
-- First delete the existing dates in bulk
FORALL I IN P_BANNERID.FIRST..P_BANNERID.LAST
DELETE FROM PROMODISTRIBDATE
WHERE BANNERID = P_BANNERID(I)
AND PROMONUMBER = P_PROMONUMBER(I);
-- Then, insert the values passed in arrays.
FORALL I IN P_BANNERID.FIRST..P_BANNERID.LAST
INSERT INTO PROMODISTRIBDATE
(BANNERID,
PROMONUMBER,
DATENUMBER,
ACTUALDATE)
VALUES (P_BANNERID(I),
P_PROMONUMBER(I),
P_DATENUMBER(I),
P_ACTUALDATE(I));
END;
As you can see, the FORALL keyword will process the arrays passed as any other PL/SQL array in one chunk.
When you do the insert like:
INSERT INTO wweb.dm_associations
(dm_association_id
,dm_message_id
,association_type
,source_id
,source_column_name
,active_flag
,create_date
,create_user
,last_update_date
,last_update_user)
VALUES
(wweb.dm_associations_s.NEXTVAL
,p_dm_message_id
,p_association_type
,v_source_id
,v_source_column_name
,1
,SYSDATE
,p_create_user
,SYSDATE
,p_create_user);
In source_id, you insert the index of the table, not the value of the field.
I would suggest you completely rewrite this procedure by using the explicit loop like this:
1/ Explicit loop
FOR i IN 1 .. p_sources.COUNT LOOP
-- Check the existence
EXIST_FLAG := 0;
BEGIN
SELECT 1
INTO EXIST_FLAG
FROM ...
WHERE ...
AND a.source_id = p_source(i) <-- You are parsing here
AND ...
EXCEPTION
WHEN OTHERS THEN -- Nothing was found
EXIST_FLAG := 0;
END;
IF (EXIST_FLAG = 1)
INSERT INTO wweb.dm_associations
(dm_association_id
,dm_message_id
,association_type
,source_id
,source_column_name
,active_flag
,create_date
,create_user
,last_update_date
,last_update_user)
VALUES
(wweb.dm_associations_s.NEXTVAL
,p_dm_message_id
,p_association_type
,p_source(i) <-- You parse here
END IF;
END LOOP;
2/ Implicit loop and bulk insert
You would need to completely review the logic and build an array that maps exactly the row of the table you are trying to insert into. Parse the array and check for the existence of your entry, delete the row in memory when not found, then, after the loop do a bulk insert with a "forall".
Hope it helps,
Patrice -
Problem in OUT Parameter in the stored procedure
Hi,
I have a problem in the OUT parameter of the stored procedure under the package. I encountered the error PLS-00306. Below are the codes.
Package
CREATE OR REPLACE package body test as
procedure sp_countries(rst OUT country_typ) as
sql_stmt VARCHAR2(300);
begin
sql_stmt := 'SELECT * FROM countries WHERE region_id = 1';
OPEN rst FOR sql_stmt;
end;
end test;
by the way. i declared the country_typ as this:
TYPE country_typ IS REF CURSOR;
Here is the code that will call this package:
declare
tst countries%ROWTYPE;
begin
test.sp_countries(tst);
dbms_output.put_line(tst.country_name);
end;Works for me. Although I had to use emp instead of your table:
SQL> create or replace
2 package test as
3 TYPE country_typ IS REF CURSOR;
4 procedure sp_countries(rst OUT country_typ);
5 end;
6 /
Package created.
SQL> CREATE OR REPLACE
2 package body test as
3 procedure sp_countries(rst OUT country_typ) as
4 sql_stmt VARCHAR2(300);
5 begin
6 sql_stmt := 'SELECT * FROM emp WHERE deptno = 20';
7 OPEN rst FOR sql_stmt;
8 end;
9 end test;
10 /
Package body created.
SQL> var tcur refcursor
SQL> exec test.sp_countries(:tcur);
PL/SQL procedure successfully completed.
SQL> print tcur
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
SQL> -
Can we query a stored procedure results as an SQL Table ?
Hi,
Can we query a results from the results of a stored procedure returning a result set either as cursors or as PL/SQL Table like what we do like this
select * from <tablename>
select * from (select * from tablename) alias. instead of this, can we do like this
select * from (results of stored procedure) alias.
Please Provide any Help.I agree. Pipelined Table Functions are the way to go.
Docs at http://tahiti.oracle.com
Working demos in Morgan's Library at www.psoug.org under Pipelined Table Functions. -
Hi ,
I am using EXECUTE IMMEDIATE to execute a DDL Statement inside a Stored Procedure .
But i am unable to see this table , please tell me why .
create or replace procedure NAmes
is
begin
EXECUTE IMMEDIATE 'CREATE TABLE execute_table (col1 VARCHAR(10))';
commit;
end;
Procedure created.Hi,
user10503747 wrote:
I am using EXECUTE IMMEDIATE to execute a DDL Statement inside a Stored Procedure .Why? Performing DDL in strored procedures is usually not the best way to do things in Oracle.
Whenever you have a problem, post a compete test script that people can use to re-create the problem and test their ideas. The CREATE TABLE statement that you posted was a good start; add code to show how you ran it, and what you did to see if it worked or not.
For example:
create or replace procedure NAmes
is
begin
EXECUTE IMMEDIATE 'CREATE TABLE execute_table (col1 VARCHAR(10))';
commit; -- Not needed. DDL automatically causes COMMIT
end;
SHOW ERRORS
PROMPT ===== Before Running Names Procedure =====
DESCRIBE execute_table
EXEC names;
PROMPT ===== After Running Names Procedure =====
DESCRIBE execute_tableThis worked fine for me in Oracle 10.2.0.1.0 and SQL*Plus 10.2. Output:
Procedure created.
No errors.
===== Before Running Names Procedure =====
ERROR:
ORA-04043: object execute_table does not exist
PL/SQL procedure successfully completed.
===== After Running Names Procedure =====
Name Null? Type
COL1 VARCHAR2(10)What are you doing different?
Did you get any error messages?
Are you creating the procedure in one schema, and running it in another?
Did you call the names procedure from another procedure?
Don't make people guess. Guessing is not the best way to solve problems.
Maybe you are looking for
-
How can I mount an external hard drive via command line
I have an external hard drive that's been formatted as "Mac OS Extended (Journaled)" (the default option from Disk Utility). I'm in single-user mode and want to mount the drive. I noticed that when I plug in the drive to the USB port I get some new i
-
What's wrong with my AJAX process and '&'
On the page where I create a new record, in my branch I set P10_ID with the newly created primary key and then page 10 loads. I have and onload call in the header of page 10 - onload="getValues(document.getElementById('P10_ID'));" I want to set my pa
-
I want to back up an Iphone 3G and put all the content into Iphone 4. After I have backed up the Ipone 3G and then when Iphone 4 is connected to Itunes I do not get an Option to restore back up from Iphone 3G. The only devive is see in the drop down
-
Organizing emails with a POP server
-
In Crystal Report A/R Aging Report Detail section, I set the '@Paid' field formula as: if {OJDT.TransType} = '13' then {JDT1.BalFcDeb} - {JDT1.FCDebit} else {jdt1.fccredit} - {jdt1.balfccred} In Group Footer #1 (Group: OCRD: CardName), I set up '@Pai