Count a procedures input parameters
Hello,
does anyone know how to count the number of parameters being passed into a procedure in a package. That is, if a package was called from an application how could a Procedure B count the parameters passed to Procedure A on the initial call to the package.
Thanks in advance.
Have a look at ALL_ARGUMENTS.
Similar Messages
-
Can some selection conditions as PL/SQL procedure input parameters
Dear All,
I need to write a PL/SQL procedure so as to compute the different query only by changing the input parameters. But those input parameters need to be like a PL/SQL table selection conditions. Like:
one of the query I need two conditions:
customers.zip = 60606
customers.zip = employees.zipMy procedure can compute the query like:
select customers.cno, cname, employees.eno, ename
from customers, orders, employees
where customers.cno = orders.cno and
employees.eno = orders.eno and
C;
where C is the conjunction of the conditions in the input parameter.
Please help and thanks in advance!Well, it's easy enough to do what you want....
SQL> conn scott/tiger
Connected.
SQL> CREATE OR REPLACE FUNCTION flexi_q (pn_deptno IN NUMBER, pv_string IN VARCHAR2 := NULL)
2 RETURN sys_refcursor AS
3 return_value sys_refcursor;
4 BEGIN
5 IF pv_string IS NULL THEN
6 OPEN return_value FOR SELECT * FROM emp WHERE deptno = pn_deptno;
7 ELSE
8 OPEN return_value FOR 'SELECT * FROM emp WHERE deptno = :1 AND '
9 ||pv_string USING pn_deptno;
10 END IF;
11 RETURN return_value;
12 END;
13 /
Function created.
SQL> var rc refcursor
SQL> exec :rc := flexi_q(30)
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7900 JAMES CLERK 7698 03-DEC-81 950
30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30
6 rows selected.
SQL> exec :rc := flexi_q(30, 'SAL > 1400')
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0
30
SQL> The real question is: do you really want to do this? Fundamentally you are handing over control of your app to any nimrod who thinks they know how to write SQL. It's just about allowable for them to add simple restrictions but they could add in anything - correlated sub-queries, extravagant sorts, etc. Even if they don't deliberately exploit this hole you still have a fundamentally untunable part of your app.
It would be much better to have some additional parameters that allows the users to choose from several off-the-peg queries. If you have a user demanding the ability to write "any report I need" I recommend talking to them. The chances are they simply have a pet query, probably embodied in an Excel spreadsheet, they run once every month. Give them a view to meet that need and they'll be happy.
Cheers, APC -
Oracle Developer Tools Stored Procedures with input parameters.
I have created packages with stored procedures that contain input parameters. Am I required to write my own VB code in visual studio .net to define input parameters and their values in using these packages or am I able to drag and drop the packages and use the wizards.
If you drag and drop a procedure that has input parameters the wizard will generate code that creates parameter objects. You will need to assign appropriate values to those parameters after they are created to use them.
- Mark -
Problem calling stored procedure with user-defined type of input parameters
Hi,
I have to call a stored procedure with IN parameters, but these are user-defined types of input parameters.
function fv_createnews (
pit_groups in T_APPLICATION_USER_GROUPS,
pit_documents in T_DOCUMENTS
return varchar2;
TYPE T_APPLICATION_USER_GROUPS IS
TABLE OF varchar2(500)
INDEX BY binary_integer;
TYPE T_DOCUMENT IS record (
name varchar2(256)
,url varchar2(1024)
,lang varchar2(30)
,foldername varchar2(150)
TYPE T_DOCUMENTS IS
TABLE OF T_DOCUMENT
INDEX BY binary_integer;
How can I do this using the TopLink 10.1.3 API.
I already found following related posts, but I still can' t make it up:
Using VARRAYs as parameters to a Stored Procedure
Pass Object as In/Out Parameter in Stored Procedure
Or do I have to create my own PreparedStatement for this special stored procedure call using Java and Toplink?As the related posts suggest, you will need to use direct JDBC code for this.
Also I'm not sure JDBC supports the RECORD type, so you may need to wrap your stored functions with ones that either flatten the record out, or take OBJECT types. -
Hi,
I have a scenario where my stored procedure takes 5 parameters and the users can pass NULL or some value to these parameters and based on the parameters, I need to pull data from various tables.
Is it possible to use a case statement in the join, similar the one in the below example. I'm getting error when I use the below type of statement.
select a.*
from a
case
when parameter1=1 then
inner join a on a.id = b.id
when parameter1=2 then
inner join a on a.id = c.id
end;
Please let me know, if this type of statement works, and if it works will it create any performance issues?. If the above doesn't work, could you please give me some alternate solutions?
Thanks.Here's a technique for joining A to B or C depending on the input parameters. In theory, you are joining to both tables but the execution plan includes filters to skip whichever join is not appropriate. The drawback is that you have to do outer joins, not inner ones.
CREATE TABLE A AS SELECT LEVEL ak FROM dual CONNECT BY LEVEL <= 100;
CREATE TABLE b AS SELECT ak, bk
FROM A, (SELECT LEVEL bk FROM dual CONNECT BY LEVEL <= 10);
CREATE TABLE c(ak, ck) AS SELECT ak, bk*10 FROM b;
variable p1 NUMBER;
variable p2 NUMBER;
exec :p1 := 1;
exec :p2 := 20;
SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
WHERE A.ak <= 9;
SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 9 |00:00:00.01 | 7 |
|* 1 | HASH JOIN OUTER | | 1 | 9 | 9 |00:00:00.01 | 7 |
|* 2 | HASH JOIN OUTER | | 1 | 9 | 9 |00:00:00.01 | 7 |
|* 3 | TABLE ACCESS FULL | A | 1 | 9 | 9 |00:00:00.01 | 3 |
| 4 | VIEW | VW_DCL_5532A50F | 1 | 9 | 9 |00:00:00.01 | 4 |
|* 5 | FILTER | | 1 | | 9 |00:00:00.01 | 4 |
|* 6 | TABLE ACCESS FULL| B | 1 | 9 | 9 |00:00:00.01 | 4 |
| 7 | VIEW | VW_DCL_5532A50F | 1 | 9 | 0 |00:00:00.01 | 0 |
|* 8 | FILTER | | 1 | | 0 |00:00:00.01 | 0 |
|* 9 | TABLE ACCESS FULL | C | 0 | 9 | 0 |00:00:00.01 | 0 |
Predicate Information (identified by operation id):
1 - access("A"."AK"="ITEM_0")
2 - access("A"."AK"="ITEM_1")
3 - filter("A"."AK"<=9)
5 - filter(:P1 IS NOT NULL)
6 - filter(("B"."AK"<=9 AND "B"."BK"=:P1))
8 - filter((:P2 IS NOT NULL AND :P1 IS NULL))
9 - filter(("C"."AK"<=9 AND "C"."CK"=:P2))
You can see that table C was not really accessed: the buffer count is 0.
exec :p1 := NULL;
SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
WHERE A.ak <= 9;
SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
Now table B is not accessed.
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
| 0 | SELECT STATEMENT | | 1 | | 9 |00:00:00.02 | 7 | 2 |
|* 1 | HASH JOIN OUTER | | 1 | 9 | 9 |00:00:00.02 | 7 | 2 |
|* 2 | HASH JOIN OUTER | | 1 | 9 | 9 |00:00:00.01 | 3 | 0 |
|* 3 | TABLE ACCESS FULL | A | 1 | 9 | 9 |00:00:00.01 | 3 | 0 |
| 4 | VIEW | VW_DCL_5532A50F | 1 | 9 | 0 |00:00:00.01 | 0 | 0 |
|* 5 | FILTER | | 1 | | 0 |00:00:00.01 | 0 | 0 |
|* 6 | TABLE ACCESS FULL| B | 0 | 9 | 0 |00:00:00.01 | 0 | 0 |
| 7 | VIEW | VW_DCL_5532A50F | 1 | 9 | 9 |00:00:00.01 | 4 | 2 |
|* 8 | FILTER | | 1 | | 9 |00:00:00.01 | 4 | 2 |
|* 9 | TABLE ACCESS FULL | C | 1 | 9 | 9 |00:00:00.01 | 4 | 2 | -
So what I mean:
I have stored procedure like this:
CREATE PROCEDURE sp_Example
@param1 NVARCHAR(20) = '',
@param2 DATE = ''
AS
BEGIN
IF (SELECT COUNT(*) FROM Table1 WHERE (Name = @param1 OR @param1 = '') AND (StartDate = @param2 OR @param2 = '')) > 2
BEGIN
SELECT Name, Date, Price, Etc
FROM Table2
WHERE (Name = @param1 OR @param1 = '') AND (StartDate = @param2 OR @param2 = '')
END
IF (SELECT COUNT(*) FROM Table1 WHERE (Name = @param1 OR @param1 = '') AND (StartDate = @param2 OR @param2 = '')) < 2
BEGIN
SELECT Name, Date, Price, Etc
FROM Table3
WHERE (Name = @param1 OR @param1 = '') AND (StartDate = @param2 OR @param2 = '')
END
END
So in stored procedure are some input parameters and they are passed into IF statement.
If I use this stored procedure as report's dataset (Microsoft Visual Studio 2013) in following:
Add
Dataset > Query
Type: Stored Procedure > sp_Example It
do NOT get any fields, but get parameters
If I use this stored procedure in following:
Add
Dataset > Query
Type: Text > EXECUTE
sp_Example It get all required fields, but do NOT get parameters
Of course If I add manually parameters or fields It not working.
If I change IF statement
in stored procedure something like:
IF (1 < 3)
BEGIN
SELECT Name, Date, Price, Etc
FROM Table3
WHERE (Name = @param1 OR @param1 = '') AND (StartDate = @param2 OR @param2 = '')
END
It normally working in report (getting all fields and parameters). So problem is that I pass parameters to IF statement.
Have you any ideas how to pass parameters to IF statement
and get It correctly working on report?Hi Stanisolvas,
Per my understanding that you are experending some issue when using the stored procedure to create the dataset, you can't get the fields to display under the dataset, right?
I have tested on my local environment with the same script as your and can't reproduce the issue, Please try to check and provide more details information according to below points:
What do you mean of not get any fields, Is that mean no table header along with the value will display? If you got any error message, please provide it.
Did you use any temp table in the stored procedure, if so, the issue can be caused by the temp table you are using, please don't use temp table in it which will cause no fields display.
If you use the second method to execute the procedure, please check to make sure you have added the script like below to make the parameters display in the report:
exec sp_Example @Param1=@Param1,@Param2=@Param2
Please execute the stored procedure in the SQL Server Management Studio like below to see if the stored procedure will works fine:
exec sp_Example @Param1='Test1',@Param2='2014-10-15'
If this work fine in the management studio, please try to create an new report to re-add this procedure.
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
Calling stored procedures with parameters with the Database Connectivi​ty Toolkit
Hi all,
I am new to the forum and am having difficulty finding a solution to a particular problem I am having regarding using the LabVIEW Database Connectivity Toolkit on a project I am currently working on at my job. I have a database in which I have tables and stored procedures with parameters. Some of these stored procedures have input, output, and return parameters.
I have been trying to follow this example but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument
One such stored procedure I am working on implementing is named "dbo.getAllowablePNs", which executes "SELECT * from DeviceType" (DeviceType is the table). In this case, it does not require an input parameter, it has an output parameter that generates the table [cluster], and has a return parameter which returns an integer value (execution status code) 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 gone over many examples and have talking to NI support to try to implement this and similar stored procedures in LabVIEW but have not been successful. I am able to connect to the database with the Open Connection VI without error, but am running into some confusion following this step. I am then trying to use the Create Parameterized Query VI to call the stored procedure and set the parameters. I assume I would then use the Set Parameter Value VI for each parameter that is wired into the parameters input on the previous Parameterized Query VI? I am also having some confusion during and following these steps as well. I would greatly appreciate any advice or suggestions anyone might have in regards to this situation as I am not a SQL expert. Also, I would be happy to provide any more information that would be helpful.
Regards,
Jon
Solved!
Go to Solution.Also, I don't know if this would be helpful but here is the actual stored procedure in SQL:
CREATEPROCEDURE [dbo].[getLastSequenceNumber]
@p1 nvarchar(10)='WO-00000'
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SETNOCOUNTON;
-- Insert statements for procedure here
selectmax(SequenceNumber)from Devices where WorkOrderNumber= @p1
END
GO -
How to bind/pass multiple input parameters to sql query in BPEL Process
Hi,
I have a requirement to invoke a query on a database table to fetch the records based on the few input values or bind variables?
I have created a Partner link using the DBAdapter service and have used custom SQL, how can i bind and pass multiple bind/input parameters for these queries.
foreg: if i have to query employee records based on name , desgination and age, these three params would be my input parameter that i will pass when i invoke the BPEL process, bow how can i pass these parameters to the partner link using DBADAPTER service.
Please help
RegardsIf the parameter-value is not known beforehand and cannot be determined based on the process instance data at that time, there are 2 options. Either invoke the PL/SQL procedure you named using a DB adapter service to get the value and pass it to the other DB adapter service. Or create a single service (e.g. PL/SQL procedure) that determines the parameter value, executes the query and returns the result. However, this is more a design issue. Does it makes sense to combine these actions in a separate service and use it or are these actions not related? You furthermore state that additional (DB adapter) services make the process heavier. Do you have strict requirements on the time process-instances may run or other such requirements? If not, I think the design-choice on whether combining these actions in a single service should have more priority.
-
Calling report from a form with user input parameters
Hello,
I am new to Oracle reports. I have an application coded in 6i. I am currently running the application in Oracle Forms Builder 9i. There are also few reports which are called from the forms. Since the application was developed in 6i, the report was called using Run_Product. The forms pass a set of user parameters to the report using the parameter list pl_id. The syntax used was Run_Product(REPORTS, 'D:\Report\sales.rdf', SYNCHRONOUS, RUNTIME,FILESYSTEM, pl_id, NULL);
I learnt that the Run_product doesnt work in 9i and we need to use run_report_object. I have changed the code to use run_report_object and using web.show_document () i am able to run the report from the form. There are 2 parameters that need to be passed from forms to reports. The parameters are from_date and to_date which the user will be prompted to enter on running the form. In the report, the initial values for these parametes are defined. So, the report runs fine for the initial value always. But when i try to change the user inputs for the form_date and to_date, the report output doesnt seem to take the new values, instead the old report with the initial values(defined in the report) runs again.
Can someone give me the code to pass the user defined parameters to the report from the forms? I have defined a report object in the forms node as REPTEST and defined a parameter list pl_id and added form_date and to_date to pl_id and used the following coding:
vrepid := FIND_REPORT_OBJECT ('REPTEST');
vrep := RUN_REPORT_OBJECT (vrepid,pl_id);
But this doesnt work.
Also, Should the parameters defined in the forms and reports have the same name?Thanks for the quick response Denis.
I had referred to the document link before and tried using the RUN_REPORT_OBJECT_PROC procedure and ENCODE functions as given in the doc and added the following SET_REPORT_OBJECT_PROPERTY in the RUN_REPORT_OBJECT_PROC :
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,' FROM_DATE='||:BLK_INPUT.FROM_DATE||' TO_DATE='||:BLK_INPUT.TO_DATE||' paramform=no');
But this also dint work. Please help me understand what difference does setting paramform=no OR paramform=yes make?
In the report, i have defined the user parameters as FROM_DATE and TO_DATE respectively so that they match the form datablock BLK_INPUT items FROM_DATE and TO_DATE.
My WHEN_BUTTON_PRESSED trigger is as below:
DECLARE
report_id report_object;
vrep VARCHAR2 (100);
v_show_document VARCHAR2 (2000) := '/reports/rwservlet?';
v_connect VARCHAR2 (30) := '&userid=scott/tiger@oracle';
v_report_server VARCHAR2 (30) := 'repserver90';
BEGIN
report_id:= find_report_object('REPTEST');
-- Call the generic PL/SQL procedure to run the Reports
RUN_REPORT_OBJECT_PROC( report_id,'repserver90','PDF',CACHE,'D:\Report\sales.rdf','paramform=no','/reports/rwservlet');
END;
... and the SET_REPORT_OBJECT_PROPERTY code in the RUN_REPORT_OBJECT_PROC procedure is as:
PROCEDURE RUN_REPORT_OBJECT_PROC(
report_id REPORT_OBJECT,
report_server_name VARCHAR2,
report_format VARCHAR2,
report_destype_name NUMBER,
report_file_name VARCHAR2,
report_otherparam VARCHAR2,
reports_servlet VARCHAR2) IS
report_message VARCHAR2(100) :='';
rep_status VARCHAR2(100) :='';
vjob_id VARCHAR2(4000) :='';
hidden_action VARCHAR2(2000) :='';
v_report_other VARCHAR2(4000) :='';
i number (5);
c char;
c_old char;
c_new char;
BEGIN
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_COMM_MODE,SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME,report_file_name);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_SERVER,report_server_name);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE,report_destype_name);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESFORMAT,report_format);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,' FROM_DATE='||:BLK_INPUT.FROM_DATE||' TO_DATE='||:BLK_INPUT.TO_DATE||' paramform=no');
hidden_action := hidden_action ||'&report='||GET_REPORT_OBJECT_PROPERTY(report_id,REPORT_FILENAME);
hidden_action := hidden_action||'&destype='||GET_REPORT_OBJECT_PROPERTY(report_id,REPORT_DESTYPE);
hidden_action := hidden_action||'&desformat='||GET_REPORT_OBJECT_PROPERTY (report_id,REPORT_DESFORMAT);
hidden_action := hidden_action ||'&userid='||get_application_property(username)||'/'||get_application_property(password)||'@'||get_application_property(connect_string);
c_old :='@';
FOR i IN 1..LENGTH(report_otherparam) LOOP
c_new:= substr(report_otherparam,i,1);
IF (c_new =' ') THEN
c:='&';
ELSE
c:= c_new;
END IF;
-- eliminate multiple blanks
IF (c_old =' ' and c_new = ' ') THEN
null;
ELSE
v_report_other := v_report_other||c;
END IF;
c_old := c_new;
END LOOP;
hidden_action := hidden_action ||'&'|| v_report_other;
hidden_action := reports_servlet||'?_hidden_server='||report_server_name|| encode(hidden_action);
SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,'pfaction='||hidden_action||' '||report_otherparam);
-- run Reports
report_message := run_report_object(report_id);
rep_status := report_object_status(report_message);
IF rep_status='FINISHED' THEN
vjob_id :=substr(report_message,length(report_server_name)+2,length(report_message));
message('job id is'||vjob_id);pause;
WEB.SHOW_DOCUMENT(reports_servlet||'/getjobid'||vjob_id||'?server='||report_server_name,' _blank');
ELSE
--handle errors
null;
END IF;
In the code - " hidden_action := hidden_action ||'&'|| v_report_other; " in the RUN_REPORT_OBJECT_PROC procedure above, how do i make sure that the v_report_other variable reflects the user input parameters FROM_DATE and TO_DATE ??? v_report_other is initialised as v_report_other VARCHAR2(4000) :=''; in the procedure. Will ensuring that the v_report_other contains the user input parameters FROM_DATE and TO_DATE ensure that my report will run fine for the input parameters?
Thanks in advance.
Edited by: user10713842 on Apr 7, 2009 6:05 AM -
Duplicating Data Sets depending on input parameters
I originally posted this question as part of Oracle Reports but I think its not really an Oracle Report issue, its more an SQL Issue. I am on Oracle 9i.
I need to generate a Report that is based on a maximum of 6 input parameters.
Three of them belong to Customer ID# and 3 belong to Number of Copies that need to be printed on the Report.
Parameters for Customers: P_CUST_ID1, P_CUST_ID2, P_CUST_ID3
Parameters for the Number of Copies: P_N1, P_N2, P_N3
So, at any given point, there could be a maximum of 3 Customer ID's passed to the main query. Here is an example of what the input parameters could look like.
User chose to enter values for Customer ID's 1 and 2 and left it blank for Customer 3.
Customer ID1 1001 Number of Copies 2
Customer ID2 1002 Number of Copies 3
Customer ID3 ---- Number of Copies -The Query that retrieves data looks something like this. The query below is intended to fetch Customer Home and Office Addresses.
Of course, it is possible that there might be No home or Office Address or both.
SELECT c.cust_no,
c.saln||c.first_name||' '||c.last_name cust_name,
a.address_type,
a.street,
a.city||' '||a.province||' '||a.postal_code city,
'('||a.tel_area||') '||a.tel_number telephone
FROM customer c, customer_address a
WHERE c.cust_no = a.cust_no
AND c.cust_no IN (:P_CUST_ID1, :P_CUST_ID2, :P_CUST_ID3);Based on my query:
Customer ID 1001 has 3 Addresses (2 Home and 1 Office) --> Total number of Records = 3
Customer ID 1002 has 2 Addresses (1 Home and 1 Office) --> Total number of Records = 2
The output should be something like this. I have put a Label Copy1, Copy2 and Copy3 to show
how the data will appear for readability.
Cust No Customer Name Address Type Address Line 1 Address Line 2 Telephone
Copy1
1001 Mr Robert Green H 2100 Picket Fences Vancouver BC V6E 2C9 (604)726-5555
1001 Mr Robert Green H 2300 Happy Valley Vancouver BC V6G 2N8 (604)308-5555
1001 Mr Robert Green O 1200 Davie Street Vancouver BC V1V 1X1 (604)211-5555
Copy2
1001 Mr Robert Green H 2100 Picket Fences Vancouver BC V6E 2C9 (604)726-5555
1001 Mr Robert Green H 2300 Happy Valley Vancouver BC V6G 2N8 (604)308-5555
1001 Mr Robert Green O 1200 Davie Street Vancouver BC V1V 1X1 (604)211-5555
Copy1
1002 Ms Cynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416)432-5555
1002 Ms Cynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416)321-5555
Copy2
1002 Ms Cynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416)432-5555
1002 Ms Cynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416)321-5555
Copy3
1002 Ms Cynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416)432-5555
1002 Ms Cynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416)321-5555Scripts for the table creation and INSERTs
CREATE TABLE CUSTOMER
"CUST_NO" VARCHAR2(4 BYTE) NOT NULL,
"SALN" VARCHAR2(4 BYTE),
"FIRST_NAME" VARCHAR2(20 BYTE),
"LAST_NAME" VARCHAR2(20 BYTE),
CONSTRAINT "CUSTOMER_PK" PRIMARY KEY ("CUST_NO")
Insert into CUSTOMER values ('1001','Mr','Robert','Green');
Insert into CUSTOMER values ('1002','Ms','Cynthia','Brown');
Insert into CUSTOMER values ('1003','Dr','David','Taylor');
CREATE TABLE CUSTOMER_ADDRESS
"CUST_NO" VARCHAR2(4 BYTE) NOT NULL ENABLE,
"ADDRESS_TYPE" VARCHAR2(1 BYTE) NOT NULL ENABLE,
"STREET" VARCHAR2(20 BYTE),
"CITY" VARCHAR2(20 BYTE),
"PROVINCE" VARCHAR2(2 BYTE),
"POSTAL_CODE" VARCHAR2(10 BYTE),
"TEL_AREA" VARCHAR2(3 BYTE),
"TEL_NUMBER" VARCHAR2(10 BYTE)
Insert into CUSTOMER_ADDRESS values ('1001','H','2100 Picket Fences','Vancouver','BC','V6E 2C9','604','726-5555');
Insert into CUSTOMER_ADDRESS values ('1001','H','2300 Happy Valley','Vancouver','BC','V6G 2N8','604','308-5555');
Insert into CUSTOMER_ADDRESS values ('1001','O','1200 Davie Street','Vancouver','BC','V1V 1X1','604','211-5555');
Insert into CUSTOMER_ADDRESS values ('1002','H','261 King Street W','Calgary','AB','M5A 1N1','416','432-5555');
Insert into CUSTOMER_ADDRESS values ('1002','O','150 Bloor St W','Calgary','AB','M1W 1S3','416','321-5555');
Insert into CUSTOMER_ADDRESS values ('1003','O','435 Richmond Street','Calgary','AB','M5A 4T6','416','453-5555');Any help or pointers in this regard would be great.
I could have adopted a procedure to use Temporary tables but I really would prefer not going in that direction as there could be quite a few reports that need to be generated in this manner.
Thanks and have a great weekend.Hi,
Roxyrollers wrote:
Hi Frank,
Here is my piece of code that I was working on Friday... Okay, but what's wrong with the solution I posted on Saturday?
WITH report_parameters AS
SELECT :p_cust_no_1 AS cust_no, :p_no_copies_1 AS no_copies FROM dual UNION ALL
SELECT :p_cust_no_2 AS cust_no, :p_no_copies_2 AS no_copies FROM dual UNION ALL
SELECT :p_cust_no_3 AS cust_no, :p_no_copies_3 AS no_copies FROM dual
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (no_copies) AS max_no_copies
FROM report_parameters
CONNECT BY LEVEL <= max_no_copies
SELECT c.cust_no,
c.saln||c.first_name||' '||c.last_name cust_name,
a.address_type,
a.street,
a.city||' '||a.province||' '||a.postal_code city,
'('||a.tel_area||') '||a.tel_number telephone
, t.n -- If wanted
FROM customer c
, customer_address a
, report_parameters p
, cntr t
WHERE c.cust_no = a.cust_no
AND c.cust_no = p.cust_no
AND p.no_copies >= t.n
ORDER BY c.cust_no
, t.n
, a.address_type
;Output, given your sample data and parameters:
CUST CUST_NAME A STREET CITY TELEPHONE N
1001 MrRobert Green H 2100 Picket Fences Vancouver BC V6E 2C9 (604) 726-5555 1
1001 MrRobert Green H 2300 Happy Valley Vancouver BC V6G 2N8 (604) 308-5555 1
1001 MrRobert Green O 1200 Davie Street Vancouver BC V1V 1X1 (604) 211-5555 1
1001 MrRobert Green H 2100 Picket Fences Vancouver BC V6E 2C9 (604) 726-5555 2
1001 MrRobert Green H 2300 Happy Valley Vancouver BC V6G 2N8 (604) 308-5555 2
1001 MrRobert Green O 1200 Davie Street Vancouver BC V1V 1X1 (604) 211-5555 2
1002 MsCynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416) 432-5555 1
1002 MsCynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416) 321-5555 1
1002 MsCynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416) 432-5555 2
1002 MsCynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416) 321-5555 2
1002 MsCynthia Brown H 261 King Street W Calgary AB M5A 1N1 (416) 432-5555 3
1002 MsCynthia Brown O 150 Bloor St W Calgary AB M1W 1S3 (416) 321-5555 3 WITH DOES work in Oracle 9.1, and higher. Are you getting an error message that starts with "SP"? Those are SQL*Plus errors, that occur before your code is even sent to the database. In extremely old versions of SQL*Plus, a statement cannont begin with the keyword WITH. The best solution is to upgrade SQL*Plus, but you could also re-wqrite the query so WITH is not the first word of the statement. In this case, you could also use in-line views instead of WITH.
I tried to generate duplicate data sets as a Sub-Query like RP suggested and it seems to be working except the ordering seems to be messed up for Mr Robert Green. The correct order should have been Home, Home, Office and then Home, Home, Office again...The order above seems to be what you want, but there are many different reasons why a small set of sample data might just happen to appear in the right order.
Explain why you want that order. If you can say what you want in English, somebody can help you code it in SQL.
I don't recommend any solution that uses UNION. It will be inefficient, and difficult to debug and to maintain. -
Pluggable Mappings and Input Parameters
Hi All,
I have a mapping which receives 2 input parameters. I have created a pluggable mapping to which I would like to pass those same values. Is is possible to pass parameter values into a pluggable mapping such that these values are NOT part of the input signature?
thanks
Ok, I have more information. When I deploy my mapping, I found the following code commented out of the main procedure:
-- register custom input parameters:
-- Temp fix until selective registration ensures correct handling of complex types
-- wb_rt_mapaudit_util.register_custom_param(x_audit_id,
-- '"MY_PARAM"',
-- TO_CHAR("MY_PARAM"));
What is the "selective registration" that they mention and how do I do it?
thanks, again
Edited by: philip_b on Mar 26, 2010 8:39 AMThanks for responding David. I am using Client: 10.2.0.1.31 and Repo: 10.2.0.1.0
I was hoping I didn't have to include it in the signature because I didn't want these values to be part of the incoming dataset; that just complicates the mapping logic for me.
It would make sense to me that the pluggable mapping should have access to the parent mapping's parameter values.
Why is the parameter registration code commented out inside the generated package? Do you know what it is referring to when it mentions "selective registration"? I can't find any reference to it:-/
Someone else had the same issue last year on the following thread, but there were no responses to the issue:
wb_rt_mapaudit_util register_custom_param call commented out in gen'd sql -
Audit input parameters in package by access
Hi Gurus,
I recently activated the audit_trail parameter in init.ora file so i can audit the database. I want to audit de input parameters of a package. This could be possible ??...
Regards!!
Pablo.-
Edited by: PabloArroyo on Nov 7, 2012 6:09 PMYes, it is recorded in sql_text.dba_audit_trail. See demo :
C:\Windows\system32>sqlplus scott/tiger
SQL*Plus: Release 11.2.0.1.0 Production on Thu Nov 8 10:20:42 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter audit_trail;
NAME TYPE VALUE
audit_trail string DB_EXTENDED
SQL> set line 200;
SQL> create or replace procedure sp(num in number)
2 is
3 begin
4 dbms_output.put_line(num);
5 end;
6 /
Procedure created.
SQL> create or replace package p is
2 procedure sp(num in number);
3 end;
4 /
Package created.
SQL> create or replace package body p is
2 procedure sp(num in number)
3 is
4 begin
5 dbms_output.put_line('Executing Package:');
6 end;
7 end;
8 /
Package body created.
SQL> audit execute on sp by access;
Audit succeeded.
SQL> audit execute on p by access;
Audit succeeded.
SQL> exec sp(12);
12
PL/SQL procedure successfully completed.
SQL> exec p.sp(15);
Executing Package:
PL/SQL procedure successfully completed.
SQL> alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
Session altered.
SQL> column timestamp format a20
SQL> column owner format a10
SQL> column obj_name format a10
SQL> column action_name format a20
SQL> column sql_text format a20
SQL> select timestamp, owner, obj_name, action_name,sql_text from dba_audit_trail
2 where obj_name='P'
3 and owner='SCOTT';
TIMESTAMP OWNER OBJ_NAME ACTION_NAME SQL_TEXT
08-NOV-2012 10:43:19 SCOTT P EXECUTE PROCEDURE BEGIN p.sp(15); END;
SQL> select timestamp, owner, obj_name, action_name,sql_text from dba_audit_trail
2 where obj_name='SP'
3 and owner='SCOTT';
TIMESTAMP OWNER OBJ_NAME ACTION_NAME SQL_TEXT
08-NOV-2012 10:43:00 SCOTT SP EXECUTE PROCEDURE BEGIN sp(12); END;
SQL>So, we can get the package's procedure input parameter value from sql_text column of dba_audit_trail.
Regards
Girish Sharma -
Input Parameters to call PLSQL
Hello all.
I need to call a PLSQL procedure, using ADF BC. No problem to create the AppModule and call the procedure using a button and a text box in my page (the text box is for a String input parameter). What I need is to use the value from an input text box from a VO as my input parameter. What is the best way to accomplish this?
What I have done so far:
1) Created a managed bean, copying the value from text_a (from the VO) to text_b. Text_b is the input text field. But I need to render both text_a and text_b to accomplish this. What is the best practice in this case?
I am using JDeveloper 11.1.2.1
Thanks in advanceI assume, you have created a method in AMImpl that takes the input parameters & that are passed to store procedure.
1) Create a binding for the inputText component in the managed bean.
2) Have an actionlistener method for the button in the managed bean. In that method, get handle to the methodAction as operationBinding & set the required parameters and call execute method on the operation binding.
Thanks,
Navaneeth -
DBMS_SCHEDULER.CREATE_PROGRAM with Optional input parameters
I have a procedure that has a number of "optional" parameters.
procedure get_files(
file_name_in in varchar2 default 'dummy_file',
layout_in in number default 1,
client_in in number default null,
data_supplier_in in number default 99999
This procedure can be called with any combination of the input parameters.
I can set up program(s) using the DBMS_SCHEDULER.CREATE_PROGRAM procedure using a program_type => 'PLSQL_BLOCK' like this:
begin
sys.dbms_scheduler.create_program(
program_name => 'GET_MY_FILES',
program_action => '
declare
begin
get_files( layout_in => 11111, client_in => 2222 );
end ;',
program_type => 'PLSQL_BLOCK',
number_of_arguments => 0);
end;
My question is: Can I set up programs(s) using the DBMS_SCHEDULER.CREATE_PROGRAM procedure using a program_type => 'STORED_PROCEDURE' when I have "optional" parameters?
It appears that ALL of the program input parameters must be defined and there is no way to indicate that a parameters is "optional".Yes you can do it.
You can defined default values for program parameters, but this values are "constants". So if your default value of parameter is defined by function call you have a problem, because you have to specify this parametr every time.
procedure my_proc(p_date IN DATE := SYSDATE) AS
...There is my example, it using DBADMIN schema create this schema or replace it.
create or replace procedure dbadmin.sleep(p_interval in number)
as
begin
dbms_lock.sleep(p_interval);
end;
--program definition
begin
dbms_scheduler.create_program(program_name => 'dbadmin.prg_test1',
program_type => 'STORED_PROCEDURE',
program_action => 'dbadmin.sleep',
number_of_arguments => 1);
dbms_scheduler.define_program_argument(program_name => 'dbadmin.prg_test1',argument_position => 1,argument_type => 'NUMBER',default_value => 60);
dbms_scheduler.enable(name => 'dbadmin.prg_test1');
end;
--check that program was created
select * from dba_scheduler_programs
where owner='DBADMIN';
select * from dba_scheduler_program_args
where owner='DBADMIN';
BEGIN
dbms_scheduler.create_job(job_name => 'dbadmin.job_program1',
program_name => 'dbadmin.prg_test1',
start_date => to_timestamp_tz('1.1.2010 12:00 Europe/Prague', 'dd.mm.yyyy hh24:mi tzr'),
repeat_interval => 'FREQ=minutely; INTERVAL=2;BYSECOND=0',
auto_drop => FALSE);
dbms_scheduler.enable(name => 'dbadmin.job_program1');
END;
--job run checks
SELECT *
FROM dba_scheduler_jobs j
WHERE j.JOB_NAME = 'JOB_PROGRAM1';
SELECT *
FROM dba_scheduler_job_log jl
WHERE jl.JOB_NAME = 'JOB_PROGRAM1';
SELECT *
FROM dba_scheduler_job_run_details jr
WHERE jr.JOB_NAME = 'JOB_PROGRAM1';
--now set job parametr
BEGIN
dbms_scheduler.set_job_argument_value(job_name => 'dbadmin.job_program1', argument_position => 1, argument_value => 30);
END;
--clean up
BEGIN
dbms_scheduler.drop_job(job_name => 'dbadmin.job_program1', force => TRUE);
dbms_scheduler.drop_program(program_name => 'dbadmin.prg_test1');
dbms_scheduler.purge_log;
END;
/ -
SQLPLUS Acitivity in process flow Input parameters to the script
I have a sqlplus Activity in the process flow. In the script section I have a update statement which has a where clause where I need to pass a date field as input paramter to this script to compare and update the records.
Is there a way to pass Input Parameters to the script.
update test
set last_name = 'TEST'
where trunc(begin_date) = :begin_date;
Begin_date is a variable in my process flow which I need to pass to this script.
Any ideas as to how I can accomplish this.
Thanks in advance.You can Create a procedure of the Update statement with one input paramenter like
Create Or replace procedure Update_test ( p_begin_date date )
IS
update test
set last_name = 'TEST'
where trunc(begin_date) = p_begin_date;
End;Then call this Procedure in the Process Flow and give input parameter from PF variable.
Cheers
Nawneet
Maybe you are looking for
-
TS1559 WiFi greyed out - no WiFi on iPhone 4s with iOS 6.1.3
Two days ago I discovered my phone was suffering from the popular "Greyed out WiFi" syndrome. On Settings> General> About the WiFi address appears as N/A. Bluetooth is working normally. I have tried everything I have found on the matter on the Intern
-
Error in synchronous( abap proxy to soap)scenario
Hi experts, My scenario is synchronous abap proxy to sysnchronous soap. for proxy I am using business system name as ERDCLNT220 and soap business system name as BS_HRS_DEV configuration steps are 1. only client proxy to soap scenario I have done. com
-
How to catch the dynamic data on the other webside to BIEE?
i want to achieve the update data everytime in BIEE dashboard, sunh as Dow Jones Indexes i want to catch it in other website and to display it in my BIEE's dashboard? how to realize it ? may be should use the oracle database.i hope can get a step by
-
Hello, I'm taking a PhoneGap Mobile Apps class this semester in college. I'm using Win7, with CS6. We are the ginny-pig class. First time being taught at school. Please explain.We are using Dreamweaver as our IDE? Now I need to download the PhoneGap
-
Where is Photoshop Help?
I can't remember the last time I used Photoshop Help because I don't use Photoshop much. Tried it today and nothing happens. My menu bar switches from Photoshop to Adobe Help Center but no Help window opens in Safari or anywhere else. Help Prefs are