How to write a procedure using collections
How can we define the collections inside the procedure and use itI get an error of execution of this proc
create or replace procedure p_collections
is
type calendar is varray(366) of date;
calendar c1;
begin
for i in 1 .. 100
loop
select sysdate bulk collect into c1 from dual;
end loop;
DBMS_OUTPUT.PUT_LINE(c1);
end;
Published by: Rahul_India on Sep 12, 2012 14:54Published by: Rahul_India on Sep 12, 2012 15:07
Hello
Rahul_India wrote:
I found the errorit should be c1 calendar;
How can I print the values of 100 dates stored in the varray
If you had 100 DATEs stored in the array, we can say:
... FOR i IN 1 .. 100
LOOP
dbms_output.put_line (c1 (i));
END LOOP;
Since you have only 1, which will trigger an error.
You might be better to use the attributes of the FIRST and the LAST:
... FOR i IN c1.FIRST .. c1.LAST
LOOP
dbms_output.put_line (c1 (i));
END LOOP;
Tags: Database
Similar Questions
-
How to write a procedure to call and run the custom package backend
Hi all
Oracle 10g
Oracle Apps R12
I work with here oracle order management, we have a package called (Pick Release) to customize. Due to a problem, we have this concurrent program execution manually giving Route_id as parameter. The route_id comes from the road to the Table. By using this query
Select distinct route@DB_LINK_APPS_TO_ROADSHOW route_id
When trunc (route_date) = trunc (sysdate + 2).
on a daily basis, we have almost 42 routes and we run this simultaneous program manually close times.
so now how to write a procedure for this
Step 1 make the route to the routing table. (By cursor we can get the route_id accordingly)
Step 2 How to trigger custom backend package and run accordingly to this output of the cursor (route_id)
If 40 routes of cursor get is - that the simultaneous program runs 40 times according to this route_id.
can some could provide the steps to do this
Thanks and greetings
Srikkanth.MTo submit a competing request from the back - end:
FND_REQUEST. SUBMIT_REQUEST (Client or server)
Summary
function FND_REQUEST. SUBMIT_REQUEST
(application IN varchar2 default NULL,
program IN varchar2 NULL by default,
Description IN varchar2 default NULL,
start_time IN varchar2 default NULL,
sub_request IN default boolean FALSE
Argument1,
argument2,..., argument99.
Return to argument100 number);
Description
Submits a competing treatment by a simultaneous Manager. If the query is successful, this function returns the ID of the concurrent request; Otherwise, it returns 0.
ATTENTION: FND_REQUEST needs to know information about the user and accountability whose application is submitted. Therefore, this feature works of concurrent programs or forms within the Oracle Applications.
The FND_REQUEST. SUBMIT_REQUEST function returns the ID of the concurrent application after successfully. It is up to the caller to issue a commit to complete the application.
Your code should retrieve and handle the error message generated if there is a problem of presentation (the ID of the concurrent request returned is 0). Use FND_MESSAGE. RETRIEVE and FND_MESSAGE. ERROR to retrieve and display the error (if the application is made on the client side).
Related essays: overview of the Message dictionary (see page)
You must call FND_REQUEST. SET_MODE before calling FND_REQUEST. SUBMIT_REQUEST of a database trigger.
If FND_REQUEST. SUBMIT_REQUEST fails to go anywhere but a database trigger, database changes are cancelled until the time of the function call.
After a call to the FND_REQUEST. SUBMIT_REQUEST function, installation of all parameters are reset to their default values.
Arguments (input)
short name of the application associated with the concurrent request for enforcement.
short simultaneous program (not the executable) name of the program for which the application must be made.
Description Description of the application that appears in the form of concurrent requests (optional).
start_time time during which demand is expected to start running in the (optional) HH24 or HH24:MI:SS format.
sub_request set to TRUE if the request is made by another application and should be treated as a subquery.
From version 11, this parameter can be used if you submit requests for in a concurrent program of PL/SQL stored procedure.
argument1... 100 arguments for the concurrent request; up to 100 arguments are allowed. If the Oracle Forms submitted, you must specify all arguments of 100. -
How to write a file using BB 10 HTML5WebWorks
Hello
How to write a file using Blackberry 10 HTML5WebWorks API.
https://developer.BlackBerry.com/HTML5/API/BlackBerry.IO.file.html#.SaveFile
The example above does not work in BB 10.
Please guide me.
Of course, look at line 95 of this file:
https://github.com/BlackBerry/BB10-WebWorks-samples/BLOB/master/invoke/invoker/invocations.js
-
How to write a procedure to recover data in a collection of a table?
create or replace type of subject as object)
number of subject_id,
subject_Desc varchar2 (50)
)
/
create or replace type Subjects_All in the varray (10) of the subject
/
create table (student)
StudentID varchar (10),
Subjects_all topics
);
so, how can I write a procedure to display information like this:
Topics:
101 "Mathematics".
102 'science '.
Topics:
...
I've written a procedure similar to the following, but it didn't work enough :(
CREATE OR REPLACE PROCEDURE StudentLoop AS
all_subj subjects_all;
subject to each_subj;
CURSOR all_subjectsrow IS select * from the student;
BEGIN
FOR all_subj IN all_subjectsrow LOOP
FOR each_subj IN all_subj LOOP
DBMS_OUTPUT. Put_line ('last selected line a ID' | each_subj.subject_id | each_subj.subject_desc);
END LOOP;
END LOOP;
END StudentLoop;
Any advice?Well, it would help if you post the code that produces this result. I'm suspecting try you at the exit of the integer type and not it's content:
SQL> insert into student(studentid, subjects) values (1, subjects_all(subject(1, 'MATH'), subject(2, 'SCIENCE'))); 1 row created. SQL> select * from student; STUDENTID |SUBJECTS(SUBJECT_ID, SUBJECT_DESC) ----------|----------------------------------------------------------------------------------------------------------------------------------- 1 |SUBJECTS_ALL(SUBJECT(1, 'MATH'), SUBJECT(2, 'SCIENCE')) SQL> declare 2 cursor all_subjectsrow is select * from student; 3 begin 4 for rStudent in all_subjectsrow loop 5 for i in 1..rStudent.subjects.count loop 6 dbms_output.put_line(rStudent.subjects(i).subject_id||' '||rStudent.subjects(i).subject_desc); 7 end loop; 8 end loop; 9 end; 10 / 1 MATH 2 SCIENCE PL/SQL procedure successfully completed.
see you soon
-
How to change a procedure using sqlplus...
command to change a procedure using sqlplusHello
Laughing says:
command to change a procedure using sqlplusYou cannot change a procedure in the way that you can, say, ALTER TABLE; all you can do is CREATE OR REPLACE PROCEDURE..., with the definition of the whole procedure.
Do the actual editing in a text editor. Any editor will do. You can even use a word processor, if you think to save it as text only.
If you don't have a copy of the procedure as it is, and then use dbms_metadata, or query a view of data as all_source dictionary to get a.
In SQL * Plus, run the file that you have edited by saying:
SQL> @pathname\filename
-
How to write a procedure?
Hi all
I am using oracle 11g,
I have the table as
EmpID, ename
1 x
2 Y
3 Z
4 M
5 N
6 P
7 Q
8 R
I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column
as if I spend empid, it should show all emp_id
Concerning
Dale
SQL > create or replace procedure test_proc (p_col_name in varchar2,
res 2 the sys_refcursor)
3 is
4 start
5. open to
6 ' select '. p_col_name | "" employee ";
7 end;
8.
Created procedure.
PL/SQL procedure successfully completed.
SQL > var res refcursor
SQL > start
2 test_proc ('employe_id',: res);
3 end;
4.
PL/SQL procedure successfully completed.
SQL > print;
EMPLOYEE_ID
-----------
100
101
102
103
104
105
106
107...
Hello
Above code will be useful
913349 wrote:
I need a procedure if I pass any column in the procedure, then it should should show all data for a particular column
as if I spend empid, it should show all emp_id
Concerning
Dale
See you soon,.
Suri ;-)
Post edited by: Suri
Misunderstood the requirement. Now, I fixed it -
How to write queries nested using the DB adapter?
I want to write a request nested by using the help DB adapter box...
SELECT INVOICE_ID, FILE_NAME IN BILLING_INVOICE_PDF_V where FILE_ID =)
(SELECT MAX (FILE_ID) FROM BILLING_INVOICE_PDF_V WHERE (INVOICE_ID = '12345'))) ;
Thank you
RAM.
Hi Ram,
It's probably the semicolon at the end of the SQL statement that causes the db adapter for error; Simply enter the SQL custom without a semicolon at the end.
SELECT INVOICE_ID, FILE_NAME IN BILLING_INVOICE_PDF_V where FILE_ID = (SELECT MAX (FILE_ID) OF BILLING_INVOICE_PDF_V WHERE INVOICE_ID = '12345')
-
How to write living expressions using Extendscipt?
Hello
I'm trying to write a script for after effects CC using Extendscript. I was wondering if it is possible to add living property of layers as expressions
"
thisComp.layer(
"Layer 1"
).transform.position" and so on.
Hoping that it is possible.
Thanks in advance
Don't know what you mean by 'Live', but adding an expression to a property is fairly simple with ExtendScript.
If you have a variable path or directly to your layer...
LAYER_OBJECT. transform.position.expression = "o = wiggle (5, 10) \rw"; The \r is a carriage return, or you can use \n for the new line. Both work on Mac. Showing that just in case you need expression multiline.
-
How to create a procedure using unit program
Hai All
II have created a procedure like this
PROCEDURE Duty_calc
IS
procedure w_Time
is
Start
Update dail_att set wtime = (select lpad ((to_number (to_char(outtime,'hh24mi')-to_char(intime,'hh24mi'))), 4: 0) in the dail_att where attend_date = f_date);
end w_time;
Start
If wtime > 0830 then
Update etime set dail_att = (select lpad(wtime-0830) from the dail_att where attend_date = f_date);
on the other
null;
end if;
duty_calc;
end duty_calc;
And I declare in unity of programs such as Duty_calc and whereas I will carry out my procedure I got an error
What must I declare a my procedure internal in my program unit
Concerning
Srikkanth.MJust write the name of the procedure simple no need to CALL
my_Proc;
-
How to write a procedure for setting Out when the condition fails
Here's my query, it works very well when the condition is fulfilled with the valid user ID and password
create or replace
PROCEDURE ISVALIDUSER / * this is procedure created to validate the connection information to users created on 09212012 by Charbonneau * /.
(
pUSERID IN VARCHAR2,
Ppassword IN VARCHAR2,
pUSERTYPE OUT NUMBER
)
AS
tmpUSERID VARCHAR2 (30);
tmpPASSWORD VARCHAR2 (150);
tmpIsative VARCHAR2 (10);
BEGIN
SELECT Userid, PASSWORD IN tmpUSERID, tmpPASSWORD FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = Ppassword AND isactive = "Y";
/ * Check ID USER Existed or not * / / * PASSWORD verification is Existed or not * /.
IF tmpPASSWORD = AND tmpuserid = pUSERID THEN pPassword
USERTYPE of SELECT INTO pUSERTYPE FROM USERMASTER WHERE USERMASTER. USERID = pUSERID and USERMASTER. PASSWORD = pPassword;
ON THE OTHER
BEGIN
1 SELECT INTO pUSERTYPE FROM DUAL;
END;
END IF;
END;
Here I am facing a problem when I get invalid user or password ID it is failed - 1 in pUSERTYPE which is OUT setting
Please suggestYou need to read about the exceptions - {message identifier: = 9360013}
create or replace PROCEDURE ISVALIDUSER /*This is Procedure created to validate Login users information Created on 09212012 by Chakravarthy*/ ( pUSERID IN VARCHAR2, pPASSWORD IN VARCHAR2, pUSERTYPE OUT NUMBER ) AS tmpIsative VARCHAR2(10); BEGIN SELECT USERTYPE INTO pUSERTYPE FROM USERMASTER WHERE USERMASTER.USERID=pUSERID and USERMASTER.PASSWORD=pPASSWORD AND isactive='Y'; exception when no_data_found then pUSERTYPE := -1; END;
You store your password without encrypting? One who is to have access to your table will see the password...
-
How to return rows by using the procedure?
Example: There are 3 areas: A, B, C and each region has some people.
create table person (name varchar2 (2), area varchar2 (2));
insert into values('A1','A') of the person; -1st rank
insert into values('A2','A') of the person; -line 2
insert into values('A3','A') of the person; -tier 3
insert into values('A4','A') of the person; -tier 4
insert into values('B1','B') of the person; -tier 5
insert into values('C1','C') of the person; -tier 6
insert into values('C2','C') of the person; -line 7
result as follows:
A, B AND C
--------------
A1 B1 C1
A2 C2
A3
A4
If we ' select * from person ", then we had all the lines.
I want to now choose volunteers in all areas, the rule is to pick one person from each region ordered, until that N people are selected. If N = 6, the sequence is
A1, A3, A2, B1, C1, C2
and want to return lines 1,5,6,2,7,3 (order of lines is not important) of the person.
How to create a procedure for this? And I want to return as rows returned by a select phrase. (can be easily filled in a DataTable object and then be used in a program).
Thank you!!
Hello
2985493 wrote:
Thank you. Could you write a procedure to do the job? This is just an example, real choice rule is complicated enough to be used by the procedure and the cursor. I wonder how do to write a procedure returns the result as a select phrase.
Here's one way:
VARIABLE c REFCURSOR
CREATE OR REPLACE PROCEDURE top_by_area
(csr ON SYS_REFCURSOR
, n_to_return IN PLS_INTEGER: = 6
)
IS
BEGIN
OPEN FOR CSR
WITH got_area_num AS
(
SELECT name, area
OF the person
ORDER BY ROW_NUMBER () (PARTITION BY AREA
ORDER BY name
)
area
)
SELECT name, area
ROWNUM AS r_num
OF got_area_num
WHERE ROWNUM<=>=>
ORDER BY r_num
;
END top_by_area;
/
DISPLAY ERRORS
EXEC top_by_area (: c);
PRINTING: c
PRINT the output of the command, given your sample data is:
R_NUM DOMAIN NAME
---- ---- --------
A1 1
B1 B 2
C1, C 3
A2 4
C2 C 5
A3 A 6
It's just a way to create and test the procedure. I don't know how you plan to use it.
-
How to write the CLOB parameter to a file or a XML using shell script?
I run an oracle stored procedure using shell script. How can I get the OUT of the procedure (CLOB) parameter and write it to a file or a XML in UNIX environment using shell script?
Edit/Delete MessageSQL> var c clob SQL> SQL> begin 2 select 3 DBMS_XMLGEN.getXML( 4 'select rownum, object_type, object_name from user_objects where rownum <= 5' 5 ) into :c 6 from dual; 7 end; 8 / PL/SQL procedure successfully completed. SQL> SQL> set long 999999 SQL> set heading off SQL> set pages 0 SQL> set feedback off SQL> set termout off SQL> set trimspool on // following in the script is not echo'ed to screen set echo off spool /tmp/x.xml select :c from dual; spool off SQL> SQL> --// file size SQL> !ls -l /tmp/x.xml -rw-rw-r-- 1 billy billy 583 2011-12-22 13:35 /tmp/x.xml SQL> --// file content SQL> !cat /tmp/x.xml
1 TABLE BONUS 2 PROCEDURE CLOSEREFCURSOR 3 TABLE DEPT 4 TABLE EMP 5 TABLE EMPTAB -
How can you write a resume using windows Vista Home Basic?
How can I write a resume using windows Vista Home Basic? I put t have microsoft word or office.
Start menu -All Programs - Accessories - Wordpad.
-
How to run a procedure with parameters in pl/sql collections?
I created a procedure with parameter from the collection. Can somone help me how to run a procedure in passing the parameters in the collection.
Package and how to create is successful. But I get the error message when executing the procedure.
ORA-06550: line 3, column 19:
PLS-00222: no function with name 'T_TAB' does exist in this scope
I gave the example of code here. Can someone please help me solve this problem.
-Spec package
create or replace package pkg_dist is
TABLE index IS THE NUMBER of t_tab_num TYPE of PLS_INTEGER;
procedure prc_test (a t_tab_num IN,
b IN t_tab_num,
c IN OUT t_tab_num);
end pkg_dist;
-Package body
create or replace package body is pkg_dist
procedure prc_test (a t_tab_num IN,
b IN t_tab_num,
c IN OUT t_tab_num) is
Start
IF (a (16) = 0) then
(16) c: = 0;
c (17): = 0;
c (18): = 0;
end if;
c (15): = (14)-(15)-a (16);
(16) c: = b (16) /b (17);
c (17): = 50;
(18) c: = a (16) * 2;
end prc_test;
end pkg_dist;
-executeing procedure
declare
TABLE index IS THE NUMBER of t_tab TYPE of PLS_INTEGER;
x t_tab: = t_tab (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
y t_tab: = t_tab (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500);
z t_tab;
BEGIN
pkg_dist.prc_test (x, y, z);
dbms_output.put_line (z (18));
END;
Error:
--------------------------------------------------------------------------------
ORA-06550: line 3, column 19:
PLS-00222: no function with name 'T_TAB' does exist in this scopeMy suggestion would be:
CREATE OR REPLACE PACKAGE pkg_dist IS PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist); END pkg_dist; CREATE OR REPLACE PACKAGE BODY pkg_dist IS PROCEDURE prc_test (a IN SYS.odcinumberlist, b IN SYS.odcinumberlist, c IN OUT SYS.odcinumberlist) IS BEGIN IF (a (16) = 0) THEN c (16) := 0; c (17) := 0; c (18) := 0; END IF; c (15) := a (14) + a (15) + a (16); c (16) := b (16) / b (17); c (17) := 50; c (18) := a (16) * 2; END prc_test; END pkg_dist; / DECLARE x SYS.odcinumberlist; y SYS.odcinumberlist; z SYS.odcinumberlist; BEGIN x := sys.odcinumberlist (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); y := sys.odcinumberlist (0,10,15,20,25,30,35,40,45,50,60,75,100,125,150,200,250,500); z := sys.odcinumberlist (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); pkg_dist.prc_test (x, y, z); DBMS_OUTPUT.put_line (z (18)); END; /
See you soon,.
Manik. -
How to write if another logic using time
Hai All
I have genetating a daily presence for employees, then there are three teams in the company
0815 to 1645, 1200 to 2000 & 1715 at 0145
So first quarter begins a.m. 0815 so I took just before an hour and after a time (0715 to 0915) means so intimate for all trips even.
And there is a pause inbetween time travel, as of now, I coded for only the first post and works very well.
declare
Cursor c1 is
Select the barcode, BARDATE, BARTIME
Of temp_attendance
Group of barcodes, bardate, bartime
ORDER BY barcode, bartime.
Start
to r1 c1 loop
If r1.bartime between 0631 and 0930 may
insert into dail_att (barcode, respondent, attend_date) values
(r1.barcode, r1.bartime, r1.bardate);
on the other
For r in (select empcode, empname, barcode, intimate, intrtimein, introuttime, addin, addout, outtime, dail_att attend_date) loop
If r.intrtimein is null then
Update dail_att set intrtimein is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate and intimate is not null;.
elsif r.intrtimein is not null and r.introuttime is null then
Update dail_att set introuttime = r1.bartime where barcode = r1.barcode and attend_date = r1.bardate and intimate is not null and intrtimein is not null;
elsif r.intrtimein is not null and r.introuttime is not null and r.addin is null then
Update dail_att set addin is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate and intimate is not null and that intrtimein is not null and introuttime is not null;.
elsif r.intrtimein is not null and r.introuttime is not null and r.addin is not null and r.addout is null then
Update dail_att set addout is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate and intimate is not null and intrtimein is not null and introuttime is not null and addin is not null;.
elsif r.intrtimein is not null and r.introuttime is not null and r.addin is not null and r.addout is not null and r.outtime is null then
Update dail_att set outtime is r1.bartime where barcode = r1.barcode and attend_date = r1.bardate and intimate is not null and intrtimein is not null and introuttime is not null and addin is not null and addout is not null;.
end if;
end loop;
end if;
end loop;
commit;
end;
When I use it once works very well and the next day when I added the next synchronization in the if clause
If r1.bartime between 0631 and 0930 and r1.bartime between 1100 and 1300
his does not work very well because some employees died in 1230 for interval and its addition of a new line it was not updated in the same line
Then tell how to write some conditional for that
Thanks in advance
Srikkanth.MHi Srikanth,
Please use the code tags to your zip code.
Can you specify your requirement as to what should be the output and under what conditions with some examples of data?
Maybe you are looking for
-
My ts-tb23l hp dvdwbd dvd drive won't recognise dvd-video.
I have a hp Touchsmart 610 with windows 7 and the dvd player does not read video however it will play music. HP 610-1020 a TouchSmart desktop PC. any ideas on why this is. brand new unit.
-
I can't save past 3 (your profile) of the steps in the registration APP HUB. All my details are correct and I am a valid Dreamspark student. I tried a variety of configuration security/OS/browser also. Contacted them by phone and they said that they
-
My updates does not work Code 80070002! pls help
I have problem with this thing, updates really get on my nerve... I tried to follow the instructions to "Get help with this error" I tried everything but still the same problem, please help me to solve this problem, thank you!
-
RES display has changed and now broken HP Solution
I changed my screen native 1920 x 1080 and now when I open the solution center to analyze, he made a first pass and that's it. The other buttons I need to finish with are not highlighted click on the top of the page where original scan and also previ
-
Computer hangs at various stage of starting
Original title: allows to start; but never actually gets to the stage of ready. I also ran Kaspersky anti virus more than once. I can't get online without using safe mode. I ran microsoft security scanner which found nothing wrong. My computer freeze