Using a dynamic table variable in a stored procedure
SQL Server can do this where you declare a table variable and insert / modify / delete rows in that table without it ever being actually ON the database.
Can Oracle do this?
I know I can do things like pass in a unique user id, create the table in the procedure with the user ID appended, etc ...
but this procedure is going to be accessed via two modes, a batch job as well as online. The batch job may run this procedure 500 times.
What I'm trying to is figure out a way to return a recordset of errors that occured in the job, simple, 3 lines like so:
LineNumber NUMBER,
Severity VARCHAR(10),
Error_Msg VARCHAR(200)
is there any 3 dimensional way of storing these records when the errors occur, then returning them as a select statement at the end of the procedure?
Thanks,
Why not create a table
CREATE TABLE error_log (
job_id NUMBER,
line_number NUMBER,
severity VARCHAR2(10),
error_msg VARCHAR2(200)
CREATE SEQUENCE seq_error_log_job_id
START WITH 1
INCREMENT BY 1
CACHE 100;In your procedure, you would get a new job_id from the sequence, insert whatever records you want in the error log table using that job_id and then return a REF CURSOR where you select from the error_log table using the job_id.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Similar Messages
-
Using XI - RFC table and an Oracle stored procedure that returns a cursor.
I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor. We are on oarcle 9.2 and SP12.
My stored procedure looks something like this:
CREATE OR REPLACE
PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
in_quoteid IN varchar2 )
AS
BEGIN
OPEN p_recordset1 FOR
SELECT q.quote_id,
q.modified_by,
q.quote_status,
q.total_cost
FROM quote q
WHERE q.quote_id = in_quoteid
AND q.total_cost > 0 ;
END testproc_xi2 ;
My RFC has table and one import parameter .
I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
Thanks for the help.
MalaMala,
i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
for ex
<Details>
<FirstName>
<LastName>
</Details>
that in xi would be smthing like
Details type of data occurence
FirstName type of data occurence
LastName type of data occurence.
Hope that helps.
If it does dont forget the points..:-) -
How to use OUT variables in my stored procedure
I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code...
CREATE OR REPLACE PROCEDURE testProj.testProcedure (
v_segment_id IN VARCHAR2,
v_student_id OUT VARCHAR2,
v_current_code OUT NUMBER,
v_new_code OUT NUMBER
) AS
BEGIN
SELECT
s.student_id,
s.quad_code_id,
nc.quad_code_id
INTO
v_student_id,
v_current_quad_code,
v_new_quad_code
FROM testProj.students s
INNER JOIN testProj.new_codes nc ON s.student_id = nc.student_id
WHERE s.segment_id = v_segment_id ;
END testProcedure ;
EXECUTE testProj.testProcedure ('44') ;
When I execute that stored procedure with the above execute statement, I get this error:
Error report:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'testProcedure'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
+06550. 00000 - "line %s, column %s:\n%s"+
*Cause: Usually a PL/SQL compilation error.+
*Action:+Using Refcursor is one way you can do that ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.21
satyaki>
satyaki>
satyaki>create or replace procedure r_arg(
2 choice in number,
3 b in out sys_refcursor
4 )
5 is
6 str varchar2(500);
7 begin
8 str := 'select * from emp';
9 open b for str;
10 exception
11 when others then
12 dbms_output.put_line(sqlerrm);
13 end;
14 /
Procedure created.
Elapsed: 00:00:01.84
satyaki>
satyaki>
satyaki>declare
2 rec_x emp%rowtype;
3 w sys_refcursor;
4 begin
5 dbms_output.enable(1000000);
6 r_arg(1,w);
7 loop
8 fetch w into rec_x;
9 exit when w%notfound;
10 dbms_output.put_line('Employee No: '||rec_x.empno||' - '||
11 'Name: '||rec_x.ename||' - '||
12 'Job: '||rec_x.job||' - '||
13 'Manager: '||rec_x.mgr||' - '||
14 'Joining Date: '||rec_x.hiredate||' - '||
15 'Salary: '||rec_x.sal||' - '||
16 'Commission: '||rec_x.comm||' - '||
17 'Department No: '||rec_x.deptno);
18 end loop;
19 close w;
20 exception
21 when others then
22 dbms_output.put_line(sqlerrm);
23 end;
24 /
Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
Employee No: 7777 - Name: SOURAV - Job: SLS - Manager: - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission: - Department No: 20
Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission: - Department No: 30
Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission: - Department No: 10
Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission: - Department No: 20
Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager: - Joining Date: 17-NOV-81 - Salary: 7000 - Commission: - Department No: 10
Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission: - Department No: 20
Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission: - Department No: 30
Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission: - Department No: 20
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.48
satyaki>
satyaki>Regards.
Satyaki De. -
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 -
Passing Tables back from Java Stored Procedures
Thomas Kyte has written (in reference to
trying to pass an array back from a stored
function call):
You can do one of two things (and both require the use of
objects). You cannot use PLSQL table types as JDBC cannot bind to
this type -- we must use OBJECT Types.
[snip]
Another way is to use a result set and "select * from
plsql_function". It could look like this:
ops$tkyte@8i> create or replace type myTableType as table of
varchar2 (64);
2 /
Type created.
ops$tkyte@8i>
ops$tkyte@8i>
ops$tkyte@8i> create or replace
2 function demo_proc2( p_rows_to_make_up in number )
3 return myTableType
4 as
5 l_data myTableType := myTableType();
6 begin
7 for i in 1 .. p_rows_to_make_up
8 loop
9 l_data.extend;
10 l_data(i) := 'Made up row ' | | i;
11 end loop;
12 return l_data;
13 end;
14 /
Function created.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( demo_proc2(5) as mytableType )
3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
Made up row 4 [Image]
Made up row 5
So, your JDBC program would just run the query to get the data.
If the function "demo_proc2" cannot be called from SQL for
whatever reason (eg: it calls an impure function in another piece
of code or it itself tries to modify the database via an insert
or whatever), you'll just make a package like:
ops$tkyte@8i> create or replace package my_pkg
2 as
3
4 procedure Make_up_the_data( p_rows_to_make_up in
number ); 5 function Get_The_Data return myTableType;
6 end;
7 /
Package created.
ops$tkyte@8i>
ops$tkyte@8i> create or replace package body my_pkg
2 as
3
4 g_data myTableType;
5
6 procedure Make_up_the_data( p_rows_to_make_up in number )
7 as
8 begin
9 g_data := myTableType();
10 for i in 1 .. p_rows_to_make_up
11 loop
12 g_data.extend;
13 g_data(i) := 'Made up row ' | | i;
14 end loop;
15 end;
16
17
18 function get_the_data return myTableType
19 is
20 begin
21 return g_data;
22 end;
23
24 end;
25 /
Package body created.
ops$tkyte@8i>
ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
PL/SQL procedure successfully completed.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( my_pkg.get_the_data as mytableType
) 3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
And you'll call the procedure followed by a query to get the
data...
I have tried this, and it works perfectly.
My question, is what does the wrapper look
like if the stored function is written
in java instead of PL/SQL? My experiments
with putting the function in java have been
dismal failures. (I supposed I should also
ask how the java stored procedure might
look also, as I suppose that could be where
I have been having a problem)
nullThanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
SELECT java_stored_proc(pl/sql_stored_proc(col_id))
FROM table_of_5000_rows;
Sorry for the lengthy post. -
Query to get list of linked server tables referenced inside a stored procedure
Hi,
SQL Server 2005 sp4
I have a requirement to get list of linked server tables referenced insider a stored procedure
Ex:
Databases DB1 DB2
Tables: T1 T2
Use DB1
Go
Create proc P1
begin
select * from T1
select * from DB2.dbo.T2
end
I am looking for a query which can return a result with output as below. sp_depends is not helping here as it does not work for cross DB objects, any other thoughts.
Tables
T1,
DB2.dbo.T2On SQL 2005, you will have to do it manually.
On SQL 2008 or later, you could have used sys.sql_expression_dependencies.
Erland Sommarskog, SQL Server MVP, [email protected] -
4gb file size limitation using java.io.* package in java stored procedure
Does anyone know about file size limitations when using java.io.* package inside java stored procedures. I have some java stored procedures that read and write to files. They error out when run as a java stored procedure within oracle on files over 4gb. I have no problems with these procedures when I test them outside of oracle.
I am using 10g Release 10.2.0.1.0, the java version returned by the Oracle JVM is 1.4.2_04
When I tested it outside of oracle I ran it using the java run time in ORACLE_HOME\jdk\bin and it works perfectly on files larger than 4gb.
Thank you for the UTL_FILE suggestion. I have considered using that but there is one method in Java that I can't seem to find a corresponding procedure for in PL/SQL.
RandomAccessFile.setLength()
This allows me to truncate a file. I have a need to strip bytes off the end of a file without creating a copy because I am working with large files and disk space may be limited. It is also much slower to read from the original file and writing the same bytes to a new file (minus the trailing bytes).
If anybody has any insight about the 4gb java.io limitation in Oracle JVM or has a workaround in PL/SQL for the RandomAccessFile.setLength() method in Java, I would really appreciate the help.
Thanks,
Thach -
Retrieving PL/SQL Table Type returned by stored procedure using Java.
Hi All,
I am facing an issue in a Stored Procedure (SP) which returns Table Type, the PL/SQL complex type.
Below mentioned is how my stored procedure looks like.
CREATE OR REPLACE package sp_test_pkg as
TYPE v_value_table_type is table of SW_VALID_CODE.swValue%Type
index by binary_integer;
v_swRMAStatus v_value_table_type;
procedure sp_test
(locale in int,
name in SW_CODE.swName%Type,
v_value_table out v_value_table_type,
batch_size in int,
out_batch_size in out int,
status out int);
end sp_test_lcode_code_pkg;
My java program to access this stored procedure is as given below:
import java.sql.*;
import oracle.jdbc.driver.*;
public class OracleTest {
public static void main(String args[]) {
Connection con = null;
OracleCallableStatement cstmt = null;
String url = "url";
String userName = "username";
String password = "password";
try
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection(url, userName, password);
cstmt = (OracleCallableStatement)con.prepareCall("begin " +
"sp_test_pkg.sp_test_pkg(?,?,?,?,?,?); end;");
cstmt.setInt(1, 1);
cstmt.setString(2, "Test");
cstmt.registerOutParameter(3, OracleTypes.ARRAY);
cstmt.setInt(4, 10);
cstmt.setInt(5, 1);
cstmt.registerOutParameter(5, Types.INTEGER);
cstmt.registerOutParameter(6, Types.INTEGER);
cstmt.execute();
} catch(Exception ex) {
ex.printStackTrace(System.err);
} finally {
if(cstmt != null) try{cstmt.close();}catch(Exception _ex){}
if(con != null) try{con.close();}catch(Exception _ex){}
When i execute this java program, i get the following error:
java.sql.SQLException: Parameter Type Conflict: sqlType=2003
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:245)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:389)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:452)
at OracleTest.main(OracleTest.java:49)
I am not sure where i am going wrong. I have never worked on such complex types before. I want to retrieve the complex table type returned by the stored procedure using my java source code.
Can anyone please help me out in resolving this issue?. This is very urgent.JDBC does not recognise types declared in PL/SQL. This is documented in the Dev Guide. [Find out more|http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm#1057625].
The only work around would be to build a wrapper which calls your existing PL/SQL procedures and returns a SQL type instead. Obviously not knowing your precise scenario I have no idea how much work this entails for you. It may be worth building a code generator.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
How to pass javascript variable to PLSQL stored procedure
Hi,
How can I pass a javascript variable to a database procedure. I have a form with a radio button group and would like to save the value of the selected radio button to a database table by passing the value to the stored procedure.
ThanksHi
You can use iframe to call the procedure. Here is an example used in dynamic page or pl/sql portlet. The pl/sql procedure is called myprocedure and resists in the schema myschema. This example passes 2 parameters, but I have not yet reased a limit.
First the call within a javascript function:
myiframe.location.href="myschema.myprocedure?p_myprameter1=" + vJvascriptparameter1 + "&p_myprameter2=" + vJvascriptparameter2;
Then the iframe:
<iframe id="myiframe" height="0" width="0" frameborder="0"></iframe>
You can let the pl/sql procedure print a value, that can be used i the portlet. You can get the value in a javascript this way:
myvalue=top.window.frames["myiframe"].document.body.innerHTML;
Best regards
Klaus -
Printing OUT variables from a Stored Procedure
Hi all,
I'm running an SQL command that calls a Stored Procedure and passes in some value. I've pasted in the important parts of it below. What I am trying to do is access the OUT variables that have been assigned to the DECLARED variables. I come from a SQL Server background and there we can do "SELECT @variable" which will print it to screen. I'm trying to do something similar here.
I need to access the contents of the three variables declared at the top of the script.
Thanks in advance.
DECLARE
l_error_value NUMBER;
l_error_product VARCHAR2 (10);
l_CE_DOC_ID number;
BEGIN
PEM.create_enquiry
( ce_cat => 'COMP'
, ce_class => 'FRML'
, error_value => l_ERROR_VALUE
,error_product => l_ERROR_PRODUCT
, ce_doc_id => l_ce_doc_id
END;Ah yes I see. Sorry I misunderstood what you were suggesting. I'm currently working on a test script that uses an approach similar to the one you mentioned, but I'm having trouble resolving foreign key relationships with test data.
I've no access to the tables or anything so it's proving to be a time consuming task!!
Is it required that all fields are given a value, even if they have a "DEFAULT" defined for them within the procedure. At the moment I'm using a rather cumbersome approach to this:
i.e.
With cmmAddRequest
.ActiveConnection = strConnect
.CommandType = adCmdText
.CommandText = strSQL
.Parameters(0).Direction = adParamInput
.Parameters(1).Direction = adParamInput
.Parameters(2).Direction = adParamInput
.Parameters(3).Direction = adParamOutput
.Parameters(4).Direction = adParamOutput
.Parameters(5).Direction = adParamOutput
.Parameters(0).Value = "COMP"
.Parameters(1).Value = "FRML"
.Parameters(2).Value = "1"
.Execute
WScript.Echo(.Parameters(5).Value)
End With -
How can I use a button to trigger a SQL Stored Procedure?
I have a stored procedure (UpdateAdsUsers) that performs updates on multiple tables all tied together with one
parameter - @username
(I'm using DWCS5, SQL SERVER 2008, ASP VB)
UPDATE users SET defaultview='0' WHERE user_name=@username
UPDATE db_settings SET valuestr='MM/DD/YYYY' WHERE keyword='dateformat' AND user_name=@username
UPDATE db_settings SET valuestr='Y' WHERE keyword='COPY_MSG_VIA_EMAIL' AND user_name=@username
UPDATE db_settings SET valuestr='4' WHERE keyword='web_download_rend' AND user_name=@username
UPDATE db_settings SET valuestr='Y' WHERE keyword='cpy_confirm' AND user_name=@username
UPDATE db_settings SET valuestr='WLPG:12' WHERE keyword='INITIAL_ASSETS' AND user_name=@username
UPDATE db_settings SET valuestr='20' WHERE keyword='thumb_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='20' WHERE keyword='text_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='5' WHERE keyword='para_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.company_name' WHERE keyword='sortorder1' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.title' WHERE keyword='sortorder2' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.production_type' WHERE keyword='sortorder3' AND user_name=@username
UPDATE tnailview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='adsx_type', fourth_field='adsx_status' WHERE user_name=@username
UPDATE textview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
UPDATE paraview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
SELECT * FROM adsx_preferences WHERE user_name=@username
This functions perfectly in SQL.
Using Dreamweaver CS5, I've added the Procedure as a Command (ADS_User) with the one variable (@username).
<%
set ADS_User = Server.CreateObject("ADODB.Command")
ADS_User.ActiveConnection = MM_ADSX_STRING
ADS_User.CommandText = "dbo.UpdateAdsUser"
ADS_User.Parameters.Append ADS_User.CreateParameter("@RETURN_VALUE", 3, 4)
ADS_User.Parameters.Append ADS_User.CreateParameter("@username", 129, 1,32,ADS_User__username)
ADS_User.CommandType = 4
ADS_User.CommandTimeout = 0
ADS_User.Prepared = true
ADS_User.Execute()
%>
In a perfect world, either an image click or a form submit would run the procedure. The parameter (@username) is currently sent to the page as a URL Querystring of the same name.
I'm sure it's something obvious, but I'm new.
Thanks in advanceI'm not sure what your question is. Is this currently failing? Or are you not able to figure out how to send the username to the script page? You really just need to create a form and pass the value in a form field.
>The parameter (@username) is currently sent to
>the page as a URL Querystring of the same name.
Never use a querystring to update data. It is too dangerous. Use the post method instead. -
Creating a table/view or temporary table from within a stored procedure
Hi Gurus,
Can someone tell me if it is possible to create a table (or view) from within a stored procedure.
PROBLEM:
In fact I need to create a report at back end (without using oracle developer forms or reports). This report requires creating several tables to hold temporary report data. If I create a sql*plus script for this, i works fine, because it can run DDL and other sql or pl/sql statements sequencialy. But this sql*plus script cannot be called from application. So, application needs an stored procedure to do this task and then application call that procedure. But within stored procedure, i am unable to create table (or run any ddl statement). Can somebody help me in this?
Thanks in Advance.Denis,
The problem with Nicholas' suggestion isrelated to the fact that now you have two components
(a table and a stored procedure)
I don't see any problem to have "two
components" here. After all, what about all others
tabes ? This is only one more, but I don't understand
why want manage less objects, that implies more code,
more maintenance, and more difficulties to debug.
Needless to say about performance...
Nicolas.The same reasons apply if you were forced to declare all PL/SQL variables publicly (outside the stored proc.) rather than privately (from inside the stored proc). Naming conflicts for one. If the name that you want to use for the GTT already exists, you need to find a new name. With the SQL Server type local/private declarations, you wouldn't have that problem.
I can see how performance would be the same or better using GTTs. If the number of records involved is low, this is likely negligable. -
URGENT: I want to pass a variable to a stored procedure at run time
Post Author: aruplabs
CA Forum: Data Connectivity and SQL
I work for a health care provider and I have reports that pull PHI (Protected Health Information) about patients that needs to be logged according to federal HIPAA regulations. One of the pieces of information that needs to be logged is the username of the person who ran the report. Since these reports will be run from our Crystal Enterprise server I can get this from the CurrentCEUserName variable but I am looking for a way to pass this value to a stored procedure that will not only return the records for the report, but also log the disclosure in our PHI disclosure tracking table. I know you can pass a parameter to a stored procedure but I dont know how, or if it is even possible, to pass a run time variable. This is an urgent problem that I need to find a solution for. Any help would be appreciated.
Thank you.Here it is. Right now, when i press te "Go" it runs for the specific time i've set and when its done the variable "Run" is set true. When i call this VI from another VI it waits for the loop to be finished before it will read the variable.
Regards
Viktor
Attachments:
Untitled 2.vi 26 KB -
Dynamic pages submitting data to stored procedure
Hi,
I am developing an Oracle Portal application and I am facing a problem, if anyone could help me I'd be very grateful.
I have the latest version of Portal 3.0.9, installed on a linux server. I'm using I.E. 6.0 to interface with Portal.
I have a dynamic page that have a <form> tag, like this:
<form name="MyFormName" action="MySchema.MyStoredProcedure" method="post">
I changed the form name and the stored procedure name, because I'm in Brazil and these names are in portuguese, it won't make much sense in english...
Well, problem is, when I click on submit button, instead of calling the stored procedure, the browser tries to load a page called "http://MyServer/pls/MyDAD/MySchema.MyStoredProcedure" instead of calling the actual stored procedure. The procedure have all the parameters defined on <input> tags within the html code of the dynamic page.
I don't know what else I can do, any help or hint would be greatly appreciated. Sorry for my bad english.
Thanks In Advance,
Tiago RochaHave you specified any value (greater than 0) in the Portlet expires in ... minutes field ?
If you have, then I guess your dynamic page is getting cached.
Before submitting the form, do a right click on the browser page and view the page source.
What does the <form> tag look like ?
Does it still show the old procedure name ? -
"table type" result from stored procedure (Oracle 10g) for physical service
Hello,
I'm trying to create a physical service based on a stored procedure which returns a table type like this:
SQL
-- create table
create table myTable ( "col1" VARCHAR2(250) not null enable, "filtercol1" VARCHAR2(250), "filtercol2" VARCHAR2(250), "sortcol1" VARCHAR2(250), "sortcol2" VARCHAR2(250), "sortcol3" VARCHAR2(250))
-- create return type
create or replace type myResultType as table of varchar2(250);
-- create function
create or replace function getResult(param1 in varchar2, param2 in varchar2, orderby in varchar2) return myResultType as
query_str VARCHAR2(1000);
myResult myResultType;
begin
query_str := 'select m.col1 from myTable m where m.filtercol1 like :param1 and m.filtercol2 like :param2 order by ' || orderby;
execute immediate query_str bulk collect into myResult using param1, param2;
return myResult;
end getResult;
The wizard for creating the physical service complains that it can't find the return type and I have to create a schema by myself. How should it look like? I can't find a sample in the documentation.
Thanks for any help,
GuidoOk, now the wizard produces something like this:
(::pragma function <f:function xmlns:f="urn:annotations.ld.bea.com" visibility="protected" kind="library" isPrimary="false" nativeName="GETRESULT" nativeLevel2Container="MY_SCHEMA" style="storedProcedure">
<nonCacheable/>
<params xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes" xmlns:pn1="ld:physical/SQLServices/MY_TMP_TABLE" >
<param name="RETURN_VALUE" kind="return" xqueryType="pn1:MY_TMP_TABLE" nativeTypeCode="0" nativeType="RowSet"/>
<param name="RETURN_VALUE" kind="out" xqueryType="pn1:MY_TMP_TABLE" nativeTypeCode="0" nativeType="RowSet"/>
<param name="PARAM1" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
<param name="PARAM2" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
<param name="ORDERBY" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
</params>
</f:function>::)
declare procedure f1:GETRESULT($PARAM1 as xs:string, $PARAM2 as xs:string, $ORDERBY as xs:string) as schema-element(t1:GETRESULT) external;
Then WorkSpace Studio complains about: "... error: cos-element-consistent: Type of 'RETURN_VALUE' is inconsistent with another element with the same name in this content model. "
If I rename one RETURN_VALUE to RETURN_VALUE1 (the param name and in the schema file) the error is gone, but if I try to test the method I get:
com.bea.dsp.das.exception.DASException: weblogic.xml.query.exceptions.XQuerySagaException: {bea-err}UPD003: Update failure: mixed outcome, update error dispatched (updateid=SAGA_596ba32b1ff8d8a4:181f0b20:11f92ed2529:-7fe2): java.lang.RuntimeException: Konflikt bei Parametertyp
at com.bea.dsp.das.ejb.EJBClient.invokeOperation(EJBClient.java:160)
at com.bea.dsp.das.DataAccessServiceImpl.invokeOperation(DataAccessServiceImpl.java:171)
at com.bea.dsp.das.DataAccessServiceImpl.invoke(DataAccessServiceImpl.java:122)
at com.bea.dsp.ide.xquery.views.test.QueryExecutor.invokeFunctionOrProcedure(QueryExecutor.java:121)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.getFunctionExecutionResult(XQueryTestView.java:1006)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.executeFunction(XQueryTestView.java:1134)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelectedImpl(XQueryTestView.java:1807)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.access$300(XQueryTestView.java:159)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent$3.run(XQueryTestView.java:1535)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelectedBusy(XQueryTestView.java:1538)
at com.bea.dsp.ide.xquery.views.test.XQueryTestViewContent.widgetSelected(XQueryTestView.java:1500)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:339)
at org.eclipse.core.launcher.Main.basicRun(Main.java:283)
at org.eclipse.core.launcher.Main.run(Main.java:984)
at org.eclipse.core.launcher.Main.eclipse_main(Main.java:959)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.m7.installer.util.NitroxMain$1.run(NitroxMain.java:39)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
"Konflikt bei Parametertyp" means something like: parameter type conflict
Best regards,
Guido
Maybe you are looking for
-
Problem of Creating a web dynpro application based on a car rental web serv
Based original SAP developer studio examples shipped with the developer studio, I first create J2EE application QuickCarRental. It works at http://192.168.254.4:50300/QuickCarRental. A web service QuickCarRentalWebService is defined in J2EE appli
-
Officejet Pro 8000 slow to select for color prints
I just installed Officejet Pro 8000 and immediately noticed how slowly the printer is selected in printer options box when I am doing color printing. It takes about 30 sec-1 minute to finalize the selection of this as my printer for the job. I have a
-
I need urgent help for the logic
hi all, Initially, the requirement was to create PO regardless the Purchase Requisition based on the formula If (Open Qty + Current Stock) < Safety Stock ==>> THEN A PO NEEDS TO BE CREATED This is absolutely fine, this created the PO as per the above
-
Runtime error with column default value settings
I have one SP2010 (enterprise) document library which gives me a runtime error if I click on "column default value settings" in the settings. Other document libraries' column default value settings are working fine. I use managed metadata and created
-
I figure this is hte closest I can get to a section on this. I need to use a website that requires Windows and Internet Explorer. I've got Explorer 5.2 on my iBook, but obviously Windows isn't an option on it. So, I was wondering if there's any way t