Probelm in use of - - - - AT End of statement
Dear Experts,
types : begin of t_ZVAIQ1 ,
vbeln type vbeln,
prctr type prctr,
pfach type pfach,
fkimg1 type i,
fkimg2 type i,
end of t_ZVAIQ1.
DATA : itab type standard table of t_ZVAIQ1 initial size 0 with header line.
DATA : wa_itab type t_ZVAIQ1.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-fkimg1 = '2200'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-fkimg1 = '2500'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000000'.
itab-prctr = '1002'.
itab-fkimg1 = '2500'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-fkimg1 = '2200'.
itab-pfach = 'NON TAM'.
append itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-fkimg1 = '2200'.
itab-pfach = 'NON TAM'.
append itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-fkimg1 = '1000'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-fkimg1 = '3000'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-fkimg1 = '3500'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000001'.
itab-prctr = '1002'.
itab-fkimg1 = '500'.
itab-pfach = 'TAM'.
append itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-fkimg1 = '4000'.
itab-pfach = 'NON TAM'.
append itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-fkimg1 = '5000'.
itab-pfach = 'NON TAM'.
append itab.
data : sum type i.
LOOP AT itab into wa_itab.
sum = sum + wa_itab-fkimg1.
IF wa_itab-pfach = 'TAM'.
at end of prctr.
wa_itab-fkimg2 = sum.
modify itab from wa_itab.
clear sum.
endat.
elseif wa_itab-pfach = 'NON TAM'.
at end of vbeln.
modify itab from wa_itab.
clear sum.
endat.
ENDIF.
ENDLOOP.
Problem is , its not entering into at end of vbeln block.
if the value of pfach = NON TAM, then the sum is supposed to done at vbeln level.
Can any one tell me what to do.
Regards,
Jaspal
adjust your code as below and check the output.you cannot use if comparision for control break cheks
REPORT zex3.
TYPES : BEGIN OF t_zvaiq1 ,
vbeln TYPE vbeln,
prctr TYPE prctr,
val TYPE i, "bring in this-->imp
pfach TYPE pfach,
fkimg1 TYPE i,
fkimg2 TYPE i,
END OF t_zvaiq1.
DATA : itab TYPE STANDARD TABLE OF t_zvaiq1 INITIAL SIZE 0 WITH HEADER LINE.
DATA : wa_itab TYPE t_zvaiq1.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-val = 1.
itab-fkimg1 = '2200'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-val = 1.
itab-fkimg1 = '2500'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000000'.
itab-prctr = '1002'.
itab-val = 1.
itab-fkimg1 = '2500'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-val = 2.
itab-fkimg1 = '2200'.
itab-pfach = 'NON TAM'.
APPEND itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-val = 2.
itab-fkimg1 = '2200'.
itab-pfach = 'NON TAM'.
APPEND itab.
itab-vbeln = '4000000000'.
itab-prctr = '1001'.
itab-val = 1.
itab-fkimg1 = '1000'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-val = 1.
itab-fkimg1 = '3000'.
itab-pfach = 'TAM'.
itab-val = 1.
APPEND itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-val = 1.
itab-fkimg1 = '3500'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000001'.
itab-prctr = '1002'.
itab-val = 1.
itab-fkimg1 = '500'.
itab-pfach = 'TAM'.
APPEND itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-val = 2.
itab-fkimg1 = '4000'.
itab-pfach = 'NON TAM'.
APPEND itab.
itab-vbeln = '4000000001'.
itab-prctr = '1001'.
itab-val = 2.
itab-fkimg1 = '5000'.
itab-pfach = 'NON TAM'.
APPEND itab.
DATA : sum TYPE i,
sum_tot_vb TYPE i .
SORT itab BY vbeln prctr val.
LOOP AT itab INTO wa_itab.
WRITE:/ wa_itab-vbeln, wa_itab-prctr, wa_itab-pfach, wa_itab-fkimg1.
sum = sum + wa_itab-fkimg1.
sum_tot_vb = sum_tot_vb + wa_itab-fkimg1.
AT END OF val.
WRITE:/ sum.
CLEAR sum.
ENDAT.
AT END OF vbeln.
WRITE:/ 'vbeln', wa_itab-vbeln ,'tot = ' ,sum_tot_vb.
CLEAR sum_tot_vb.
ENDAT.
ENDLOOP.
Similar Messages
-
RPM - How to re-process prices without using the front end.
Hi all,
There is a way of re-processing prices without using the front end? For instance, using the front end, a new clearance is created state in rpm_clearance ‘pricechange.State.conflictCheckforApproved’ and changed for ‘pricechange.State.worksheet’ after the conflict check.
Now, I want to re-process the same clearance without using the front end. I’ve tried to change again the STATE to ‘pricechange.State.conflictCheckforApproved’ but no success. Any suggestions?
Thanks in advance.
RegardsCan you please attach your VI?
Prashanth N
National Instruments -
How to use using clause in execute immediate statement??
Hi ALL,
Can u help me ....
This is the code which I have written...
declare
type rec_typ is table of forall_test%rowtype;
v_rectype rec_typ:=rec_typ();
begin
--poputating records
for i in 1..10000 loop
v_rectype.extend;
v_rectype(v_rectype.last).id:=i;
v_rectype(v_rectype.last).code:=to_char(i);
v_rectype(v_rectype.last).description:='Description :'||to_char(i);
end loop;
execute immediate 'truncate table forall_test';
forall i in v_rectype.first..v_rectype.last
execute immediate 'insert into forall_test values :1' using v_rectype(i);
commit;
end;
But I am getting this ERROR....
execute immediate 'insert into forall_test values :1' using v_rectype(i);
ERROR at line 14:
ORA-06550: line 14, column 61:
PLS-00457: expressions have to be of SQL types
ORA-06550: line 14, column 1:
PL/SQL: Statement ignored
Thanks & Regards,
T.HalderThatmeans using statement cannot be a non sql type.True: You need an sql type for this:
e.g. with
create or replace type emp_typ
as
object (empno number (4),
ename varchar2 (10 byte),
job varchar2 (9 byte),
mgr number (4),
hiredate date,
sal number (7, 2),
comm number (7, 2),
deptno number (2))
create or replace type emp_tab as table of emp_typ
/you can do
--- an empty test table
SQL> create table emp2
as
select *
from emp
where 1 = 2
Table created.
SQL> declare
emp2_tab emp_tab;
begin
/* fill the collection */
select emp_typ (empno,
ename,
job,
mgr,
hiredate,
sal,
comm,
deptno)
bulk collect into emp2_tab
from emp
where empno like '77%';
-- forall loop
forall c in 1 .. emp2_tab.count
execute immediate 'begin
insert into emp2 select * from table(cast(emp_tab(:1) as emp_tab)) t;
update emp2 set sal = null where empno = (:1).empno and empno = 7788;
end;' using emp2_tab (c);
end;
PL/SQL procedure successfully completed.
SQL> select empno, ename, sal from emp2
EMPNO ENAME SAL
7782 CLARK 2450
7788 SCOTT
2 rows selected. -
Passing multiple fields as addition to "end at " statement
Hi All
I dont think I can pass multiple fields to END AT statement.
I need to sum at end of few field values in table .what is the best method of acheving this.
Thanks in Advance
Regards
Vinay Kollahave different control blocks, and make sure you sort on all of the fields which you are using the control statements.
-
Using plsql tables in select statement of report query
Hi
Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
thanks in advance
sureshhi,
u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
declare
ur_file utl_file.file_type;
my_result varchar2(250);
begin
ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
utl_file.get_line(ur_file, my_result);
dbms_output.put_line(my_result);
utl_file.fclose(ur_file);
end;
make sure u have an entry in ur init.ora saying that your
utl_file_dir = '\your directory where ur files reside'
cheers!
[email protected] -
Problem in using aggregate functions inside case statement
Hi All,
I am facing problem while using aggregate functions inside case statement.
CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
how can I achieve above requirement ? Con anyone help me.
Thanks and Regards
DGHi All,
Below is my query:
SELECT
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
POS.PCLOSE,SUM(POS.PMKVAL) ,
TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
POS.SOURCE_GMI_LIB,
--DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
POS.RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
NULL,
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN POS.PSUBTY='S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
FROM POSITIONS_WRK POS LEFT OUTER JOIN
(SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
(CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
WHERE
POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
AND POS.BUSINESS_DATE = run_date_char
GROUP BY
POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
POS.PEXCH,POS.PSUBEX,POS.PCURSY,
CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END,
NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
NVL(C.SSECID,POS.PCUSIP),
POS.PYSTMV,
POS.PMINIT,
POS.PEXPDT,
CASE WHEN PSUBTY = 'S' THEN SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
Thanks and Rgds
DG
Edited by: BluShadow on 16-May-2011 09:39
added {noformat}{noformat} tags. Please read: {message:id=9360002} for details on how to post code/data -
Use NEXTVAL in an insert statement Part II
db - 10g
I am asking this question out of curiosity.
I posted a question and recieved a successful answer at the following address on this forum;
Use NEXTVAL in an insert statement
The following insert statement uses a sequence to create an arbitrary number for each null record. The problem is, the sequence is firing regardless of the condition being true or false (but it is working in that it only inserts values when the condition is true). The result is the sequence appears to increment each time it loops through the cursor and so the first arbitrary number to be inserted is not 1001 but some other higher number.
INSERT INTO psp_trees
( plot_id
, tree_name
, species_code)
VALUES
( get_plot_id
, c1.treenum
, c1.species
) RETURNING tree_id INTO get_tree_id; I have gotten around the issue by removing the sequence from the insert statement and placing it outside the cursor loop as an update statement.
UPDATE psp_trees
SET tree_name = to_char(tree_arbitrary_name_seq.nextval)
WHERE tree_name IS NULL;Is there anyway to get the sequence to only fire in the insert statement when the condition is true.
This is the complete anonymous block for your reference;
DECLARE p_access_num NUMBER;
col_access_var VARCHAR2(30);
type number_ptb IS table OF VARCHAR2(4000);
p_access_nam number_ptb;
get_plot_measurement_id NUMBER;
update_plot_measurements VARCHAR2(4000);
get_tree_id NUMBER;
get_plot_id NUMBER;
BEGIN
p_access_num := 6;
p_access_nam := number_ptb();
p_access_nam.extend(7);
p_access_nam(1) := 535;
p_access_nam(2) := 548;
p_access_nam(3) := 898;
p_access_nam(4) := 544;
p_access_nam(5) := 551;
p_access_nam(6) := 724;
FOR loop_int IN 1 .. p_access_num
LOOP
col_access_var := p_access_nam(loop_int);
-- 1. Initiate insert process by getting PK from psp_plots.
SELECT plot_id INTO get_plot_id FROM psp_plots WHERE plot_name = col_access_var;
-- 2. Insert records into psp_plot_measurements and keep relationship with psp_plots with variable get_plot_id.
-- and get primary key value of psp_plot_measurements to insert into psp_tree_measurements during loop process.
INSERT INTO psp_plot_measurements (plot_id) VALUES (get_plot_id) RETURNING plot_measurement_id INTO get_plot_measurement_id;
-- 3. Update record created at point 2.
UPDATE psp_plot_measurements
SET measurement_date = (SELECT DISTINCT date_ FROM pspdata)
, codominant_height = (SELECT DISTINCT height_codom FROM pspdata)
, assessor = (SELECT DISTINCT assessor FROM pspdata)
WHERE plot_measurement_id = col_access_var
-- 4. Open cursor to insert rows one at a time and maintain relationships between related tables.
FOR c1 IN (SELECT treenum
, dbhob
, treecomments
, species
FROM pspdata
WHERE plotnumber = col_access_var
AND date_ IS NOT NULL)
LOOP
-- 5. Insert record into psp_trees
-- and get primary key value of psp_trees to insert into psp_tree_measurements.
INSERT INTO psp_trees
( plot_id
, tree_name
, species_code)
VALUES
( get_plot_id
, c1.treenum
--, NVL(c1.treenum , to_char(tree_arbitrary_name_seq.nextval))
--, (CASE WHEN c1.treenum IS NULL THEN to_char(tree_arbitrary_name_seq.nextval) ELSE c1.treenum END)
, c1.species
) RETURNING tree_id INTO get_tree_id;
-- 6. Insert records into psp_tree_measurements and keep relationship with psp_trees with variable get_tree_id.
INSERT INTO psp_tree_measurements
( plot_measurement_id
, tree_id
, dbhob
, comments
VALUES
( get_plot_measurement_id
, get_tree_id
, c1.dbhob
, c1.comment
END LOOP;
END LOOP;
-- 7. Update null columns with arbitrary number.
UPDATE psp_trees
SET tree_name = to_char(tree_arbitrary_name_seq.nextval)
WHERE tree_name IS NULL;
END;
/Edited by: benton on Sep 6, 2011 1:53 PMOr use a function (I'll use dbms_xml.getxml):
SQL> create sequence s_seq nocache
Sequence created.
SQL> select case when mod (level, 2) = 0
then extractvalue(dbms_xmlgen.getxmltype('select s_seq.nextval from dual'), '//text()')
else '0' end col1
from dual connect by level < 20
COL1
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
0
19 rows selected.
SQL> select sequence_name, last_number from user_sequences where sequence_name = 'S_SEQ'
SEQUENCE_NAME LAST_NUMBER
S_SEQ 10
1 row selected. -
Using Collection in a sql statement.
Hi I want to perform the following statement:
DELETE FROM ALLOCATION_ELEC_MATRIX
WHERE dgo_ean_id in (lt_inter_dgos);
The collection lt_inter_dgos holds my dgo_ean_id's(varchars).
I can't find a way to get it to work.
The collection is declared as follows:
TYPE Interface_param_dgos IS TABLE OF VARCHAR2(20);
lt_inter_dgos Interface_param_dgos := Interface_param_dgos();
then later on the collection gets filled. But how can i get it to work to use it in my sql statement?
I don't won't to use a for loop around it since it would give me problems if I use more collections with a different amount of values in it.The standard approach is to use SQL collection type and table function,
for example
SQL> create TYPE Interface_param_dgos IS TABLE OF VARCHAR2(20);
2 /
Type created.
SQL> create or replace package my_pkg
2 is
3 lt_inter_dgos Interface_param_dgos := Interface_param_dgos();
4 function get_coll return Interface_param_dgos;
5 end;
6 /
Package created.
SQL> create or replace package body my_pkg
2 is
3 function get_coll return Interface_param_dgos
4 is
5 begin
6 return lt_inter_dgos;
7 end;
8 end;
9 /
Package body created.
SQL> begin
2 my_pkg.lt_inter_dgos.extend(3);
3 my_pkg.lt_inter_dgos(1) := 'SMITH';
4 my_pkg.lt_inter_dgos(2) := 'KING';
5 my_pkg.lt_inter_dgos(3) := 'ALLEN';
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> select ename from emp;
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
14 rows selected.
SQL> delete from emp where ename in (select column_value from table(my_pkg.get_coll));
3 rows deleted.
SQL> select ename from emp;
ENAME
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
TURNER
ADAMS
JAMES
FORD
MILLER
11 rows selected.Rgds. -
Case, end case statement
Hi all,
name of my internal table is my_tab.i need to calculate the discounts depending upon the condition types(KSCHL) FROM KONV TABLE.
WHEN KSCHL = ZDO1 calulation procedure is in percentage
KSCHL= ZD02 calculation procedure is in fixed amount.
and so on.....
my_tab has fields
my_tab-total
my_tab-discount
if kschl = ZD01, discount = my_tab-total - my_tab-discount
if kschl = ZD02, discount = my_tab-total * my_tab-discount/100.
i wanted to know how to use this in CASE AND END CASE statement.
regards
akmalHi akmal,
chek out this code.
Case kshcl.
when 'ZD01'.
discount = my_tab-total - my_tab-discount.
when 'ZD02'.
if kschl = ZD02, discount = my_tab-total * my_tab-discount/100.
end case.
if you ar looping through the internal table sthen you can do the same af ter the when statements.
regards,
sateesh. -
PLS-00455: cursor 'CUR_1' cannot be used in dynamic SQL OPEN statement
create or replace function f_my_test_func
return refcur_pkg.refcur_t1
is
cur_1 refcur_pkg.refcur_t1;
begin
open cur_1
for
'select * from dept';
return cur_1;
exception
when others
then
insert into ddl_log (SQLTEXT)
values
('fucntion error');
end;I would suggest that cur_1 refcur_pkg.refcur_t1 is a stongly typed ref cursor i.e. it has RETURN dept%ROWTYPE or something similar in the declaration. You can't use strongly typed ref cursors with dynamic SQL in this way. The declaration should be weakly typed or just use sys_refcursor.
DTYLER_APP@pssdev2> DECLARE
2
3 TYPE t_Strong IS REF CURSOR RETURN dual%ROWTYPE;
4
5 lc_Strong t_Strong;
6
7 BEGIN
8
9 OPEN lc_Strong FOR
10 'SELECT * FROM dual';
11
12 END;
13 /
OPEN lc_Strong FOR
ERROR at line 9:
ORA-06550: line 9, column 10:
PLS-00455: cursor 'LC_STRONG' cannot be used in dynamic SQL OPEN statement
ORA-06550: line 9, column 5:
PL/SQL: Statement ignored
DTYLER_APP@pssdev2>
DTYLER_APP@pssdev2> DECLARE
2
3 TYPE t_Weak IS REF CURSOR;
4
5 lc_Weak t_Weak;
6
7 BEGIN
8
9 OPEN lc_Weak FOR
10 'SELECT * FROM dual';
11
12 END;
13 /
PL/SQL procedure successfully completed.
DTYLER_APP@pssdev2> DECLARE
2
3 lc_Weak sys_refcursor;
4
5 BEGIN
6
7 OPEN lc_Weak FOR
8 'SELECT * FROM dual';
9
10 END;
11 /
PL/SQL procedure successfully completed.
DTYLER_APP@pssdev2>HTH
David -
Can i use "begin" and "end" in a database control
hi there
i just want to know if i can use begin and end with several sql update statments in between in a database control. u see, i need to run few update statements together. i don't want to put them in seperate method. i was wondering if i could put them together in on method and run it. is there any other way to do it if begin and end are not allowed. thanksI have a J2EE application, for which I have a module which is used by system administrators. this module is completly written in Java swing.
and it does talk to my EJBs.
If you don't have a firewall in your application, then you can directly make your applications in awt, swing and applets talk to EJBs. if you do have a firewall, then just write a web-service wrapper over your EJBs and other J2EE components and use them from desktop applications.
It seems that you want to implement a kind of a applet based monitor application for your J2EE EJBs on the server. Applets cannot directly monitor your EJBs.
Create a new module which has a service which acts as an event listener on the server. each j2ee component on the server notify it if there is a change to them. this service, can then write the data realted to the modification on a socket which is continiously being read by the applet. So you can implement a kind of a monitor for J2ee apps with applets.
hope this helps.
regards,
Abhishek.
PS:How did you manage to adore the AWT ;-) ? I found that it sucks (good performance.. very poor lnf) ... java swing sucks too (very poor performance ... avaerage lnf). -
I want to purchase a month of cellular service for my IPAD2. When I use my ITunes password, it states that I have the wrong password but does not offer a way to reset my password. Please advise.
Read through this link and maybe you'll see something that will help you:
http://www.tech-recipes.com/rx/5827/ipad-3g-activating-purchasing-att-cellular-d ata-for-the-ipad-3gwifi/ -
Using a different default component state within each page state
I am using a custom component in multiple page states but would like to have a different default state (for the same custom component) within each page state.
Is there anyway to use a different default component state within each page state .
When I change the default state at a component level it seems to go across all my page states. Any solutions?
Thank youI guess I can just add that interaction for that component!
I think my brain is just catching up -
Using a string as sql statement in PL/SQL
Hi there,
I have a function which returns a part of a query depending on some conditions.
FUNCTION GET_REPORT_TYPE(in_report_type IN NUMBER)
RETURN VARCHAR2
AS
reporttype varchar2(50);
BEGIN
CASE in_report_type
WHEN 0 THEN
reporttype := 'C1.DATE_CLOSED != NULL';
WHEN 1 THEN
reporttype := 'C1.DATE_CLOSED := NULL';
WHEN 2 THEN
reporttype := '';
END CASE;
RETURN reporttype;
END GET_REPORT_TYPE;
Now in my procedure I would like to put this returned value in an AND clause of my query:
procedure get_cpl(p_cursor OUT rst_cur, searchcode IN VARCHAR2, reporttype IN VARCHAR2)
is
begin
open p_cursor for
SELECT C1.CIPIDI_NR,
C1.CIPIDI_NAME,
C2.TEAM_MEMBER
FROM TBL_CIPIDI C1, TBL_TEAM_MEMBERS C2
WHERE C1.CIPIDI_NR LIKE searchcode
AND C1.CIPIDI_NR = C2.CIPIDI_NR (+);
AND reporttype; -- HERE I WOULD LIKE TO USE WHAT THE FUNCTIONS RETURNED
end get_cpl;
How can I can I use reporttype to function as a part of the query? Thanks a lot
Chrisscott@ORA92> -- test data:
scott@ORA92> SELECT * FROM tbl_cipidi
2 /
CIPIDI_NR CIPIDI_NAME DATE_CLOS
1 name1 30-MAY-05
1 name2
scott@ORA92> SELECT * FROM tbl_team_members
2 /
CIPIDI_NR TEAM_MEMBER
1 team1
scott@ORA92> -- function:
scott@ORA92> CREATE OR REPLACE FUNCTION GET_REPORT_TYPE
2 (in_report_type IN NUMBER)
3 RETURN VARCHAR2
4 AS
5 reporttype varchar2(50);
6 BEGIN
7 CASE in_report_type
8 WHEN 0 THEN reporttype := 'C1.DATE_CLOSED IS NOT NULL';
9 WHEN 1 THEN reporttype := 'C1.DATE_CLOSED IS NULL';
10 ELSE reporttype := '1 = 1';
11 END CASE;
12 RETURN reporttype;
13 END GET_REPORT_TYPE;
14 /
Function created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- packaged with procedure:
scott@ORA92> CREATE OR REPLACE PACKAGE your_pkg
2 AS
3 TYPE rst_cur IS REF CURSOR;
4 procedure get_cpl
5 (p_cursor OUT rst_cur,
6 searchcode IN VARCHAR2,
7 reporttype IN VARCHAR2);
8 END your_pkg;
9 /
Package created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> CREATE OR REPLACE PACKAGE BODY your_pkg
2 AS
3 procedure get_cpl
4 (p_cursor OUT rst_cur,
5 searchcode IN VARCHAR2,
6 reporttype IN VARCHAR2)
7 is
8 begin
9 OPEN p_cursor FOR
10 'SELECT C1.CIPIDI_NR,
11 C1.CIPIDI_NAME,
12 C2.TEAM_MEMBER
13 FROM TBL_CIPIDI C1, TBL_TEAM_MEMBERS C2
14 WHERE C1.CIPIDI_NR = :b_searchcode
15 AND C1.CIPIDI_NR = C2.CIPIDI_NR (+)
16 AND ' || get_report_type (reporttype)
17 USING searchcode;
18 end get_cpl;
19 END your_pkg;
20 /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- tests:
scott@ORA92> VARIABLE g_ref REFCURSOR
scott@ORA92> SET AUTOPRINT ON
scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 0)
PL/SQL procedure successfully completed.
CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
1 name1 team1
scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 1)
PL/SQL procedure successfully completed.
CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
1 name2 team1
scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 2)
PL/SQL procedure successfully completed.
CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
1 name1 team1
1 name2 team1
scott@ORA92> -
I have the a query that keeps coming up with an error when I try to place in in a form as VBA. The following is the code:
txtOperationID = "SELECT TOP 1 [idsOpSymbolID] & " " & Format([txtOperationSub#]+1,"0000") AS NewOpID " & _
"FROM tblOperations LEFT JOIN tblOperationsSUB ON tblOperations.idsOpSymbolID = tblOperationsSUB.idrOpSymbolID " & _
"WHERE (((tblOperations.idsOpSymbolID) = [Forms]![frmNewProjectOperationTrackingNumber]![Combo91])) " & _
"ORDER BY tblOperationsSUB.[txtOperationSub#] DESC"
I am given the following error: Compile Error, Expected end of statement. Any suggestions?Yes,
You have to neutralize " in string:
txtOperationID = "SELECT TOP 1 [idsOpSymbolID] & "" "" & Format([txtOperationSub#]+1,""0000"") AS NewOpID " & _
"FROM tblOperations LEFT JOIN tblOperationsSUB ON tblOperations.idsOpSymbolID = tblOperationsSUB.idrOpSymbolID " & _
"WHERE (((tblOperations.idsOpSymbolID) = [Forms]![frmNewProjectOperationTrackingNumber]![Combo91])) " & _
"ORDER BY tblOperationsSUB.[txtOperationSub#] DESC"
Michał
Maybe you are looking for
-
Certain characters not appearing in the "full name" when sending e-mail
I have certain characters in my full name of one of my e-mail aliases in iCloud. However, those characters are simply absent from the name shown as sender name when sending mail from Mail app in OS X. For me the problematic characters are C5 A1 and C
-
This is just a informed post telling you guy's how to get your video's from you Ipod Touch, Ipad, or Iphone to your windows PC. Here it is step by step. STEP 1: Connect you device to your windows pc. STEP 2: Open up "computer" on your pc, you should
-
i need help....i just downloaded the new update to my ipod. How will I know when the update/restore is complete? I saw the apple logo come up on the ipod, but the screen now says do not disconnect. The updater window shows my name, the serial number,
-
Configure Web Service finished with error
Hi, I had configured the web server for version EPM 11.1.2.3 on Server 2008 R2. But I had a failed status. I copied the c:\program files\Oracle\Inventory\logs\Install 2014-01-14-05:00:00PM.log file as below; What is the problem? Did you take this fai
-
Find Whether Array Element have same element in all index
Hi , I need to check if an array have the same element in all its indexes.(Example: An Array of Size 4, should have index 0 ..index 3 as 1 and during next iteration let it be number 2 in all indexes......how do I check if all index have same number)