How to call a procedure with two arguments
Hi,
I have a procedure with two arguments, ie. myprocedure(p1 in number,p2 in number) to display a blob image.
how can I call out this blob image in url.
I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1&p2=2 , but it don't work..
Thanks
vincent
Vincent,
As long as you have been granted the ability to execute the procedure and there are no spaces in the url and you have not misspelled the parameter names then this looks right.
Here is a link to a procedure to download a file which takes two parameters.
http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724
Cheers,
Tyson Jouglet
Similar Messages
-
How to call sql procedure with parameter from java
Hello,
i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.
the following is my java code:
protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
i got error message like:
java.lang.ClassCastException: java.math.BigDecimal
As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
Please help me to solve this problem.
Thanks a lot.state.execute();
i try to use debug to find the problem, in this line, i saw
OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
is this the problem? -
How to call stored procedure with multiple parameters in an HTML expression
Hi, Guys:
Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
The orginal HTML expression is :
<img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
Thanks a lot.
SamHi:
Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
<img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
create or replace
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
v_counter number:=0;
cursor cur_All_Images_of_Offender is
SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
FROM sor_image
WHERE offender_id = p_n_Offender_id;
rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
BEGIN
open cur_All_Images_of_Offender;
loop
fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
v_counter:=v_counter+1;
if (v_counter=p_n_image_Count) then
owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||rec_Image_of_Offender.image_length);
owa_util.http_header_close;
wpg_docload.download_file (rec_Image_of_Offender.image);
end if;
exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
end loop;
close cur_All_Images_of_Offender;
END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
Thanks
Sam -
Calling Oracle procedure with two OUT parameters
Hi I am having an Oracle procedure which return ref cursor. I also want to result one more out parameter result. How Can I call the procedure in SQL. Below is the way I am calling my stored procedure with one parameter.
proc_Test (p_resultset=> My_cursor)
How can I call the procedure when I have one more OUT parameter. Second parameter returns 0 or 1.
Thanks in advYes its possible to use multiple parameter as OUT type in procedure.
SQL>set serveroutput on size 1000000;
SQL>CREATE OR REPLACE PROCEDURE myproc(p_cv OUT SYS_REFCURSOR, p_num OUT NUMBER) AS
2 BEGIN
3 OPEN p_cv FOR SELECT 'Hello Oracle' sayhello FROM DUAL ;
4 p_num := 1;
5 END;
6 /
Procedure created.
SQL>VAR cv REFCURSOR;
SQL>VAR num NUMBER;
SQL>EXEC myproc(:cv, :num);
PL/SQL procedure successfully completed.
SQL>PRINT cv;
SAYHELLO
Hello Oracle
SQL>PRINT num;
NUM
1
SQL>
{code} -
How to call a procedure with refcursor from another plsql unit
example I created a pkg with the a procedure that returns a REFCURSOR.
Now I need to call this procedure from another pkg and use the refcursor values in other pkg.
Help please.......
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor);
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor)
IS
-- 0903: Include BillToName
BEGIN
OPEN p_Cursor FOR
SELECT S.LOCATION CustomerSite, S.SITE_USE_ID CustomerSiteID, C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C,
RA_ADDRESSES A,
RA_SITE_USES S,
UWA_REGISTRY R,
UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
ORDER BY S.LOCATION;
END CustomerSite_Get;
thanks,
Anitha.
Edited by: user521218 on May 6, 2009 1:24 PMHi Anitha,
try this,
-- PKG_A
Procedure CustomerSite_Get( p_Registry IN Varchar2
, p_CustomerNumber IN Varchar2
, p_Cursor IN OUT t_cursor) Is
Begin
PKG_B.CustomerSite_Get( p_Registry
, p_CustomerNumber
, p_Cursor );
End;
-- PKG_B
Procedure CustomerSite_Get(p_Registry IN Varchar2
,p_CustomerNumber IN Varchar2
,p_Cursor IN OUT t_cursor) Is
Begin
Open p_Cursor For
SELECT S.LOCATION CustomerSite
,S.SITE_USE_ID CustomerSiteID
,C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C
,RA_ADDRESSES A
,RA_SITE_USES S
,UWA_REGISTRY R
,UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
Order BY S.LOCATION;
End CustomerSite_Get;regards,
Christian Balz -
How to call a procedure with SYS_REFCURSOR OUT parameter
Hi,
Using Oracle 11g R2.
I'd 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'd like to call this procedure similar to the way a query is called and executed. Like this
select * from testprocedure
I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.I'd 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
No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
select * from TABLE(testfunction);
This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20)) -
How to call stored procedure with parameters?
I created a stored procedure in db like:
CREATE PROCEDURE dbo.MySP
@name varchar(50),
@access_date datetime
AS
BEGIN
--insert data into a table
End
Then I create pb function to call this sp like( I use pb 11.5)
datetime ll_date
ll_date =datetime(today(), now())
DECLARE mytest PROCEDURE FOR MySP @objname = :is_name, @access_date = :ll_date USING is_tran;
IF is_tran.SQLCode <> 0 THEN
MessageBox ( "Error", "DECLARE failed" )
RETURN
END IF
EXECUTE mytest;
IF ( is_tran.SQLCode <> 0 ) and ( is_tran.SQLCode <> 100 ) THEN
MessageBox ( "Error", "EXECUTE failed" )
RETURN
END IF
Then I run the app, first time to call this function without any error, but no data inserted, no thing happen.
keep in the app and call the function again, give me error declare error.
debug give me SQLCode = 100.
SP is fine, I can insert data with isql like:
exec MySP 'name', '2014-06-18'
How to figure out the problem and fix it?You didn't mention the database in question, but the first thing I would recommend is making the call via and RPCFUNC declaration on a user object to type transaction rather than embedded SQL. Embedded SQL (IMHO) should be a last resort.
See: Using Transaction Objects to call Stored Procedures -
How to call PL/SQL stored procedure with TWO or more arguments from URL?
Hi all,
does anybody know, how to call stored procedure with more than one argument?
How to do this with one argument is known -
<img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#" width="70" height="80" alt="No Picture">
But if I need to call procedure with two formal parameters? And need to pass through URL, for example, two page item values?Just separate with an "&". Using your previous example, I'll add i_name and i_type:
<img src="#OWNER#.retreive_img_data?i_id=#IMG_ID#&i_name=somename&i_type=jpg" width="70" height="80" alt="No Picture" />
Tyler -
How to execute a procedure with collection passed as parameter?
i have created the collection:
CREATE TYPE typ_Project AS OBJECT( project_no NUMBER(2), title VARCHAR2(35), cost NUMBER(7,2))
CREATE TYPE typ_ProjectList AS VARRAY (50) OF typ_Project
and a procedure:
CREATE OR REPLACE PROCEDURE add_project (
p_deptno IN NUMBER,
p_new_project IN typ_Project,
p_position IN NUMBER )
IS
v_my_projects typ_ProjectList;
BEGIN
SELECT projects INTO v_my_projects FROM department
WHERE dept_id = p_deptno FOR UPDATE OF projects;
v_my_projects.EXTEND;
FOR i IN REVERSE p_position..v_my_projects.LAST - 1 LOOP
v_my_projects(i + 1) := v_my_projects(i);
END LOOP;
v_my_projects(p_position) := p_new_project; -- add new
UPDATE department SET projects = v_my_projects
WHERE dept_id = p_deptno;
END add_project;
Now please explain how to call this procedure with collection passed as parameter . . .For example:
BEGIN
add_project(
10, -- department number
typ_Project(
99, -- project number
'New Project', -- project title
99999.99 -- project cost
), -- new project
5 -- project position
END;
/SY. -
In SQLScript, how to use EXEC to call another procedure with parameters in procedure?
Hi experts,
In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very muchHi Sagar,
thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
create procedure ftest1(out sum_num bigint)
as
begin
declare fa_output bigint;
declare v_sql_drop varchar(200);
declare v_sql varchar(500);
declare cursor c_cursor1 for select num from TABLE1;
--v_sql_drop := 'drop procedure fe';
--exec v_sql_drop;
v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
v_sql := :v_sql || ' end';
exec v_sql;
open c_cursor1;
for c_item as c_cursor1 do
exec 'call fe(c_item.num,o_num=>fa_output)';
if sum_num is null then
sum_num := fa_output;
else
sum_num := :sum_num + fa_output;
end if;
end for;
close c_cursor1;
end;
The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again! -
How to call a script with procedure parameter
I have a script my_script.sql in sqlplus and that script calls a procedure with one in parameter my_procedure (my_parameter IN VARCHAR2).
I need to pass the parameter in the script call.
sqlplus>@my_script my_parameter
How can I do that?SQL> set serveroutput on
SQL> create or replace procedure testpass (par1 in varchar2)
2 is
3 begin
4 dbms_output.put_line(par1);
5* end;
SQL> get my_script
1* exec testpass ('&1');
SQL> @my_script 'This is the parameter'
This is the parameter
PL/SQL procedure successfully completed.
SQL> -
How to call one procedure from another procedure
Hi all,
Could anyone give me clue how to call a procedure contains out parameters
from another procedure.
I had following procedures.
1)
create or replace procedure INS_PUR_ORDER
p_poamt in number,
p_podate in date,
p_poid out number
is
begin
select pkseq.nextval into p_poid from dual;
insert into pur_order(poamt,podate,poid)
values (p_poamt,p_podate,p_poid);
end;
2)
create or replace procedure INS_PUR_ORDER_DETAIL
p_pounits in number,
p_poddate in date,
p_poid in number)
is
begin
Insert into pur_order_detail(podid,pounits,poddate,poid)
values(pdseq.nextval,p_pounits,p_poddate,p_poid);
end;
I need to write a 3rd procedure which calls above two procedures.
like
call first procedure ,basing on the return value
i.e if p_poid != 0 then
we need to call second procedure
in the loop.
thanks in advance.
rampa.Not sure what are you doing, you can not assign cursor to another cursor, may be you are looking for this?
SQL> create or replace procedure proc1 ( result out sys_refcursor)
2 is
3
4 begin
5 open result for
6 select 'HELLO WORLD' from dual ;
7 end proc1 ;
8 /
Procedure created.
Elapsed: 00:00:00.01
SQL> create or replace procedure proc2
2 is
3 l_cursor sys_refcursor ;
4 begin
5 l_cursor := proc1 ;
6
7
8 open l_cursor;
9 fetch l_cursor into l_text;
10 dbms_output.put_line(l_text);
11 close l_cursor;
12
13
14 end proc2 ;
15 /
Warning: Procedure created with compilation errors.
Elapsed: 00:00:00.01
SQL> show error;
Errors for PROCEDURE PROC2:
LINE/COL ERROR
5/4 PL/SQL: Statement ignored
5/16 PLS-00306: wrong number or types of arguments
in call to 'PROC1'
6/4 PLS-00201: identifier 'L_TEXT' must be
declared
6/4 PL/SQL: Statement ignored
8/4 PLS-00382: expression is of wrong type
8/4 PL/SQL: SQL Statement ignored
9/4 PL/SQL: SQL Statement ignored
9/24 PLS-00201: identifier 'L_TEXT' must be
declared
10/4 PL/SQL: Statement ignored
10/25 PLS-00201: identifier 'L_TEXT' must be
declared
---- this is the correct waySQL>ed
1 create or replace procedure proc2
2 is
3 l_cursor sys_refcursor ;
4 l_text varchar2(100);
5 begin
---- procedure call
6 proc1(l_cursor);
7 -- open l_cursor;
8 fetch l_cursor into l_text;
9 dbms_output.put_line(l_text);
10 close l_cursor;
11* end proc2 ;
SQL> /
Procedure created.
Elapsed: 00:00:00.01
SQL> set serveroutput on
SQL> execute proc2;
HELLO WORLD
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> -
Calling stored procedure with output parameters in a different schema
I have a simple stored procedure with two parameters:
PROCEDURE Test1(
pOutRecords OUT tCursorRef,
pIdNumber IN NUMBER);
where tCursorRef is REF CURSOR.
(This procedure is part of a package with REF CURSOR declared in there)
And I have two database schemas: AppOwner and AppUser.
The above stored procedure is owned by AppOwner, but I have to execute this stored procedure from AppUser schema. I have created a private synonym and granted the neccessary privileges for AppUser schema to execute the package in the AppUser schema.
When I ran the above procedure from VB using ADO and OraOLEDB.Oracle.1 driver, I got the following error when connecting to the AppUser schema:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TEST1'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
but when I was connecting to the AppOwner schema, everything is running correctly without errors.
Also, when I switch to the microsoft MSDAORA.1 driver, I can execute the above procedure without any problems even when connecting to the AppUser schema.
I got this error only when I am trying to execute a stored procedure with an output parameter. All other procedures with only input parameters have no problems at all.
Do you know the reason for that? Thanks!If anyone has figured this one out let me know. I'm getting the same problem. Only in my case I've tried both the "OraOLEDB.Oracle" provider and the "MSDAORA" provider and I get an error either way. Also my procedure has 2 in parameters and 1 out parameter. At least now I know I'm not the only one with this issue. :)
'*** the Oracle procedure ***
Create sp_getconfiguration(mygroup in varchar2, myparameter in varchar2, myvalue out varchar2)
AS
rec_config tblconfiguration.configvalue%type;
cursor cur_config is select configvalue from tblconfiguration where configgroup = mygroup and configparameter = myparameter;
begin
open cur_config;
fetch cur_config into rec_config;
close cur_config;
myvalue := rec_config;
end;
'** the ado code ****
dim dbconn as new adodb.connection
dim oCmd as new adodb.connection
dim ors as new adodb.recordset
dbconn.provider = "MSDAORA" 'or dbconn.provider = "OraOLEDB.Oracle"
dbconn.open "Data Source=dahdah;User ID=didi;Password=humdy;PLSQLRSet=1;"
set ocmd.activeconnection = dbconn
cmd.commandtext = "{call fogle.sp_getconfiguration(?,?)}"
'i've also tried creating a public synonym called getconfiguration and just refering to procedure by that.
' "{call getconfiguration(?, ?)}"
' "{call getconfiguration(?,?, {resultset 1, myvalue})}"
'and numerous numerous other combinations
set oPrm = cmd.createparameter("MYGROUP", advarchar, adparaminput, 50, strGrouptoPassIn$)
cmd.parameters.append oPrm
set oPrm = cmd.createParameter("MYPARAMETER", advarchar, adParamInput, 50, strParameterToPassIn$)
cmdParameters.append oPrm
set rs = cmd.execute -
JDBC-Adapter-Receiver Calling Stored Procedure with Input-Typ Record
Hallo,
I´ m trying calling a stored-procedure with two input-parameter; one of typ record (oracle) and one of type tabel of records. Is this possible (I think there are only types like string, integer etc. possible)? When not is there another possibility to work with that type?
Thanks in advance,
FrankHi Frank,
I think stored procedures will not take Array of Records as a Input. If you want to make a loop funtionality etc then JDBC adapter will work accordingly. You need to just call the stored procedure from the JDBC adapter. It will work for the array of records(multiple occurences).
Receiver JDBC Procedures.
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
Alternative option is you can make use of Java Proxy and from there you can call stored procedure ..I think it is possible.. not tried.
Hope this helps
Regards,
Moorthy -
How to call standard report with in zprogram?
Hi Sap experts,
How to call standard report with in zprogram.
For example if country is 'US' then call Zprogram(zprog_US).Inside zprogram call standard report(rhecm_change_proc_status).If country is 'CA' then call zprogram.Inside zprogram call standard report.For same othercountres like 'PR','GB','ES'.Actually HR_ECM_READ_FEATURE_CARGP will having the input as employee id and will return the CAREA(County like 'US','PR'......).Kindly help me what is the procedure?
Regards,
Sujan>
sujan T wrote:
> Thanks for your reply.
>
> What is the logic to call the standard report from zprogram?Inside the zpogram how to call standard report?
>
> Regards,
> Sujan
no special logic is required
If u want to use
RPUAUDOO IN THE ZREPORT.
Put the submit button where ever required
ex: In zreport after certain process reacedu want to call then use
submit rpuaudoo and return.
Regards
Sas
Maybe you are looking for
-
Reg : SQL query or Function -
Hi Experts, I'm in a fix between 2 approaches. Scenario : There are 2 tables say LIT (contains Literature docs) and DIAG (contains Diagams). There's some concept called 'Base number' and 'Revision' for both the tables. Ex - If Literature (or Diagram)
-
Airport Extreme - Boosting signal?
I just moved into a new apartment, and my Airport Extreme works great in the living room or office where I keep it. But when I go down a hallway (about 25 ft. away from the Extreme) and into the bedroom, I'm lucky if I get half a bar. Any way to get
-
Final cut pro nice professional sound monitor speakers
I would like some nice book shelf style nice looking sound monitor speakers for my mac pro, when you see people with edit suites in a edcit studio on TV they always have some sexy looking bookshelf speakers, any ideas where to buy these and which are
-
Address comparison to avoid duplicates in Vendor replication
Dear SRM experts, Can you please enlighten me about the Address Comparison check in Vendor replication? What would be the consequences of running the vendor replication without checking the address comparison? Thanks, Vipra.
-
No puedo conectar via wifi ipad con modem arris
no puedo conectar via wifi ipad con modem arris