Call Oracle procedure with variable
Experts,
I pass arguments through script to Oracle procedure, use the input value and pass to the procedure.
Oracle procedure Gets the input value, run the query, and all connect to the log file.
I am facing a few challenges, seems to be the error of syntax or data type
1. even if I pass all the script parameter still run complains of wrong number or type of arguments.
There are three numbers followed by a date variable
2. how to pass a variable value with the INTERVAL function, it should take the value of the variable lThird for example "" AND date > = date + INTERVAL '30' MINUTE; "but somehow, after trying different variants still get error like interavl not valid."
3 see someone more changes to this?
$1 = 10;
$2 = 30;
3 = $50
$4 = '20150113';
echo "Oracle procedure in progress"
(
set linesize 100
pkg.proc exec ($1, $2, $3, $4);
) > $logFile
If [$? == 0]
then
EXIT_VAL = 0
= Package/oracle procedure =.
CREATE or REPLACE PACKAGE pkg
AS
procedure proc (lFirst in number,
lSecond in numbers
lThird in numbers
date IN oven,
curReturn to sys_refcursor);
Pkg of END;
/
CREATE or REPLACE PACKAGE pkg BODY
AS
PROCEDURE proc (lFirst in number,
lSecond in numbers
lThird in numbers
date IN oven,
curReturn ON sys_refcursor)
IS
BEGIN
OPEN FOR CurReturn
SELECT date,
emp_id,
first name,
last_name
Employees
WHERE Emp_id in (lFirst, lSecond)
Date AND > = date + MINUTE INTERVAL "(lThird)"
AND date = TO_DATE (oven, 'YYYYMMDD')-1;
END proc;
Pkg of END;
/
Error:
PLS-306: wrong number or types of argument in the call to proc
Hello
With regard to your needs:
My current problem is
1. how to store the SELECT results in the log file, ask has several columns with multiple lines
2. what happens when SELECT brings out no line?
I have re-used, corrected and adapted to your procedure:
Package:
CREATE or REPLACE PACKAGE pkg
AS
PROCEDURE proc (lFirst in number,
lSecond in numbers
lThird IN varchar2,
curReturn to sys_refcursor);
Pkg of END;
/
CREATE or REPLACE PACKAGE pkg BODY
AS
PROCEDURE proc (lFirst in number,
lSecond in numbers
lThird IN varchar2,
curReturn ON sys_refcursor)
IS
BEGIN
OPEN FOR CurReturn
SELECT *.
WCP
WHERE empno in (lFirst, lSecond)
AND hiredate > = TO_DATE (lThird, 'YYYYMMDD');
END proc;
Pkg of END;
/
Shell script: test_sql.sh
#! / bin/ksh
V_user = scott
V_pass = Tiger
echo "Oracle procedure in progress"
Req ='sqlplus-s $V_user / $V_pass<>
var refcursor rc
exec pkg.proc ($1, $2, $3,: rc)
print the rc
output
EXPRESSIONS OF FOLKLORE"
echo "$req" > logfile$ $
PS:
(1) you must put the name of your user/passwd name and table (I used the scott/tiger schema by default with emp table). This is just to show how to retrieve a refcursor output in a script.
(2) I used logfile$ $ as output file; You can use any other file or method name to redirect the output to a file
Call us at:
19000101 7934 7900 test_sql.sh
PS: As noted in the previous posts, you cannot define a VARIABLE of type DATE in sqlplus (or a Unix script); You can send a string and perform the conversion in the SQL section.
If no line is not recovered, you get the following in the log file:
PL/SQL procedure successfully completed. no rows selected
HTH.
Tags: Database
Similar Questions
-
How to call a procedure with parameter SYS_REFCURSOR OUT
Hello
With the help of Oracle 11 g R2.
I would like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor) as begin open result for select 1 from dual union all select 2 from dual; end;
I want to call this procedure similar to how a query is called and executed. Like this
Select * from testprocedure
I have seen lots of examples on the web that show how it is possible to loop through the results of a sys_refcursor inside an anonymous block and display the results using dbms_output.putline, but this isn't the method I'm looking for.
Read this: PL/SQL 101: understanding Ref Cursor
You're wrong if you think a ref cursor is a result set of data that you can query from.
-
Calling stored procedure with an input of DATE parameter
Hello. A question about the Date input parameters when you call a stored procedure.
I have a procedure that takes a DATE as input parameter. I would DATE this value to include a time element.
My Application Module method takes an input as a java.util.Date (myParamDate) parameter - that will preserve a time element (?).
However when I create the CallableStatement, I am trying to set the parameter using setDate like this (for the param 5):
I understand java.sql.Date does NOT include a time element. But setDate() only accepts a java.sql.Date so my parameter of the procedure ends with a zero time element.st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0); Connection myConn = st.getConnection(); ArrayDescriptor myArrDesc = ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn); Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray()); Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray()); Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray()); st.setString(1, repType); st.setObject(2, sqlParamNameArray); st.setObject(3,sqlParamValueArray); st.setObject(4,sqlFilterNameArray); java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime()); st.setDate(5,myRepDate); System.out.println("Report Date = " + myRepDate.toString()); st.setString(6,repUser); st.setString(7,repAttach); // set out param st.registerOutParameter(8, Types.NUMERIC); st.execute();
How to call this procedure keeping the time element?
Thank you.It includes the time element, if you want more precision with time stamp.
http://docs.Oracle.com/javase/6/docs/API/Java/SQL/date.html
-
Calling stored procedures with parameters with the database connectivity Toolkit
Hi all
I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work. I have a database in which I tables and stored procedures with parameters. Some of these stored procedures have input, output and return parameters.
I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument
Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table). In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred. The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).) I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful. I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step. I then try to use the VI of parameter query create to call the stored procedure and set the parameters. I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI? I am also having some confusion during and after these steps as well. I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert. Also, I would be happy to provide more information that might be useful.
Kind regards
Jon
Here's what I use to do this. I think I had to change him create parameterized query VI for him to work. There is a post on the forum about this somewhere.
-
Calling a procedure with IN and OUT parameters
Hello
I usually call my procedures using the following
declare the variable msg_erreur varchar2 (50)
exec simple_msg('ABC,'ABC','ABC',:error_msg);
CREATE OR REPLACE PROCEDURE SIMPLE_MSG)
ID IN VARCHAR2,
URL IN VARCHAR2,
THE LIST IN VARCHAR2,
MSG_ERREUR OUT VARCHAR2
*************************************************************
Now my question is, I try to call a proc that has IN OUT parameters. Can someone guide me on how to call the d.a. thanks
CREATE OR REPLACE PROCEDURE SIMPLE_MSG)
ID IN VARCHAR2,
URL IN VARCHAR2,
THE LIST IN VARCHAR2,
NAME IN VARCHAR OUT,
MSG_ERREUR OUT VARCHAR2Hello
OUTSIDE of the parameters are passed as OUT was: you must pass a variable.
If you set the IN OUT parameter before calling the procedure, and then either
(a) use the separate EXEC command:EXEC :name := 'Original name'; EXEC simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg);
or
(b) use a PL/SQL anonymous block, like this:
BEGIN :name := 'Original name'; simple_msg ('ABC', 'ABC', 'ABC', :name, :error_msg); END; /
The parameter can be either a variable binding (as illustrated above), or a local variable (which may only be used in the block).
-
How to call a procedure with two arguments.
Hello
I have a procedure with two arguments, IE. MyProcedure (p1 in numbers, p2 in number) to display an image blob.
How can I call this image blob in the url.
I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1 & p2 = 2, but it does not work...
Thank you
VincentVincent,
As long as you've got the possibility to execute the procedure and there is no space in the url and you have not misspelled the names of parameters then it looks right.
Here is a link to a procedure to download a file that takes two parameters.
http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724
See you soon,.
Janet Tyson
-
How to call the property with variable
Basically, I want to fill a table with data
photoArray [count] = varLoader.data.nombre;
the problem is that 'number' is supposed to be a variable is inside a loop and I "number ="peak"+ count;" before him, but it does not work, how do I call?
table rating to coerce strings to objects:
photoArray [count] = varLoader.data [number];
or
photoArray [count] = varLoader.data ["peak" + count];
-
How 2 call a procedure with the data type for the parameter Ftree.NODE
Hello
in this link
http://Andreas.Weiden.ORCL.over-blog.de/article-29307730.html
Down in the page after you run the package, I created the procedure and it compiled successfully but when call PR_WTNS in trigger WHEN-TREE-NŒUD-SELECTED
PROCEDURE PR_WTNE (i_ndNode IN Ftree.NODE);
as
PR_WTNE (i_ndNode Ftree.NODE);
I got the error message; A wrong number or types of argument in the call
pls I'm stuck can help any one?
Kind regards
Abdetu...
Published by: Abdetu on October 24, 2010 02:36
Published by: Abdetu on October 24, 2010 02:36YKou have to give a variable of type Ftree.NODE when calling this function. If called fromm a WHEN-TREE-NODE-SELECTED-trigger, use: SYSTEM. TRIGGER_NODE
-
What is the syntax to call a procedure with named parameters?
I should know this, but I can't seem to remember how to do it and did not find reference.
If I have a procedure like this:
CREATE or REPLACE myProc (inParam1 IN VARCHAR2, inParam2 in NUMBERS)...
If I want to call this stored proc with a call control and the name of the parameters instead of having to go through position, how should I do that?
That is to say, I know that I can do: call the myProc('somevalue'1)
But I want to be able to do something like this: call myproc (inParam1: = "somevalue", inParam2: = 1)-which doesn't seem to work. Anyone know the syntax I'm looking for?
Thank you!I don't know if you are referring to the call to the procedure according to the parameters.
His
Call MyProc (inParam1-online "somevalue", inParam2-online 1)
call MyProc (inParam2-online 1, inParam1-online "somevalue")
Hopefully it's that you make reference to.
-
calling a procedure with nested table as input param type
Hello
I have a guy like that table.
create or replace type table_type like table of the varchar2 (4000);
I have a procedure like this.
proc_temp (v_table_type, table_type)
Start
key code...
end;
I have a table like this.tab_test_data
--------------------
ABCD
efghd
MNOP
XYXX
I want to move this data in table tab_test_data as param of entry while calling this proc could you please tell me how the procedure that calls the statement will be the writtern.
I try like this.
----------------------------
declare
TABLE_TYPE v_table;
Start
proce_temp (v_table); - here, I want to pass data to the table as entry
end;
/
You already have the data in a table (tab_test_data), then why don't you just use the table inside the proce_temp? Why should I set a collection type and pass it as a parameter? Collections use the expensive PGA memory. If the application that you build this way may have some serious scalability issues.
Sort of a technical solution would be like this. You can use BULK COLLECT.
declare
TABLE_TYPE v_table;
Start
Select to bulk column_name fired in v_table
of tab_test_data;proce_temp (v_table);
end;
/ -
Java - a stored procedure with call by result
Hi the Oracle community,
I'm looking for some example Code how to use a Java-Stored procedure with output parameters. Don't get me wrong. I don't want to call a procedure with the parameters Out of Java (there are many examples in this respect over there). I want to just implement the appeal of the concept of results in a Java-Stored procedure. A customer calls this procedure with certain parameters and the Java procedure will fill the. So my first question: is it possible? And my second Question: how to implement it?
Greetings.
I found a solution. It's very simple.
Just setting the parameters as java array (e.g., String() P1). The first value (P1 [0]) is the returned value.
Finally just contained JDeveloper in dialog box "Edit method Signature" the parametermode OUT.
The dialog box are entitled on the stored procedure in the dbexport file. You can read this
in Section 6, publishing Java Classes with call specifications-> defining the Modes parameter in
The Oracle database Java Developer's Guide.
-
How to move from records in a procedure with Table Type as a parameter block
Hello
How can I move all records in a block of PL/SQL procedure with argument of Type Table or Refcursor.
I created a procedure in the backend with a parameter of Type table. Of the form, I want to call this procedure with the argument that ALL of the records in BULK.
Y at - it a simple method for it.
Thanks in advance
RizlyRizly,
I recently put in place a level of forms audit process that uses this method very - package of database, which takes an array of Records as a parameter. Forms 10 G supports this nicely. We have sought to implement this through a set of database triggers (update, insert, delete) but due to our requirements, it was not the best place to do so that we have implemented this in forms.Brief history on my form. The main block was based on a table, and the block has been marked NOT can, Insert and Delete. If the user wants to insert, update, or delete a record they clicked on Insert, Update, or Delete button that opens a popup form where they seized a reason Code and a Description of the transaction and then clicked a button Save.
Here's what I did.
Database side *.
1 package database with a Record of PL/SQL and PL/SQL records in the Table variable declared in the Package specification.
2. create INSERT_?, warning? and DELETE_? package procedures to manage integration, updates and deletions.
Secondary forms *.
1 create a table (control) Non-Base with all fields block
2. create a button that performs a loop on the block and all values assigns to the variable of records in the Table (ToR) forms (typed off the DB package)
3. pass the ToR to the appropriate database package procedure.Here is an example of the code I wrote:
Database side *.
Package specifications * (Note: replacewith your database schema name) also note, I use PL/SQL Developer with the PLDoc plug-in so I documentation tags in my code. CREATE OR REPLACE PACKAGE
.Transaction_Log_pkg IS -- Package Global Variables -- ------------------------ TYPE rec_T_Log IS RECORD ( table_name .transaction_log.table_name%TYPE ,trans_type .transaction_log.trans_type%TYPE ,trans_key .transaction_log.trans_key%TYPE ,action .transaction_log.action%TYPE ,column_name .transaction_log.column_name%TYPE ,old_value .transaction_log.old_value%TYPE ,new_value .transaction_log.new_value%TYPE ,trans_date .transaction_log.trans_date%TYPE ,user_id .transaction_log.user_id%TYPE ,reason_code .transaction_log.reason_code%TYPE ,comments .transaction_log.comments%TYPE ); TYPE tbl_T_Log IS TABLE OF rec_T_Log INDEX BY BINARY_INTEGER; -- Insert_Record -------------------------------------------------------------------------------- /** Procedure adds "INSERT" audting records in to the CIR.TRANSACTION_LOG table %param p_t_log TABLE_OF_RECORDS %desc You can pass a single record or a group of records. Allows you to package up all of the values inserted in a table and send them to the Insert_Record procedure as a group rather than as individual transactions. -- ---------------------------------------------------------------------------------------------- */ PROCEDURE Insert_Record (p_t_log tbl_T_Log ); -- Update_Record -------------------------------------------------------------------------------- /** Procedure adds a "UPDATE" record(s) in the CIR.TRANSACTION_LOG table %param p_t_log TABLE_OF_RECORDS %desc You can pass a single record or a group of records if more than one value in a row is updated. -- ---------------------------------------------------------------------------------------------- */ PROCEDURE Update_Record (p_t_log tbl_T_Log ); -- Delete_Record -------------------------------------------------------------------------------- /** Procedure adds "DELETE" records in to the CIR.TRANSACTION_LOG table %param p_t_log TABLE_OF_RECORDS %desc You can pass a single record or a group of records. Allows you to package up all of the values inserted in a table and send them to the Delete_Record procedure as a group rather than as individual transactions. -- ---------------------------------------------------------------------------------------------- */ PROCEDURE Delete_Record (p_t_log tbl_T_Log ); END Transaction_Log_pkg; Package body *.
-- Beginning of Package Body ------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------------------- CREATE OR REPLACE PACKAGE BODY
.Transaction_Log_pkg AS -- Package EXCEPTIONS -- ------------------ null_table EXCEPTION; null_table_name EXCEPTION; null_trans_type EXCEPTION; null_trans_key EXCEPTION; null_action EXCEPTION; null_column_name EXCEPTION; null_value EXCEPTION; null_user_Id EXCEPTION; null_reason_code EXCEPTION; null_comments EXCEPTION; -- Package Variables -- ----------------- vErrMsg VARCHAR2(1000); vSQL VARCHAR2(2000); -- ---------------------------------------------------------------------------------------------- PROCEDURE Insert_Record (p_t_log tbl_T_Log ) IS BEGIN IF ( NVL(p_t_log.COUNT,0) = 0 ) THEN RAISE null_table; ELSE FOR i IN p_t_log.first .. p_t_log.last LOOP vSQL := 'INSERT INTO .transaction_log (seq_no,table_name,trans_type,trans_key,action' ||',column_name,old_value,new_value,trans_date,user_id,reason_code,comments)' ||' VALUES ( .TRANSACTION_NO_SEQ.nextval'; -- Build Insert Statement IF ( p_t_log(i).table_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).table_name||''''; ELSE RAISE null_table_name; END IF; IF ( p_t_log(i).trans_type IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_type||''''; ELSE RAISE null_trans_type; END IF; IF ( p_t_log(i).trans_key IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_key||''''; ELSE RAISE null_trans_key; END IF; IF ( p_t_log(i).action IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).action||''''; ELSE RAISE null_action; END IF; IF ( p_t_log(i).column_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).column_name||''''; ELSE RAISE null_column_name; END IF; IF ( p_t_log(i).old_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).old_value||''''; ELSE vSQL := vSQL||',NULL'; END IF; IF ( p_t_log(i).new_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).new_value||''''; ELSE RAISE null_value; END IF; --transaction_date vSQL := vSQL||',sysdate'; IF ( p_t_log(i).user_id IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).user_id||''''; ELSE RAISE null_user_id; END IF; IF ( p_t_log(i).reason_code IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).reason_code||''''; ELSE RAISE null_reason_code; END IF; IF ( p_t_log(i).comments IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).comments||''''; ELSE RAISE null_comments; END IF; vSQL := vSQL||')'; dbms_output.put_line('vSQL = '||vSQL); EXECUTE IMMEDIATE vSQL; vSQL := NULL; END LOOP; -- The COMMIT is intentionally left out to force the calling -- application to perform the commit and complies with the -- basics of encapsulation. -- --------------------------------------------------------- END IF; EXCEPTION WHEN null_table THEN vErrMSg := 'The p_t_log Collection cannot be null!'; RAISE_APPLICATION_ERROR(-20990,vErrMsg); WHEN null_table_name THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20991,vErrMsg); WHEN null_trans_type THEN vErrMSg := 'Transaction Type cannot be null!'; RAISE_APPLICATION_ERROR(-20992,vErrMsg); WHEN null_trans_key THEN vErrMSg := 'Transaction Key cannot be null!'; RAISE_APPLICATION_ERROR(-20993,vErrMsg); WHEN null_action THEN vErrMSg := 'Action cannot be null!'; RAISE_APPLICATION_ERROR(-20994,vErrMsg); WHEN null_column_name THEN vErrMSg := 'Column Name cannot be null!'; RAISE_APPLICATION_ERROR(-20995,vErrMsg); WHEN null_value THEN vErrMSg := 'Value cannot be null!'; RAISE_APPLICATION_ERROR(-20996,vErrMsg); WHEN null_user_Id THEN vErrMSg := 'User ID cannot be null!'; RAISE_APPLICATION_ERROR(-20997,vErrMsg); WHEN null_reason_code THEN vErrMSg := 'Reason Code cannot be null!'; RAISE_APPLICATION_ERROR(-20998,vErrMsg); WHEN null_comments THEN vErrMSg := 'Comments cannot be null!'; RAISE_APPLICATION_ERROR(-20999,vErrMsg); END Insert_Record; -- ------------------------------------------------------------------------------------------------ PROCEDURE Update_Record (p_t_log tbl_T_Log ) IS BEGIN IF ( NVL(p_t_log.COUNT,0) = 0 ) THEN RAISE null_table; ELSE FOR i IN p_t_log.first .. p_t_log.last LOOP vSQL := 'INSERT INTO .transaction_log (seq_no,table_name,trans_type,trans_key,action' ||',column_name,old_value,new_value,trans_date,user_id,reason_code,comments)' ||' VALUES ( .TRANSACTION_NO_SEQ.nextval'; -- Build Insert Statement IF ( p_t_log(i).table_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).table_name||''''; ELSE RAISE null_table_name; END IF; IF ( p_t_log(i).trans_type IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_type||''''; ELSE RAISE null_trans_type; END IF; IF ( p_t_log(i).trans_key IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_key||''''; ELSE RAISE null_trans_key; END IF; IF ( p_t_log(i).action IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).action||''''; ELSE RAISE null_action; END IF; IF ( p_t_log(i).column_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).column_name||''''; ELSE RAISE null_column_name; END IF; IF ( p_t_log(i).old_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).old_value||''''; ELSE vSQL := vSQL||',NULL'; END IF; IF ( p_t_log(i).new_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).new_value||''''; ELSE RAISE null_value; END IF; --transaction_date vSQL := vSQL||',sysdate'; IF ( p_t_log(i).user_id IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).user_id||''''; ELSE RAISE null_user_id; END IF; IF ( p_t_log(i).reason_code IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).reason_code||''''; ELSE RAISE null_reason_code; END IF; IF ( p_t_log(i).comments IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).comments||''''; ELSE RAISE null_comments; END IF; vSQL := vSQL||')'; dbms_output.put_line('vSQL = '||vSQL); EXECUTE IMMEDIATE vSQL; vSQL := NULL; END LOOP; -- The COMMIT is intentionally left out to force the calling -- application to perform the commit and complies with the -- basics of encapsulation. -- --------------------------------------------------------- END IF; EXCEPTION WHEN null_table THEN vErrMSg := 'The p_t_log Collection cannot be null!'; RAISE_APPLICATION_ERROR(-20990,vErrMsg); WHEN null_table_name THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20991,vErrMsg); WHEN null_trans_type THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20992,vErrMsg); WHEN null_trans_key THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20993,vErrMsg); WHEN null_action THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20994,vErrMsg); WHEN null_column_name THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20995,vErrMsg); WHEN null_value THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20996,vErrMsg); WHEN null_user_Id THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20997,vErrMsg); WHEN null_reason_code THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20998,vErrMsg); WHEN null_comments THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20999,vErrMsg); END Update_Record; -- ------------------------------------------------------------------------------------------------ PROCEDURE Delete_Record (p_t_log tbl_T_Log ) IS BEGIN IF ( NVL(p_t_log.COUNT,0) = 0 ) THEN RAISE null_table; ELSE FOR i IN p_t_log.first .. p_t_log.last LOOP vSQL := 'INSERT INTO .transaction_log (seq_no,table_name,trans_type,trans_key,action' ||',column_name,old_value,new_value,trans_date,user_id,reason_code,comments)' ||' VALUES ( .TRANSACTION_NO_SEQ.nextval'; -- Build Insert Statement IF ( p_t_log(i).table_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).table_name||''''; ELSE RAISE null_table_name; END IF; IF ( p_t_log(i).trans_type IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_type||''''; ELSE RAISE null_trans_type; END IF; IF ( p_t_log(i).trans_key IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).trans_key||''''; ELSE RAISE null_trans_key; END IF; IF ( p_t_log(i).action IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).action||''''; ELSE RAISE null_action; END IF; IF ( p_t_log(i).column_name IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).column_name||''''; ELSE RAISE null_column_name; END IF; IF ( p_t_log(i).old_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).old_value||''''; ELSE vSQL := vSQL||',NULL'; END IF; IF ( p_t_log(i).new_value IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).new_value||''''; ELSE RAISE null_value; END IF; --transaction_date vSQL := vSQL||',sysdate'; IF ( p_t_log(i).user_id IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).user_id||''''; ELSE RAISE null_user_id; END IF; IF ( p_t_log(i).reason_code IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).reason_code||''''; ELSE RAISE null_reason_code; END IF; IF ( p_t_log(i).comments IS NOT NULL ) THEN vSQL := vSQL||','''||p_t_log(i).comments||''''; ELSE RAISE null_comments; END IF; vSQL := vSQL||')'; dbms_output.put_line('vSQL = '||vSQL); EXECUTE IMMEDIATE vSQL; vSQL := NULL; END LOOP; -- The COMMIT is intentionally left out to force the calling -- application to perform the commit and complies with the -- basics of encapsulation. -- --------------------------------------------------------- END IF; EXCEPTION WHEN null_table THEN vErrMSg := 'The p_t_log Collection cannot be null!'; RAISE_APPLICATION_ERROR(-20990,vErrMsg); WHEN null_table_name THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20991,vErrMsg); WHEN null_trans_type THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20992,vErrMsg); WHEN null_trans_key THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20993,vErrMsg); WHEN null_action THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20994,vErrMsg); WHEN null_column_name THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20995,vErrMsg); WHEN null_value THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20996,vErrMsg); WHEN null_user_Id THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20997,vErrMsg); WHEN null_reason_code THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20998,vErrMsg); WHEN null_comments THEN vErrMSg := 'Table Name cannot be null!'; RAISE_APPLICATION_ERROR(-20999,vErrMsg); END Delete_Record; -- ------------------------------------------------------------------------------------------------ END Transaction_Log_pkg; ----------------------------------------------------------------------------- -- --------------------------------------------------------------------------------------------------- Secondary forms * (all this coding was limited to the Insert, update or delete buttons.) The following example is the Insert button)
/* When-Button-Pressed Trigger */ DECLARE vBlockName VARCHAR2(20) := 'REPORT_CATEGORIES'; vBlockItem VARCHAR2(61); vCurrItem VARCHAR2(61); nRecCnt NUMBER := 1; /* Here is where you create your Forms Variable TYPEd off the Package Table of Records (ToR) */ /* Since it is a table of records, you could easily add multiple rows to the ToR if your form uses a multi-record block */ p_tlog cir.transaction_log_pkg.tbl_t_log; BEGIN vCurrItem := vBlockName||'.'||Get_Block_Property(vBlockName,FIRST_ITEM); Go_Item(vCurrItem); -- 1. Endure each field if populated. -- 2. Check for Duplicates (Handled in W-V-I) IF ( Name_In(:system.Cursor_Item) IS NULL ) THEN --Fail the form at the field that is NULL send_alert.msg('s','All fields are required. Please enter a unique value.'); RAISE Form_Trigger_Failure; END IF; WHILE ( vCurrItem IS NOT NULL ) LOOP vBlockItem := :system.cursor_item; -- Loop through the block and CALL Insert_Record for each Block Item. /* 1 */ p_tlog(nRecCnt).table_name := vBlockName; /* 2 */ p_tlog(nRecCnt).trans_type := Name_In(vBlockName||'.CAT_TYPE'); /* 3 */ p_tlog(nRecCnt).trans_key := Name_In(vBlockName||'.ID'); /* 4 */ p_tlog(nRecCnt).action := 'INSERT'; /* 5 */ p_tlog(nRecCnt).column_name := substr(vBlockItem,instr(vBlockItem,'.')+1,length(vBlockItem)); /* 6 */ p_tlog(nRecCnt).old_value := NULL; /* 7 */ p_tlog(nRecCnt).new_value := Name_In(vBlockItem); /* 8 */ p_tlog(nRecCnt).trans_date := sysdate; /* 9 */ p_tlog(nRecCnt).user_id := :Global.userid; /*10 */ p_tlog(nRecCnt).reason_code := Name_In(vBlockName||'.REASON_CODE'); /*11 */ p_tlog(nRecCnt).comments := Name_In(vBlockName||'.COMMENTS'); vCurrItem := Get_Item_Property(vBlockItem,NEXTITEM); next_item; nRecCnt := nRecCnt + 1; END LOOP; -- 3. Insert -- Call TRANSACTION_LOG_PKG.Insert_Record -- --------------------------------------
.transaction_log_pkg.insert_record(p_t_log => p_tlog); -- 4. Commit Commit; -- 5. Clear Block Clear_Block(Ask_Commit); -- 6. Close Form Hide_Window('REPORT_CATEGORIES'); -- 7. ReQuery RC_DISP Block Go_Block('REPORT_CATEGORIES_DISP'); Clear_Block(No_Validate); Execute_Query; -- 8. Done END; I knew not when I started this process of forms if she was going to work because I tried to do something similar to this when I was working with Forms 6i and Oracle Enterprise Business Suite and Forms 6i supported not Ref Cursor and Table of documents very well so I didn't know at first if it would work. Search in forms documentation, I found that Forms 10 g has supported this type of functionality and this process works very well and it was surprisingly fast - at least in my usage, it is very fast. :)
I hope this helps.
Craig...If I or someone elses answer was useful, please mark accordingly
-
call a procedure of package DB type complicated if the type defined in the package itself
Hello world
I use jdev 11.1.1.7.0
I defined a package of data with a procedure and internal two types as follows:
Create Or Replace Package Db_Package As Type rec Is Record(Rec_Type Varchar2(10), Rec_Desc varchar2(10) ); Type recordList Is Table Of rec; Procedure Test_Procedure(p_out out recordList); END db_package;
evil
I want to call this procedure in the module of the application. I know how to call a procedure or function db AM,
but in this case that I've defined two types in the package itself and I use one of these types as to the procedure output parameter, I had a problem.
below is the example of code to call the db procedure, but it does not work because the plsqlBlock.registerOutParameter () setting will not
CallableStatement plsqlBlock = null; String statement = "Begin DB_PACKAGE.Test_Procedure(:1); END;"; try { plsqlBlock = getDBTransaction().createCallableStatement(statement, 0); plsqlBlock.registerOutParameter(1, OracleTypes.ARRAY);// it doesn't work plsqlBlock.executeUpdate(); Object object = plsqlBlock.getObject(1); } catch (Exception e) { e.printStackTrace(); }
I know that if I set the types of packets (rec, recordList) as types of oracle (instead of setting in the packaging itself) so I can call the procedure with success, in this case I should use below:
plsqlBlock.registerOutParameter(1, OracleTypes.ARRAY,"Recordlist");
but I wonder how you can call a procedure from the package if the types defined in the package itself.
Kind regards
Habib
JDBC supports the types of oracle level package only from 12 c database and jdbc driver ojdbc7 (which requires java 7).
Dario
-
How to get 2 out of procedure with sql dynamic param?
Hello
following my other question on the treatment in the ranks, so that I did a procedure defined ranges for the table I want to deal with;
I did another procedure to obtain a particular range for treatment and that's where I have a problem;
My data are:
{
CREATE THE TABLE PRECUBE. TEST_STG_TMO_RANGES
(
NUMBER OF GLASS FIBER,
MIN_RID VARCHAR2 (18 BYTE),
MAX_RID VARCHAR2 (18 BYTE)
)
tablespace UTI_DAT;
Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (0, 'AABKSxAAEAACW3pAAA', 'AABKSxAAEAADqCICcQ');
Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (1, "AABKSxAAEAADqCJAAA", "AABKSxAAEAAD + wICcQ");
Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (2, ' AABKSxAAEAAD/QJAAA', 'AABKSxAAEAAECyICcQ');
Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (3, 'AABKSxAAEAAEFQJAAA', 'AABKSxAAEAAEL8ICcQ');
Insert into TEST_STG_TMO_RANGES (GRP, MIN_RID, MAX_RID) values (4, 'AABKSxAAEAAEMSJAAA', 'AABKSxAAEAAEPwICcQ');
}
my package:
{
create or replace
PACKAGE C_UTI_BASIC AS
procedure P_GET_RANGE (table_owner_in in varchar2
TABLE_NAME_IN in varchar2
range_no number
Min_RANGE_OUT OUT varchar2
max_range_OUT OUT varchar2
);END C_UTI_BASIC;
}
My procedure:
{
procedure P_GET_RANGE (TABLE_OWNER_IN in varchar2
TABLE_NAME_IN in varchar2
RANGE_NO number
MIN_RANGE_OUT OUT varchar2
MAX_RANGE_OUT OUT varchar2
)
isDDL_STATEMENT varchar2 (4000);
Start
DDL_STATEMENT: ='select MIN_RID, MAX_RID in MIN_RANGE_OUT, MAX_RANGE_OUT in '. TABLE_OWNER_IN |'. ' || TABLE_NAME_IN | "_RANGES where PRV =' | RANGE_NO;immediately run DDL_STATEMENT;
DBMS_OUTPUT. PUT_LINE (DDL_STATEMENT);
DBMS_OUTPUT. Put_line ('Min_RANGE_OUT :'||) Min_RANGE_OUT);
DBMS_OUTPUT. Put_line ('max_range_OUT :'|| max_range_OUT);
end P_GET_RANGE;}
I tried to call the procedure with:
{
declare
V_MIN_RANGE_OUT varchar2 (30);
v_Max_RANGE_OUT varchar2 (30);
Start
C_UTI_BASIC. P_GET_RANGE (TABLE_OWNER_IN = > 'PRECUBE')
, TABLE_NAME_IN = > 'TEST_STG_TMO '.
, RANGE_NO = > '4'
, MIN_RANGE_OUT = > V_MIN_RANGE_OUT
, MAX_RANGE_OUT = > v_Max_RANGE_OUT
);
end;
}
but it ends with the error:
Error report:
ORA-06510: PL/SQL: not supported by the user-defined exception
ORA-06512: at "DWH_ADMIN. C_UTI_BASIC', line 2331
ORA-00905: lack of keyword
ORA-06512: at line 5
06510 00000 - "PL/SQL: not supported by the user-defined exception.
* Cause: A user-defined exception has been raised by PL/SQL code, but
not been processed.
* Action: Fix the problem that causes the exception or write an exception
Manager for this condition. Or you may have to contact your
Director of application or DBA.
When I jump the "run immediately" just to see what is output through DBMS output here it is:
{
Select MIN_RID, MAX_RID in MIN_RANGE_OUT, PRECUBE MAX_RANGE_OUT. TEST_STG_TMO_RANGES where PRV = 4
Min_RANGE_OUT:
max_range_OUT:
}
the select statmetent seems OK for me, but the parameters are not met and have the value null;
I would appreicate advice on where I went wrong here and how achieve a correct output
THS
Rgds
Rgds
Outside the use of SQL statements cr@p Dynamics (i.e. DML and not the DDL as implied by your code) and your total lack of variable bind...
And that is your problem. Your dynamic instruction seeks to select VARIABLES that are out of reach of the dynamic statement itself. The IN such statements should be part of the EXECUTE IMMEDIATE for example
EXECUTE IMMEDIATE ddl_statement INTO min_range_out, max_range_out;
-
NullPointerException when calling stored procedure
I have the stored procedure
create or replace PROCEDURE GREETING_PROC
(
TEXT_PARAM IN VARCHAR2
MSG_TEXT VARCHAR2 OUT
) AS
BEGIN
MSG_TEXT: = "Hello" | TEXT_PARAM;
END;
My stored procedure call method
public class UserBean {}
public UserBean() {}
Super();
}
Public Shared Sub main (String [] args) {}
UserBean userBean = new UserBean();
userBean.callP ();
userBean.callStoreProcedure ();
}
public void callStoreProcedure() {}
CallableStatement st = null;
SysUser SysUserEOImpl = new SysUserEOImpl();
try {}
String sql = "BEGIN GREETING_PROC (: TEXT_PARAM,: MSG_TEXT); END; « ;
St = sysUser.getDBTransaction () .createCallableStatement (sql, sysUser.getDBTransaction (). DEFAULT VALUE);
st.setObject ("TEXT_PARAM", "Scoot");
st.registerOutParameter ("MSG_TEXT", Types.VARCHAR);
St.Execute ();
System.out.println ((String) St.GetObject ("MSG_TEXT"));
} catch (SQLException e) {}
throw new Aexception.getLocalizedMessage (e);
}
}
then I got an exception:
Exception in thread "main" java.lang.NullPointerException
at cic.opsi.model.bean.UserBean.callStoreProcedure(UserBean.java:35)
at cic.opsi.model.bean.UserBean.main(UserBean.java:27)
Hello
What statemet is UserBean.java:35)?
Second, create a new SysUserEOImpl()!
If you want to call stored proc, put the java code calling stored proc in ViewRowImpl/ViewObjectImpl/ApplicationModuleImpl and export this code in the customer interface. Then put this method in the pageDef as
a call him as an OperationBinding Zeeshan Baig blog: the PL/SQL procedure call and function in the Oracle ADF application
Extending the functionality of the components Business
ADF/OFA for Oracle Techies: ADF call stored procedure with Out parameters
Latest Oracle technology: call Store procedures for Oracle ADF Application
Maybe you are looking for
-
Water-resistant IPhone 6s, hoax?
"I've heard many blogs of people who say things like ' finally Apple made a waterproof iphone water" and other things. It's about the iphone 6, not 7. It is a hoax, or is it true? They say things like resistant to water up to 1 ft. Probably the hoax.
-
Satellite A500 - 19 X - LAN wireless no longer works
Can someone help me? We set up our wireless router and everything worked well. About 3 weeks later, the laptop cannot detect wireless networks in the area (there 6 in the front area). The switch is on, do a right click on properties on the device in
-
Satellite P850 - 12 X - not impressed
Hello I recently bought a laptop Satellite P850 - 12 X and have had problems since day one.Loose hard drive sounds, the LAN adapter is flaky and the system is subject to random freeze I tried to reinstall windows and then all the drivers, just in cas
-
Current do not install the update to Vista Media Center (KB960544)
I would appreciate much information on how to deal with a recurring problem of the automatic Windows Update: "Cumulative Update for Media Center for Windows Vista (KB960544)." Since the beginning of February 2009, whenever I start my computer, I get
-
In the folder which I put the tetherxp.inf file?
I downloaded the tetherxp.inf file but I don't know where to put it.