Help!! loop for current procedure
I have a procedure which creates tickets to be printed. However I would like to amend this procedure so that the user can input the number of tickets s/he will be printing and then loop through my current procedure to generate them all at once.
I have been staring at this for 30 min and decided to post. It is probably glaringly obvious, but I am in need of help.
TIA
PROCEDURE create_inv (
MS_ID_IN IN mfg_stations.ms_id%TYPE,
ITEM_CODE_IN IN mfg_stations.item_code_dnmlz%TYPE,
UOM_CODE_IN IN mfg_stations.inv_uom_code_dnmlz%TYPE,
PROCESS_NAME_IN IN mfg_stations.process_name_dnmlz%TYPE,
ZONE_IN IN mfg_stations.zone_dnmlz%TYPE,
LOT_CODE_IN IN mfg_stations.lot_code_dnmlz%TYPE,
GRADE_CODE_IN IN mfg_stations.grade_code_dnmlz%TYPE,
CREATED_QTY_IN IN mfg_stations.created_qty_dnmlz%TYPE,
INV_STATUS_IN IN mfg_stations.inv_status_dnmlz%TYPE,
ret_val_out OUT ret_val_curtype) IS
-- Cursor Var...
new_iu_id inventory_units.iu_id%TYPE;
new_i_id items.i_id%TYPE;
new_im_id item_uoms.im_id%TYPE;
new_g_id grades.g_id%TYPE;
new_l_id locations.l_id%TYPE;
new_mfp_id mfg_processes.mfp_id%TYPE;
new_z_id zones.z_id%TYPE;
created_ts DATE;
mod_ts DATE;
BEGIN
select iu_seq.nextval
into new_iu_id
from dual;
select i_id
into new_i_id
from items
where item_code = item_code_in;
select im_id
into new_im_id
from item_uoms
where inv_uom_code = uom_code_in;
select g_id
into new_g_id
from grades
where grade_code = grade_code_in;
select l_id
into new_l_id
from mfg_stations
where ms_id = ms_id_in;
select mfp_id
into new_mfp_id
from mfg_processes
where l_id = new_l_id
and process_name = process_name_in;
select z_id
into new_z_id
from zones
where zone = zone_in;
select general_pkg.usertime(sysdate),
trunc(general_pkg.usertime(sysdate))
into created_ts,
mod_ts
from dual;
/* INSERT */
insert into inventory_units
IU_ID,
I_ID,
LOT_CODE,
INV_STATUS,
IM_ID,
G_ID,
MFP_ID,
MS_ID,
CREATED_QTY,
CURRENT_QTY,
Z_ID,
CREATED_TIMESTAMP,
MOD_TIMESTAMP,
CB_USER
values
new_iu_id,
new_i_id,
lot_code_in,
inv_status_in,
new_im_id,
new_g_id,
new_mfp_id,
ms_id_in,
created_qty_in,
created_qty_in, /* current gets same initial value as created */
new_z_id,
created_ts,
mod_ts,
user
COMMIT;
/* UPDATE */
UPDATE MFG_STATIONS
SET NEXT_SERIAL_CODE = NEXT_SERIAL_CODE,
LOT_CODE_DNMLZ = lot_code_in,
INV_STATUS_DNMLZ = inv_status_in,
CREATED_QTY_DNMLZ = created_qty_in,
PROCESS_NAME_DNMLZ = process_name_in,
PROCESS_TYPE_DNMLZ = process_type_dnmlz, /* From Database Trigger on insert */
ITEM_CODE_DNMLZ = item_code_in,
GRADE_CODE_DNMLZ = grade_code_in,
ZONE_DNMLZ = zone_in,
INV_UOM_CODE_DNMLZ = uom_code_in
WHERE MS_ID = ms_id_in;
COMMIT;
OPEN ret_val_out FOR
select new_iu_id
from dual;
END;
null
Have you found a solution to this issue?
If not then are the values of the parameters going to change for each loop iteration?
What environment is the procedure executed in? i.e. SQL*Plus, Forms, etc..
Similar Messages
-
Help needed for Stored procedure
I'm using this code for initializing an approval procedure.I want to create an exception for customers whose card code is ,C-KL-KKD -185 & C-KL-TCR-1204 in this procedure.How to do this.Anyone please help.
GO
/****** Object: StoredProcedure [dbo].[SP_Nocil_CreditDays_60] Script Date: 04/04/2014 16:49:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_Nocil_CreditDays_60]
@list_of_cols_val_tab_del NVARCHAR(255), @error_message NVARCHAR(255) OUTPUT
AS
BEGIN
declare @RowCount int
select
@RowCount=COUNT(RDR1.ItemCode)
from ORDR
inner join RDR1 on ORDR.DocEntry=RDR1.DocEntry
inner join OITM on RDR1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N' and isnull(ORDR.U_Approved,'N')='N'
where
ORDR.DocEntry=@list_of_cols_val_tab_del
if @RowCount>0
begin
select @RowCount=0
select
@RowCount=COUNT(OINV.DocEntry)
from
OINV
inner join INV1 on OINV.DocEntry=INV1.DocEntry
inner join OITM on INV1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N'
where
OINV.DocTotal-OINV.PaidToDate>0 and DATEDIFF(Day,OINV.DocDate,GETDATE())>60
and OINV.CardCode=(select ORDR.CardCode from ORDR where ORDR.DocEntry=@list_of_cols_val_tab_del)
if @RowCount>0
begin
select @error_message= 'This document required approval. Please select Approval to "Yes" to continue'
return -1
end
else
begin
return 0
end
end
return 0
EndHi,
Try this:
GO
/****** Object: StoredProcedure [dbo].[SP_Nocil_CreditDays_60] Script Date: 04/04/2014 16:49:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_Nocil_CreditDays_60]
@list_of_cols_val_tab_del NVARCHAR(255), @error_message NVARCHAR(255) OUTPUT
AS
BEGIN
declare @RowCount int
select
@RowCount=COUNT(RDR1.ItemCode)
from ORDR
inner join RDR1 on ORDR.DocEntry=RDR1.DocEntry
inner join OITM on RDR1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N' and isnull(ORDR.U_Approved,'N')='N'
where ORDR.cardcode not in ('C-KL-KKD -185',' C-KL-TCR-1204') and
ORDR.DocEntry=@list_of_cols_val_tab_del
if @RowCount>0
begin
select @RowCount=0
select
@RowCount=COUNT(OINV.DocEntry)
from
OINV
inner join INV1 on OINV.DocEntry=INV1.DocEntry
inner join OITM on INV1.ItemCode=OITM.ItemCode and OITM.U_SeriesGrp='N'
where ORDR.cardcode not in ('C-KL-KKD -185',' C-KL-TCR-1204') and
OINV.DocTotal-OINV.PaidToDate>0 and DATEDIFF(Day,OINV.DocDate,GETDATE())>60
and OINV.CardCode=(select ORDR.CardCode from ORDR where ORDR.DocEntry=@list_of_cols_val_tab_del)
if @RowCount>0
begin
select @error_message= 'This document required approval. Please select Approval to "Yes" to continue'
return -1
end
else
begin
return 0
end
end
return 0
End
Thanks & Regards,
Nagarajan -
Help -Looping in the procedure
Deleting/Closing the Query...
Edited by: k_17 on Oct 12, 2011 5:28 PMhi ,
please let us know what you are trying to achieve .
Thanks,
P Prakash -
Need Help: Dynamically displaying parameter values for a procedure.
Problem Statement: Generic Code should display the parameter values dynamically by taking "package name" and "procedure name" as inputs and the values needs to be obtained from the parameters of the wrapper procedure.
Example:
a) Let us assume that there is an application package called customer.
create or replace package spec customer
as
begin
TYPE cust_in_rec_type IS RECORD
cust_id NUMBER,
,cust_name VARCHAR2(25) );
TYPE cust_role_rec_type IS RECORD
(cust_id NUMBER,
role_type VARCHAR2(20)
TYPE role_tbl_type IS TABLE OF cust_role_rec_type INDEX BY BINARY_INTEGER;
Procedure create_customer
p_code in varchar2
,p_cust_rec cust_in_rec_type
,p_cust_roles role_tbl_type
end;
b) Let us assume that we need to test the create customer procedure in the package.For that various test cases needs to be executed.
c) We have created a testing package as mentioned below.
create or replace package body customer_test
as
begin
-- signature of this wrapper is exactly same as create_customer procedure.
procedure create_customer_wrapper
p_code in varchar2
,p_cust_rec customer.cust_in_rec_type
,p_cust_roles customer.role_tbl_type
as
begin
//<<<<<---Need to display parameter values dynamically for each test case-->>>>>
Since the signature of this wrapper procedure is similar to actual app procedure, we can get all the parameter definition for this procedure using ALL_ARGUMENTS table as mentioned below.
//<<
select * from ALL_ARGUMENTS where package_name = CUSTOMER' and object_name = 'CREATE_CUSTOMER'
but the problem is there are other procedures exists inside customer package like update_customer, add_address so need to have generalized code that is independent of each procedure inside the package.
Is there any way to achieve this.
Any help is appreciated.
// >>>>
create_customer
p_code => p_code
,p_cust_rec => p_cust_rec
,p_cust_roles => p_cust_roles
end;
procedure testcase1
as
l_cust_rec customer.cust_in_rec_type ;
l_cust_roles customer.role_tbl_type;
begin
l_cust_rec.cust_id := 1;
l_cust_rec.cust_name := 'ABC';
l_cust_roles(1).cust_id := 1;
l_cust_roles(1).role_type := 'Role1';
create_customer_wrapper
p_code => 'code1'
,p_cust_rec => l_cust_rec
,p_cust_roles => l_cust_role
end;
procedure testcase2
as
l_cust_rec customer.cust_in_rec_type ;
l_cust_roles customer.role_tbl_type;
begin
l_cust_rec.cust_id := 2;
l_cust_rec.cust_name := 'DEF';
l_cust_roles(1).cust_id := 2;
l_cust_roles(1).role_type := 'Role2';
create_customer_wrapper
p_code => 'code2'
,p_cust_rec => l_cust_rec
,p_cust_roles => l_cust_role
end;
end;Not possible to dynamically in a procedure, deal with the parameter values passed by a caller. There is no struct or interface that a procedure can use to ask the run-time to give it the value of the 1st or 2nd or n parameter.
There could perhaps be some undocumented/unsupported method - as debugging code (<i>DBMS_DEBUG</i>) is able to dynamically reference a variable (see Get_Value() function). But debugging requires a primary session (the debug session) and the target session (session being debugged).
So easy answer is no - the complex answer is.. well, complex as the basic functionality for this do exists in Oracle in its DBMS_DEBUG feature, but only from a special debug session.
The easiest way would be to generate the wrapper itself, dynamically. This allows your to generate code that displays the parameter values and add whatever other code needed into the wrapper. The following example demonstrates the basics of this approach:
SQL> -- // our application proc called FooProc
SQL> create or replace procedure FooProc( d date, n number, s varchar2 ) is
2 begin
3 -- // do some stuff
4 null;
5 end;
6 /
Procedure created.
SQL>
SQL> create or replace type TArgument is object(
2 name varchar2(30),
3 datatype varchar2(30)
4 );
5 /
Type created.
SQL>
SQL> create or replace type TArgumentList is table of TArgument;
2 /
Type created.
SQL>
SQL> -- // create a proc that creates wrappers dynamically
SQL> create or replace procedure GenerateWrapper( procName varchar2 ) is
2 procCode varchar2(32767);
3 argList TArgumentList;
4 begin
5 select
6 TArgument( argument_name, data_type )
7 bulk collect into
8 argList
9 from user_arguments
10 where object_name = upper(procName)
11 order by position;
12
13 procCode := 'create or replace procedure Test'||procName||'( ';
14 for i in 1..argList.Count
15 loop
16 procCode := procCode||argList(i).name||' '||argList(i).datatype;
17 if i < argList.Count then
18 procCode := procCode||', ';
19 end if;
20 end loop;
21
22 procCode := procCode||') as begin ';
23 procCode := procCode||'DBMS_OUTPUT.put_line( '''||procName||''' ); ';
24
25 for i in 1..argList.Count
26 loop
27 procCode := procCode||'DBMS_OUTPUT.put_line( '''||argList(i).name||'=''||'||argList(i).name||' ); ';
28 end loop;
29
30 -- // similarly, a call to the real proc can be added into the test wrapper
31 procCode := procCode||'end;';
32
33 execute immediate procCode;
34 end;
35 /
Procedure created.
SQL>
SQL> -- // generate a wrapper for a FooProc
SQL> exec GenerateWrapper( 'FooProc' );
PL/SQL procedure successfully completed.
SQL>
SQL> -- // call the FooProc wrapper
SQL> exec TestFooProc( sysdate, 100, 'Hello World' )
FooProc
D=2011-01-07 13:11:32
N=100
S=Hello World
PL/SQL procedure successfully completed.
SQL> -
I've tried the listed troubleshooting procedures to activate Facetime and iMessage, but no luck. Are there any other options? If it helps, I'm currently overseas and only using WiFi to connect.
lovethoseleaves,
Oh no! I am saddened to hear that you are having troubles with your MMS pictures. I know that this can be an important thing to be able to do. I appreciate you working with us to get this matter resolved as well. I see that you have spent time working with us, and I know that can also be frustrating. There are a few things we can check though. Are these to any specific numbers or all? A factory reset certainly should've resolved this. We can check into the account set up as well for that if need be. Please share any additional details that you can think of. Thanks.
ErinW_VZWSupport
Follow us on Twitter @VZWSupport -
apple loops for garageband pack doesn't show the folder content (loops, files...) in ableton live suite 8 library browser, but I can see all the loops in the folder from finder. how can i fix this? help please.
Thanks Barney, I tried that but all that comes up in Spotlight are the log files that show the file paths! I don't know how Steam works. Are all the files held by Steam on their server perhaps?
-
I have GarageBand for iPad 2 and noticed that there are far fewer loops for iPad than for apple laptops. Is there a library available of apple loops? I haven't been able to find any if there are. Any help would be greatly appreciated.
Update: An Apple rep called me today to update the status of my return. I was told that the replacements for the BLACK iPad 2's was still another 3 weeks out (at least) so they offered me a brand new WHITE 16GB iPad 2. I could have that or continue waiting. I opted to go ahead and accept the offer of a new white one. Worst case scenario if I don't like the white one I have buddy that just bought a 16GB black one that he would be willing to swap it.
-
Passing an array in a for loop to a procedure
I am trying to pass an array in a cursor for loop to a procedure which performs a table insert using the array's contents. Somehow I am missing something, or it is not possible. The compile error states: PLS-00306: wrong number or types in call to 'insert_address' I checked to be sure I am creating the arrays in both cases from similar data objects. Both address and work_address_table contain the same 4 columns with the same data types.
create or replace package work_address as
FUNCTION populate_address return boolean;
procedure insert_address(in_address IN work_address_table%ROWTYPE);
end work_address;
create or replace package body work_address as
function populate_address return boolean is
cursor c1 is
select 'H' as header,
street1 as street
city as city,
NULL as state
from address
where city = 'HANOVER';
TYPE addressT IS TABLE OF c1%ROWTYPE INDEX BY BINARY_INTEGER;
rec1 addressT;
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT INTO rec1 LIMIT 500;
FOR i IN 1..rec1.count LOOP
rec1(i).state := 'US'
insert_address(rec1(i));
exit when c1%notfound;
END LOOP;
CLOSE c1;
return TRUE;
END populate_address;
PROCEDURE insert_address(in_address IN work_address_table%ROWTYPE) IS
BEGIN
INSERT INTO work_address_table
VALUES (in_address.header,
in_address.street,
in_address.city,
in_address.state);
COMMIT;
END insert_address;
END work address;
/Both address and work_address_table contain the same 4 columns with the same data types.Are you 100% sure about this?
SQL> declare
cursor c1
is
select 1 deptno, dummy dname, 'Loc' location from dual;
type addresst is table of c1%rowtype
index by binary_integer;
rec1 addresst;
procedure p (d dept%rowtype)
as
begin
dbms_output.put_line(d.dname);
end p;
begin
rec1 (1).dname := 'z';
p (rec1 (1));
end;
z
PL/SQL procedure successfully completed.but changing just the first column of the cursor:
SQL> declare
cursor c1
is
select 'xy' deptno, dummy dname, 'Loc' location from dual;
type addresst is table of c1%rowtype
index by binary_integer;
rec1 addresst;
procedure p (d dept%rowtype)
as
begin
dbms_output.put_line(d.dname);
end p;
begin
rec1 (1).dname := 'z';
p (rec1 (1));
end;
Error at line 3
ORA-06550: line 20, column 3:
PLS-00306: wrong number or types of arguments in call to 'P'
ORA-06550: line 20, column 3:
PL/SQL: Statement ignored -
The product that I purchased is not working!!!! I need help and I've been stuck in your "Contact us loop" for the last few days and I'm getting frustrated. How do I contact you for HELP!
Probably the best place to start is the right forum for your product. This is the forum for Distiller Server, a long dead product used by big companies, and probably not what you have. If you can't find the right forum, please let us know the FULL name of what you paid for (please check your invoice, as Adobe have many similar products), and we can perhaps direct you. Good luck!
-
How to know (package , procedures or functions) name for current sessions
Hi all
I'm DBA and i want to find way to get object name whatever (package , procedures or functions) for current running statement in active session.
To clarify when i open session browser from toad i can see active sessions and see current statement for every session but without the name of the object.
Is there any way to know this point.
thanks in advanceselect *
from dba_objects
where object_id in (select nvl(t.PLSQL_ENTRY_OBJECT_ID,-1)
from v$session t
where sid = 452)
Ramin Hashimzade -
Help need for procedure with "cursor in a cursor"
Hi
Iam using two cursors in my procedure.
Create SP_sample as
cursor C1 is
select a from A
cursor C2 is
select
a,bc,d from A,B where A.a=B.a
Begin
For Cur_rec C1 loop
For Cur_rec1 C2 loop
"SELECT QUERY"
end loop
end loop
end
1)the "SELECT QUERY" is working fine in Toad or sql editor.
2)The procedure is compiled without any errors
But when I am executing the procedure I am getting the error
ORA-01403: no data found
ORA-06512: at the line where "SELECT QUERY" is starting
ORA-06512: at line 1
can you please suggest what are the things I should be checking.
ThanksCould you provide a more complete example of what you are doing.
Your example is vague on the details, and it appears that you have 2 cursors both selecting from table A that you are looping through in a nested fashion, but your inner cursor is not correlated with your outer cursor. Also you have skimped on the details of the select you are trying to perform in the inner most loop of your code, and there is no indication that it has any correlation to the two outer cursors, and to top it off you have completely left out any syntactic punctuation.
why not rewrite your code thusly:
declare
cursor c1 is select a from a;
cursor c2(p_a a.a%type) is select bc, d from b where b.a = p_a;
begin
for cur_rec in c1 loop
for cur_rec1 in c2(cur_rec.a) loop
select ...
into ...
from ....
where ??= cur_rec.a
and ??=cur_rec1.bc
and ??=cur_rec1.d;
end loop;
end loop;
end; -
Help required for a Remote cube query
Hi,
We are working on Remote cube, which has a source from a view built on R/3 base table. I need to extract the data to BW based on a current date due to huge volume of data(performance reasons) in the table. I have used an exit on R/3 to restrict to current date but the extract checker was showing the valid data ie only for current date. When i had built a query on Remote cube, the Report was showing complete data(restriction not working). We have even tried using an inversion routine in transfer rules to pass the selections to the Source system even then it doesn't work. Could you help if you have come across same kind of situation or you can suggest an alternate solution on the same but we have to use Remote cube.
Any suggestions asap would be highly appreciated and rewarded with full points.
Regards,
RajI can think of two ways to do it
Simple with no ABAP coding is a view
Create a view between a timestamp table and your big table
Put an entry into your timestamp table of the current date - then use a selection of this inside the view
Unforutunately you cannot use SY fields inside database views (otherwise you could have used these as a selection condition in the view)
The best way to do it is using a function module and passing the data from the query into the SQL statement
I prefer to do it the last way and also pass data through a generic structure - thus you manipulate the data inside the intial loop in the function module and don;t utilise further loops downstream in transfer rules
(to try and keep the reponse time down) -
Need help to fix the Procedure
I found a procedure in the forum. I think Vikash posted this. I update and it is working for comma delimiter records but I want to work it for TAB delimiter. I edited many ways but no luck. If any body fix it, please help so.
Thanks,
Lubna
create or replace PACKAGE htmldb_tools
AS
PROCEDURE parse_textarea (
p_textarea IN VARCHAR2,
p_collection_name IN VARCHAR2
PROCEDURE parse_file(
p_file_name IN VARCHAR2,
p_collection_name IN VARCHAR2,
p_headings_item IN VARCHAR2,
p_columns_item IN VARCHAR2,
p_ddl_item IN VARCHAR2,
p_table_name IN VARCHAR2 DEFAULT NULL
create or replace PACKAGE BODY htmldb_tools
AS
TYPE varchar2_t IS TABLE OF VARCHAR2(32767) INDEX BY binary_integer;
PROCEDURE delete_collection (
p_collection_name IN VARCHAR2
IS
BEGIN
IF (htmldb_collection.collection_exists(p_collection_name))
THEN
htmldb_collection.delete_collection(p_collection_name);
END IF;
END delete_collection;
PROCEDURE csv_to_array (
p_csv_string IN VARCHAR2,
p_array OUT wwv_flow_global.vc_arr2,
p_separator IN VARCHAR2 := 'chr(09)'
IS
l_start_separator PLS_INTEGER := 0;
l_stop_separator PLS_INTEGER := 0;
l_length PLS_INTEGER := 0;
l_idx BINARY_INTEGER := 0;
l_quote_enclosed BOOLEAN := FALSE;
l_offset PLS_INTEGER := 1;
BEGIN
l_length := NVL(LENGTH(p_csv_string),0);
IF (l_length <= 0)
THEN
RETURN;
END IF;
LOOP
l_idx := l_idx + 1;
l_quote_enclosed := FALSE;
IF SUBSTR(p_csv_string, l_start_separator + 1, 1) = '"'
THEN
l_quote_enclosed := TRUE;
l_offset := 2;
l_stop_separator := INSTR(p_csv_string, '"', l_start_separator + l_offset, 1);
ELSE
l_offset := 1;
l_stop_separator := INSTR(p_csv_string, p_separator, l_start_separator + l_offset, 1);
END IF;
IF l_stop_separator = 0
THEN
l_stop_separator := l_length + 1;
END IF;
p_array(l_idx) := (SUBSTR(p_csv_string, l_start_separator + l_offset,(l_stop_separator - l_start_separator - l_offset)));
EXIT WHEN l_stop_separator >= l_length;
IF l_quote_enclosed
THEN
l_stop_separator := l_stop_separator + 1;
END IF;
l_start_separator := l_stop_separator;
END LOOP;
END csv_to_array; --}}}
PROCEDURE get_records(p_blob IN blob,p_records OUT varchar2_t) --{{{
IS
l_record_separator VARCHAR2(2) := chr(13)||chr(10);
l_last INTEGER;
l_current INTEGER;
BEGIN
IF (NVL(dbms_lob.instr(p_blob,utl_raw.cast_to_raw(l_record_separator),1,1),0)=0)
THEN
l_record_separator := chr(10);
END IF;
l_last := 1;
LOOP
l_current := dbms_lob.instr( p_blob, utl_raw.cast_to_raw(l_record_separator), l_last, 1 );
EXIT WHEN (nvl(l_current,0) = 0);
p_records(p_records.count+1) := utl_raw.cast_to_varchar2(dbms_lob.substr(p_blob,l_current-l_last,l_last));
l_last := l_current+length(l_record_separator);
END LOOP;
END get_records;
PROCEDURE parse_textarea (
p_textarea IN VARCHAR2,
p_collection_name IN VARCHAR2
IS
l_index INTEGER;
l_string VARCHAR2(32767) := TRANSLATE(p_textarea,chr(9)||chr(13)||chr(10)||' ,','@@@@');
l_element VARCHAR2(100);
BEGIN
l_string := l_string||'@';
htmldb_collection.create_or_truncate_collection(p_collection_name);
LOOP
l_index := instr(l_string,'@');
EXIT WHEN NVL(l_index,0)=0;
l_element := substr(l_string,1,l_index-1);
IF (trim(l_element) IS NOT NULL)
THEN
htmldb_collection.add_member(p_collection_name,l_element);
END IF;
l_string := substr(l_string,l_index+1);
END LOOP;
END parse_textarea;
PROCEDURE parse_file(
p_file_name IN VARCHAR2,
p_collection_name IN VARCHAR2,
p_headings_item IN VARCHAR2,
p_columns_item IN VARCHAR2,
p_ddl_item IN VARCHAR2,
p_table_name IN VARCHAR2 DEFAULT NULL
IS
l_blob blob;
l_records varchar2_t;
l_record wwv_flow_global.vc_arr2;
l_datatypes wwv_flow_global.vc_arr2;
l_headings VARCHAR2(4000);
l_columns VARCHAR2(4000);
l_seq_id NUMBER;
l_num_columns INTEGER;
l_ddl VARCHAR2(4000);
BEGIN
IF (p_table_name is not null)
THEN
l_ddl := 'insert into '||p_table_name||' '||
'select '||v(p_columns_item)||' '||
'from htmldb_collections '||
'where seq_id > 0 and collection_name='''||p_collection_name||'''';
htmldb_util.set_session_state('P149_DEBUG',v('P149_DEBUG')||'/'||l_ddl);
execute immediate l_ddl;
RETURN;
END IF;
BEGIN
select blob_content into l_blob from wwv_flow_files
where name=p_file_name;
EXCEPTION
WHEN NO_DATA_FOUND THEN
raise_application_error(-20000,'File not found, id='||p_file_name);
END;
get_records(l_blob,l_records);
IF (l_records.count < 2)
THEN
raise_application_error(-20000,'File must have at least 3 ROWS, id='||p_file_name);
END IF;
htmldb_collection.create_or_truncate_collection(p_collection_name);
csv_to_array(l_records(1),l_record);
l_num_columns := l_record.count;
if (l_num_columns > 900000) then
raise_application_error(-900000,'Max. of 9,000,00 columns allowed, id='||p_file_name);
end if;
FOR i IN 1..l_record.count
LOOP
l_headings := l_headings||':'||l_record(i);
l_columns := l_columns||',c'||lpad(i,3,'0');
END LOOP;
l_headings := ltrim(l_headings,':');
l_columns := ltrim(l_columns,',');
htmldb_util.set_session_state(p_headings_item,l_headings);
htmldb_util.set_session_state(p_columns_item,l_columns);
FOR i IN 2..l_records.count
LOOP
csv_to_array(l_records(i),l_record);
l_seq_id := htmldb_collection.add_member(p_collection_name,'dummy');
FOR i IN 1..l_record.count
LOOP
htmldb_collection.update_member_attribute(
p_collection_name=> p_collection_name,
p_seq => l_seq_id,
p_attr_number => i,
p_attr_value => l_record(i)
END LOOP;
END LOOP;
DELETE FROM wwv_flow_files WHERE name=p_file_name;
END;
BEGIN
NULL;
END;sir manu,
i started the oracleAS report Server with the following command in command prompt : rwserver server=rep_myserver
and it successfully started.
i insert this code on my button :
DECLARE
RO_Report_ID REPORT_OBJECT;
Str_Report_Server_Job VARCHAR2(100);
Str_Job_ID VARCHAR2(100);
Str_URL VARCHAR2(100);
PL_ID PARAMLIST ;
BEGIN
PL_ID := GET_PARAMETER_LIST('TEMPDATA');
IF NOT ID_NULL(PL_ID) THEN
PAUSE;
DESTROY_PARAMETER_LIST(PL_ID);
END IF;
PL_ID := CREATE_PARAMETER_LIST('TEMPDATA');
--RO_Report_ID := FIND_REPORT_OBJECT('REPORT_OBJ');
RO_Report_ID := FIND_REPORT_OBJECT('REPORT1');
ADD_PARAMETER(PL_ID, 's_sin_no', TEXT_PARAMETER,:scrap_delivery_request.sin_no);
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_FILENAME, 'C:\New Forms\REF_SF_510.ref');
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_COMM_MODE, SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_EXECUTION_MODE, BATCH);
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_DESTYPE, cache);
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_DESFORMAT, 'PDF');
SET_REPORT_OBJECT_PROPERTY(RO_Report_ID, REPORT_SERVER, 'rep_myserver');
Str_Report_Server_Job := RUN_REPORT_OBJECT(RO_Report_ID, PL_ID);
Str_Job_ID := SUBSTR(Str_Report_Server_Job, LENGTH('rep_myserver') + 2, LENGTH(Str_Report_Server_Job));
Str_URL := '/reports/rwservlet/getjobid' || Str_Job_ID || '?server=' || 'rep_myserver';
WEB.SHOW_DOCUMENT(Str_URL, '_SELF');
DESTROY_PARAMETER_LIST(PL_ID);
END;
after pressing the button this error come up in browser :
REP-52251: Cannot get output of job ID 3 you requested on SAt. jul 04 11:44...... <P> REP-51026 :No output for job b -
Need Help With a Stored Procedure
Help With a Stored Procedure
Hi everyone.
I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
Anyway, here is my case:
I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
PlanID
EmployeeIndicator
UpdatedBy
CreatedBy
tblRef1, tblRef2 and tblRef3 has the following fields:
UserName
EmpIndicator
UserID
In my stored procedure, I need to perform the following:
1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
v_plan_no tblToUpdate.PLANID%TYPE;
v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
v_update_user tblToUpdate.UPDATEDBY%TYPE;
v_created_by tblToUpdate.CREATEDBY%TYPE;
v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
BEGIN
Open cur_plan;
LOOP
FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
EXIT WHEN cur_plan%NOTFOUND;
BEGIN
-- Check if v_created_by has value.
IF v_created_by IS NOT NULL THEN
-- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_created_by
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
ELSIF v_created_by IS NULL THEN
-- Get the EmpIndicator based on the UpdatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_update_user
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
END IF;
END;
END LOOP;
CLOSE cur_plan;
COMMIT;
END
Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
Thanks.Ah, ok; I got the updates the wrong way round then.
BluShadow's single update sounds like what you need then.
I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-) -
Help needed for compactrio programming
Hello all,
I am very new to LabVIEW programming.I've an application where it's required to acquire temprature data at a perticular duration from a heater.Depending upon the differance between current temp (process varible)and set temprature,heater has to make ON and OFF in a controlled way to reach the set value.
I have made a loop where i am acquireing temp data at every 30 sec interval and depending upon temprature diff between set value and present value ,am genarting a pulse (for eg. 22 sec on period and 8 sec off period).Inside that loop I am driving the "True" value to DIO of CompactRIO for ON period to make the heater ON .Problem what I am facing is the heater is not gaetting ON at Exact 0 to 22 sec and not OFF from 22 sec to 30 sec.
i have tried to use separate loop for acustion ,analysis and control but not able to synchonise all.Heater is getting ON and OFF randomly.Please help.
thanks
tapasmCan you post your code?
It would make is so much easier to help.
Tim
Johnson Controls
Holland Michigan
Maybe you are looking for
-
How can I highlight the default data in a numeric control when a VI loads.
I have a VI that features a string constant that asks for a numeric response via a numeric control, a "next" button that enters the data (controlled by the enter key), and two leds, one that lights if the data entered is correct, and one that lights
-
ABAP centered role assignment not working
I have been trying to implement ABAP centered role assignment for our users but not really having much luck in gettng it to work. I've been trying to make sense of it by using [the help guide|http://help.sap.com/saphelp_nwmobile71/helpdata/en/d2/3e38
-
When I use Firefox I tend to open a lot of tabs. But when I go to close tabs they all go, except when I get down to three tabs and close the third tab, the remaining two tabs combine together so that only one of them is visible. To see the other tab
-
Satellite 5100/201: trouble with video card or overheat?
Hy, I'm experiencing trouble with video on a Satellite 5100/201. It seems that when I press on the left side above the graphics card or press a key on the keyboard on that side, the screen starts to be scrambled and vertical lines appear. At the end
-
IPhoto 9 importing images already in iPhoto's library
I have iPhoto 9 running on a MacBook Core 2 Duo running Snow Leopard. First issue in four years: I tried to import 29 new jpg photos emailed to me and iPhoto indicated it was importing 828 photos after dragging them to the iPhoto icon, the import scr