Is it possible to use a case statement when joining different tables based on input parameters?
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 |
Similar Messages
-
How do I use the CASE statement in the where clause?
Hello Everyone,
I have 2 queries that do what I need to do but I am trying to learn how to use the CASE statement.
I have tried to combine these 2 into one query using a case statement but don't get the results I need.
Could use some help on how to use the case syntax to get the results needed.
thanks a lot
select segment_name,
product_type,
count (distinct account_id)
FROM NL_ACCT
where
ind = 'N'
and
EM_ind = 'N'
and product_type in ('TAX','PAY')
and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 60)
GROUP BY 1,2
order by product_type
select segment_name,
product_type,
count (distinct account_id)
FROM NL_ACCT
where
ind = 'N'
and
EM_ind = 'N'
and product_type not in ('TAX','PAY')
and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 30)
group by 1,2
order by product_typeSomething like:
SELECT segment_name, product_type,
SUM(CASE WHEN account_id IN ('TAX','PAY') and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60 THEN 1
ELSE 0 END) tax_pay,
SUM(CASE WHEN account_id NOT IN ('TAX','PAY') and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 30 THEN 1
ELSE 0 END) not_tax_pay
FROM NL_ACCT
WHERE ind = 'N' and
em_ind = 'N' and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60
GROUP BY segment_name, product_type
ORDER BY product_typeNote: You cannor GROUP BY 1,2, you need to explicitly name the columns to group by.
HTH
John -
Can CR 2008 with XML ODBC driver using SQL CASE statement?
Hi:
when i use SQL Command to provide data to the report from XML file connection. I can not use CASE statement , CR always has error message about "CASE" word.
I test the same Statement in SQL client connected to Oracle, it runs fine.
So.. Is it driver's limitation that XML datasource can not use CASE statement inside SQL command window?
Thanks anyone's reply in advance.
JohnnychiHi Johnny,
CR supports what every the ODBC driver supports. The error you are getting is from the XML driver, CR is just passing it through.
Try using an ODBC to XML driver and then a stand-alone ODBC test tool to see if your SQL works.
If not you'll have to find another way to use the CASE statement.
Thank you
Don -
I have 6 radio buttons.i want to use a case statement to read them.
i have 6 radio buttons.i grouped them.i want to read them in a subroutine using a case statement.how can i read them
Hi Leela,
You cannot use the Case statement to read the radio buttons.
nstead you will have to use Loop at Screen under At Selection Screen Output.
Please refer to the below code or the reference:
*& Report ZHYPERION *
*& Project : SubSea7
Created on : 07/02/2007
Created by : Puneet Jhari.
*& Purpose : For SAP Interface download Hyperion.
REPORT zhyperion NO STANDARD PAGE HEADING MESSAGE-ID zhyper.
Start of Data Declaration
TYPE-POOLS : truxs,vrm.
TABLES : glpct,cepc.
DATA : var TYPE i,
total TYPE f.
DATA : BEGIN OF wa2,
ryear LIKE glpct-ryear,
rbukrs LIKE glpct-rbukrs,
racct LIKE glpct-racct,
ksl01 LIKE glpct-ksl01,
END OF wa2.
DATA : BEGIN OF wa3,
ryear LIKE glpct-ryear,
rbukrs LIKE glpct-rbukrs,
racct LIKE glpct-racct,
ksl01 LIKE glpct-ksl01,
END OF wa3.
DATA : BEGIN OF wa4,
racct LIKE glpct-racct,
END OF wa4.
DATA : BEGIN OF wa5,
rbukrs LIKE glpct-rbukrs,
racct LIKE glpct-racct,
total1(8) TYPE p DECIMALS 2,
END OF wa5.
DATA : BEGIN OF wa9,
khinr LIKE cepc-khinr,
racct LIKE glpct-racct,
total1(8) TYPE p DECIMALS 2,
END OF wa9.
DATA : BEGIN OF wa6,
khinr LIKE cepc-khinr,
prctr LIKE cepc-prctr,
rprctr LIKE glpct-rprctr,
ryear LIKE glpct-ryear,
rbukrs LIKE glpct-rbukrs,
racct LIKE glpct-racct,
ksl01 LIKE glpct-ksl01,
END OF wa6.
DATA : BEGIN OF wa7,
khinr LIKE cepc-khinr,
prctr LIKE cepc-prctr,
rprctr LIKE glpct-rprctr,
ryear LIKE glpct-ryear,
rbukrs LIKE glpct-rbukrs,
racct LIKE glpct-racct,
ksl01 LIKE glpct-ksl01,
END OF wa7.
DATA : itab3 LIKE TABLE OF wa2,
itab4 LIKE TABLE OF wa3,
itab5 LIKE TABLE OF wa4 WITH HEADER LINE,
itab6 LIKE TABLE OF wa5 WITH HEADER LINE,
itab7 LIKE TABLE OF wa6,
itab8 LIKE TABLE OF wa7,
itab10 LIKE TABLE OF wa9.
DATA : flag(1) TYPE c,
temp(6) TYPE c.
DATA : itab2 TYPE truxs_t_text_data,
itab9 TYPE truxs_t_text_data WITH HEADER LINE.
DATA : name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list,
FILNAM11 TYPE STRING,
FILNAM21 TYPE STRING.
End of Data Declaration
Begin of Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: r1 DEFAULT 'X' RADIOBUTTON GROUP g1 USER-COMMAND rad1,
r2 RADIOBUTTON GROUP g1 .
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-005.
PARAMETERS: rbukrs1 TYPE glpct-rbukrs MODIF ID ful,
khinr1 TYPE cepc-khinr AS LISTBOX VISIBLE LENGTH 20
MODIF ID sam ,
ryear1 TYPE glpct-ryear MODIF ID ful,
ryear2 TYPE glpct-ryear MODIF ID sam,
rpmax1 TYPE i MODIF ID ful,
rpmax2 TYPE i MODIF ID sam,
filnam1 TYPE rlgrap-filename MODIF ID ful,
filnam2 TYPE RLGRAP-FILENAME MODIF ID sam.
SELECTION-SCREEN END OF BLOCK b3.
End of Selection Screen
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN OUTPUT.
PERFORM populate. "For populating the drop-down list.
CLEAR VALUE.
REFRESH LIST.
NAME = 'KHINR1'.
VALUE-KEY = '1S7_NOCASV'.
VALUE-TEXT = '1S7_NOCASV'.
APPEND VALUE TO LIST.
VALUE-KEY = '1S7_NOCJOT'.
VALUE-TEXT = '1S7_NOCJOT'.
APPEND VALUE TO LIST.
LOOP AT SCREEN. "For toggling between the selection screens.
IF r1 EQ 'X'.
IF screen-group1 = 'SAM'.
screen-active = 0.
ENDIF.
ELSEIF r2 EQ 'X'.
IF screen-group1 = 'FUL'.
screen-active = 0.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
For the Drop-Down Listbox
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list
EXCEPTIONS
ID_ILLEGAL_NAME = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Begin of Data Selection
START-OF-SELECTION.
When Company Code radio button is selected.
IF r1 EQ 'X'. "If Company Code radio button is selected.
IF rbukrs1 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF rpmax1 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF ryear1 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF filnam1 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
MOVE FILNAM1 TO FILNAM11.
CASE rpmax1.
WHEN '01'.
SELECT ryear rbukrs racct ksl01
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '02'.
SELECT ryear rbukrs racct ksl02
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '03'.
SELECT ryear rbukrs racct ksl03
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '04'.
SELECT ryear rbukrs racct ksl04
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '05'.
SELECT ryear rbukrs racct ksl05
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '06'.
SELECT ryear rbukrs racct ksl06
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '07'.
SELECT ryear rbukrs racct ksl07
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '08'.
SELECT ryear rbukrs racct ksl08
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '09'.
SELECT ryear rbukrs racct ksl09
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '10'.
SELECT ryear rbukrs racct ksl10
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '11'.
SELECT ryear rbukrs racct ksl11
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '12'.
SELECT ryear rbukrs racct ksl12
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '13'.
SELECT ryear rbukrs racct ksl13
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '14'.
SELECT ryear rbukrs racct ksl14
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '15'.
SELECT ryear rbukrs racct ksl15
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
WHEN '16'.
SELECT ryear rbukrs racct ksl16
FROM glpct INTO TABLE itab3 WHERE rbukrs EQ rbukrs1 AND ryear EQ ryear1.
ENDCASE.
MOVE itab3 TO itab4.
LOOP AT itab3 INTO wa2.
flag = 0.
LOOP AT itab5 INTO wa4.
IF wa2-racct EQ wa4-racct.
flag = 1.
EXIT.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM itab5.
IF flag = 1.
CONTINUE.
ENDIF.
LOOP AT itab4 INTO wa3.
IF wa2-rbukrs EQ wa3-rbukrs AND wa2-racct EQ wa3-racct AND
wa2-ryear EQ wa3-ryear.
total = total + wa3-ksl01.
ENDIF.
ENDLOOP.
wa5-rbukrs = wa2-rbukrs.
wa5-racct = wa2-racct+4(6).
wa5-total1 = total.
APPEND wa5 TO itab6.
CLEAR total.
APPEND wa2-racct TO itab5.
ENDLOOP.
If no data is available corresponding to the values entered.
IF itab6[] IS INITIAL.
MESSAGE i003.
ENDIF.
For making the file Comma separated
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = itab6
CHANGING
i_tab_converted_data = itab2
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
For downloading it to the Presentation Server
MOVE itab2[] TO itab9[].
OPEN DATASET filnam1 FOR OUTPUT IN LEGACY TEXT MODE.
LOOP AT itab9.
TRANSFER itab9 TO filnam1.
ENDLOOP.
CLOSE DATASET filnam1.
IF sy-subrc EQ 0.
MESSAGE s004.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = FILNAM11
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
IMPORTING
FILELENGTH =
tables
data_tab = itab2
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc eq 0.
message s004.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
When Region radio button is selected.
ELSEIF r2 EQ 'X'.
IF khinr1 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF rpmax2 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF ryear2 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
IF filnam2 IS INITIAL.
MESSAGE i002.
LEAVE TO SCREEN 1000.
ENDIF.
MOVE FILNAM2 TO FILNAM21.
CASE rpmax2.
WHEN '01'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl01
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '02'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl02
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '03'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl03
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '04'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl04
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '05'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl05
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '06'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl06
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '07'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl07
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '08'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl08
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '09'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl09
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '10'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl10
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '11'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl11
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '12'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl12
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '13'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl13
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '14'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl14
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '15'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl15
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
WHEN '16'.
SELECT ckhinr cprctr grprctr gryear grbukrs gracct g~ksl16
INTO CORRESPONDING FIELDS OF TABLE itab7
FROM ( glpct AS g
INNER JOIN cepc AS c ON grprctr = cprctr )
WHERE c~khinr = khinr1 AND
g~ryear = ryear2.
ENDCASE.
MOVE itab7 TO itab8.
LOOP AT itab7 INTO wa6.
flag = 0.
LOOP AT itab5 INTO wa4.
IF wa6-racct EQ wa4-racct.
flag = 1.
EXIT.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM itab5.
IF flag = 1.
CONTINUE.
ENDIF.
LOOP AT itab8 INTO wa7.
IF wa6-rbukrs EQ wa7-rbukrs AND wa6-racct EQ wa7-racct AND
wa6-ryear EQ wa7-ryear.
total = total + wa7-ksl01.
ENDIF.
ENDLOOP.
wa9-khinr = khinr1.
wa9-racct = wa6-racct+4(6).
wa9-total1 = total.
APPEND wa9 TO itab10.
CLEAR total.
APPEND wa6-racct TO itab5.
ENDLOOP.
*If no data is available corresponding to the values entered.
IF itab10 IS INITIAL.
MESSAGE i003.
ENDIF.
For making the file Comma separated
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
I_LINE_HEADER =
I_FILENAME =
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = itab10
CHANGING
i_tab_converted_data = itab2
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
For downloading it to the Presentation Server
MOVE itab2[] TO itab9[].
OPEN DATASET filnam2 FOR OUTPUT IN LEGACY TEXT MODE.
LOOP AT itab9.
TRANSFER itab9 TO filnam2.
ENDLOOP.
CLOSE DATASET filnam2.
IF sy-subrc EQ 0.
MESSAGE s004.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = FILNAM21
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
IMPORTING
FILELENGTH =
tables
data_tab = itab2
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc eq 0.
message s004.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
*& Form POPULATE
text
FORM populate.
CLEAR value.
REFRESH list.
name = 'KHINR1'.
value-key = '1S7_SUBSEA'.
value-text = '1S7_SUBSEA'.
APPEND value TO list.
value-key = '1S7_GEN'.
value-text = '1S7_GEN'.
APPEND value TO list.
value-key = '1S7'.
value-text = '1S7'.
APPEND value TO list.
value-key = '1S7_CORPTP'.
value-text = '1S7_CORPTP'.
APPEND value TO list.
value-key = '1S7_BRRE'.
value-text = '1S7_BRRE'.
APPEND value TO list.
value-key = '1S7_BRCON'.
value-text = '1S7_BRCON'.
APPEND value TO list.
value-key = '1S7_BRCJOB'.
value-text = '1S7_BRCJOB'.
APPEND value TO list.
value-key = '1S7_BRCJBU'.
value-text = '1S7_BRCJBU'.
APPEND value TO list.
value-key = '1S7_BRCJCO'.
value-text = '1S7_BRCJCO'.
APPEND value TO list.
value-key = '1S7_BRCJIR'.
value-text = '1S7_BRCJIR'.
APPEND value TO list.
value-key = '1S7_BRCJEN'.
value-text = '1S7_BRCJEN'.
APPEND value TO list.
value-key = '1S7_BRCJPI'.
value-text = '1S7_BRCJPI'.
APPEND value TO list.
value-key = '1S7_BRCJSU'.
value-text = '1S7_BRCJSU'.
APPEND value TO list.
value-key = '1S7_BRCJFL'.
value-text = '1S7_BRCJFL'.
APPEND value TO list.
value-key = '1S7_BRCJOT'.
value-text = '1S7_BRCJOT'.
APPEND value TO list.
value-key = '1S7_BRCASV'.
value-text = '1S7_BRCASV'.
APPEND value TO list.
value-key = '1S7_BRCASE'.
value-text = '1S7_BRCASE'.
APPEND value TO list.
value-key = '1S7_BRCOOC'.
value-text = '1S7_BRCOOC'.
APPEND value TO list.
value-key = '1S7_BRCOHD'.
value-text = '1S7_BRCOHD'.
APPEND value TO list.
value-key = '1S7_BRCGEN'.
value-text = '1S7_BRCGEN'.
APPEND value TO list.
value-key = '1S7_BRDRI'.
value-text = '1S7_BRDRI'.
APPEND value TO list.
value-key = '1S7_BRDJOB'.
value-text = '1S7_BRDJOB'.
APPEND value TO list.
value-key = '1S7_BRDASV'.
value-text = '1S7_BRDASV'.
APPEND value TO list.
value-key = '1S7_BRDASE'.
value-text = '1S7_BRDASE'.
APPEND value TO list.
value-key = '1S7_BRDAEW'.
value-text = '1S7_BRDAEW'.
APPEND value TO list.
value-key = '1S7_BRDAEO'.
value-text = '1S7_BRDAEO'.
APPEND value TO list.
value-key = '1S7_BRDAET'.
value-text = '1S7_BRDAET'.
APPEND value TO list.
value-key = '1S7_BRDOOC'.
value-text = '1S7_BRDOOC'.
APPEND value TO list.
value-key = '1S7_BRDOHD'.
value-text = '1S7_BRDOHD'.
APPEND value TO list.
value-key = '1S7_BRVER'.
value-text = '1S7_BRVER'.
APPEND value TO list.
value-key = '1S7_BRVJOB'.
value-text = '1S7_BRVJOB'.
APPEND value TO list.
value-key = '1S7_BRVASV'.
value-text = '1S7_BRVASV'.
APPEND value TO list.
value-key = '1S7_BRVASE'.
value-text = '1S7_BRVASE'.
APPEND value TO list.
value-key = '1S7_BRVOOC'.
value-text = '1S7_BRVOOC'.
APPEND value TO list.
value-key = '1S7_BRVOHD'.
value-text = '1S7_BRVOHD'.
APPEND value TO list.
value-key = '1S7_UKRE'.
value-text = '1S7_UKRE'.
APPEND value TO list.
value-key = '1S7_UKCON'.
value-text = '1S7_UKCON'.
APPEND value TO list.
value-key = '1S7_UKCJOB'.
value-text = '1S7_UKCJOB'.
APPEND value TO list.
value-key = '1S7_UKCJBU'.
value-text = '1S7_UKCJBU'.
APPEND value TO list.
value-key = '1S7_UKCJCO'.
value-text = '1S7_UKCJCO'.
APPEND value TO list.
value-key = '1S7_UKCJIR'.
value-text = '1S7_UKCJIR'.
APPEND value TO list.
value-key = '1S7_UKCJEN'.
value-text = '1S7_UKCJEN'.
APPEND value TO list.
value-key = '1S7_UKCJPI'.
value-text = '1S7_UKCJPI'.
APPEND value TO list.
value-key = '1S7_UKCJSU'.
value-text = '1S7_UKCJSU'.
APPEND value TO list.
value-key = '1S7_UKCJFL'.
value-text = '1S7_UKCJFL'.
APPEND value TO list.
value-key = '1S7_UKCJOT'.
value-text = '1S7_UKCJOT'.
APPEND value TO list.
value-key = '1S7_UKCASV'.
value-text = '1S7_UKCASV'.
APPEND value TO list.
value-key = '1S7_UKCASE'.
value-text = '1S7_UKCASE'.
APPEND value TO list.
value-key = '1S7_UKCOOC'.
value-text = '1S7_UKCOOC'.
APPEND value TO list.
value-key = '1S7_UKBA'.
value-text = '1S7_UKBA'.
APPEND value TO list.
value-key = '1S7_UKBATE'.
value-text = '1S7_UKBATE'.
APPEND value TO list.
value-key = '1S7_UKCOHD'.
value-text = '1S7_UKCOHD'.
APPEND value TO list.
value-key = '1S7_UKCGEN'.
value-text = '1S7_UKCGEN'.
APPEND value TO list.
value-key = '1S7_UKDRI'.
value-text = '1S7_UKDRI'.
APPEND value TO list.
value-key = '1S7_UKDJOB'.
value-text = '1S7_UKDJOB'.
APPEND value TO list.
value-key = '1S7_UKDASV'.
value-text = '1S7_UKDASV'.
APPEND value TO list.
value-key = '1S7_UKDASE'.
value-text = '1S7_UKDASE'.
APPEND value TO list.
value-key = '1S7_UKDAEW'.
value-text = '1S7_UKDAEW'.
APPEND value TO list.
value-key = '1S7_UKDAEO'.
value-text = '1S7_UKDAEO'.
APPEND value TO list.
value-key = '1S7_UKDAET'.
value-text = '1S7_UKDAET'.
APPEND value TO list.
value-key = '1S7_UKDOOC'.
value-text = '1S7_UKDOOC'.
APPEND value TO list.
value-key = '1S7_UKDOHD'.
value-text = '1S7_UKDOHD'.
APPEND value TO list.
value-key = '1S7_UKVER'.
value-text = '1S7_UKVER'.
APPEND value TO list.
value-key = '1S7_UKVJOB'.
value-text = '1S7_UKVJOB'.
APPEND value TO list.
value-key = '1S7_UKVASV'.
value-text = '1S7_UKVASV'.
APPEND value TO list.
value-key = '1S7_UKVASE'.
value-text = '1S7_UKVASE'.
APPEND value TO list.
value-key = '1S7_UKVOOC'.
value-text = '1S7_UKVOOC'.
APPEND value TO list.
value-key = '1S7_UKVOHD'.
value-text = '1S7_UKVOHD'.
APPEND value TO list.
value-key = '1S7_NORE'.
value-text = '1S7_NORE'.
APPEND value TO list.
value-key = '1S7_NOCON'.
value-text = '1S7_NOCON'.
APPEND value TO list.
value-key = '1S7_NOCJOB'.
value-text = '1S7_NOCJOB'.
APPEND value TO list.
value-key = '1S7_NOCJBU'.
value-text = '1S7_NOCJBU'.
APPEND value TO list.
value-key = '1S7_NOCJCO'.
value-text = '1S7_NOCJCO'.
APPEND value TO list.
value-key = '1S7_NOCJIR'.
value-text = '1S7_NOCJIR'.
APPEND value TO list.
value-key = '1S7_NOCJEN'.
value-text = '1S7_NOCJEN'.
APPEND value TO list.
value-key = '1S7_NOCJPI'.
value-text = '1S7_NOCJPI'.
APPEND value TO list.
value-key = '1S7_NOCJSU'.
value-text = '1S7_NOCJSU'.
APPEND value TO list.
value-key = '1S7_NOCJFL'.
value-text = '1S7_NOCJFL'.
APPEND value TO list.
value-key = '1S7_NOCJOT'.
value-text = '1S7_NOCJOT'.
APPEND value TO list.
value-key = '1S7_NOCASV'.
value-text = '1S7_NOCASV'.
APPEND value TO list.
value-key = '1S7_NOCASE'.
value-text = '1S7_NOCASE'.
APPEND value TO list.
value-key = '1S7_NOCOOC'.
value-text = '1S7_NOCOOC'.
APPEND value TO list.
value-key = '1S7_NOCOHD'.
value-text = '1S7_NOCOHD'.
APPEND value TO list.
value-key = '1S7_NOCGEN'.
value-text = '1S7_NOCGEN'.
APPEND value TO list.
value-key = '1S7_NODRI'.
value-text = '1S7_NODRI'.
APPEND value TO list.
value-key = '1S7_NODJOB'.
value-text = '1S7_NODJOB'.
APPEND value TO list.
value-key = '1S7_NODASV'.
value-text = '1S7_NODASV'.
APPEND value TO list.
value-key = '1S7_NODASE'.
value-text = '1S7_NODASE'.
APPEND value TO list.
value-key = '1S7_NODAEW'.
value-text = '1S7_NODAEW'.
APPEND value TO list.
value-key = '1S7_NODAEO'.
value-text = '1S7_NODAEO'.
APPEND value TO list.
value-key = '1S7_NODAET'.
value-text = '1S7_NODAET'.
APPEND value TO list.
value-key = '1S7_NODOOC'.
value-text = '1S7_NODOOC'.
APPEND value TO list.
value-key = '1S7_NODOHD'.
value-text = '1S7_NODOHD'.
APPEND value TO list.
value-key = '1S7_NOVER'.
value-text = '1S7_NOVER'.
APPEND value TO list.
value-key = '1S7_NOVJOB'.
value-text = '1S7_NOVJOB'.
APPEND value TO list.
value-key = '1S7_NOVASV'.
value-text = '1S7_NOVASV'.
APPEND value TO list.
value-key = '1S7_NOVASE'.
value-text = '1S7_NOVASE'.
APPEND value TO list.
value-key = '1S7_NOVOOC'.
value-text = '1S7_NOVOOC'.
APPEND value TO list.
value-key = '1S7_NOVOHD'.
value-text = '1S7_NOVOHD'.
APPEND value TO list.
value-key = '1S7_GORE'.
value-text = '1S7_GORE'.
APPEND value TO list.
value-key = '1S7_GOCON'.
value-text = '1S7_GOCON'.
APPEND value TO list.
value-key = '1S7_GOCJOB'.
value-text = '1S7_GOCJOB'.
APPEND value TO list.
value-key = '1S7_GOCJBU'.
value-text = '1S7_GOCJBU'.
APPEND value TO list.
value-key = '1S7_GOCJCO'.
value-text = '1S7_GOCJCO'.
APPEND value TO list.
value-key = '1S7_GOCJIR'.
value-text = '1S7_GOCJIR'.
APPEND value TO list.
value-key = '1S7_GOCJEN'.
value-text = '1S7_GOCJEN'.
APPEND value TO list.
value-key = '1S7_GOCJPI'.
value-text = '1S7_GOCJPI'.
APPEND value TO list.
value-key = '1S7_GOCJSU'.
value-text = '1S7_GOCJSU'.
APPEND value TO list.
value-key = '1S7_GOCJFL'.
value-text = '1S7_GOCJFL'.
APPEND value TO list.
value-key = '1S7_GOCJOT'.
value-text = '1S7_GOCJOT'.
APPEND value TO list.
value-key = '1S7_GOCASV'.
value-text = '1S7_GOCASV'.
APPEND value TO list.
value-key = '1S7_GOCASE'.
value-text = '1S7_GOCASE'.
APPEND value TO list.
value-key = '1S7_GOCOOC'.
value-text = '1S7_GOCOOC'.
APPEND value TO list.
value-key = '1S7_GOCOHD'.
value-text = '1S7_GOCOHD'.
APPEND value TO list.
value-key = '1S7_GOCGEN'.
value-text = '1S7_GOCGEN'.
APPEND value TO list.
value-key = '1S7_GODRI'.
value-text = '1S7_GODRI'.
APPEND value TO list.
value-key = '1S7_GODJOB'.
value-text = '1S7_GODJOB'.
APPEND value TO list.
value-key = '1S7_GODASV'.
value-text = '1S7_GODASV'.
APPEND value TO list.
value-key = '1S7_GODASE'.
value-text = '1S7_GODASE'.
APPEND value TO list.
value-key = '1S7_GODAEW'.
value-text = '1S7_GODAEW'.
APPEND value TO list.
value-key = '1S7_GODAEO'.
value-text = '1S7_GODAEO'.
APPEND value TO list.
value-key = '1S7_GODAET'.
value-text = '1S7_GODAET'.
APPEND value TO list.
value-key = '1S7_GODOOC'.
value-text = '1S7_GODOOC'.
APPEND value TO list.
value-key = '1S7_GODOHD'.
value-text = '1S7_GODOHD'.
APPEND value TO list.
value-key = '1S7_GOVER'.
value-text = '1S7_GOVER'.
APPEND value TO list.
value-key = '1S7_GOVJOB'.
value-text = '1S7_GOVJOB'.
APPEND value TO list.
value-key = '1S7_GOVASV'.
value-text = '1S7_GOVASV'.
APPEND value TO list.
value-key = '1S7_GOVASE'.
value-text = '1S7_GOVASE'.
APPEND value TO list.
value-key = '1S7_GOVOOC'.
value-text = '1S7_GOVOOC'.
APPEND value TO list.
value-key = '1S7_GOVOHD'.
value-text = '1S7_GOVOHD'.
APPEND value TO list.
value-key = '1S7_GVRE'.
value-text = '1S7_GVRE'.
APPEND value TO list.
value-key = '1S7_GVCON'.
value-text = '1S7_GVCON'.
APPEND value TO list.
value-key = '1S7_GVCJOB'.
value-text = '1S7_GVCJOB'.
APPEND value TO list.
value-key = '1S7_GVCJBU'.
value-text = '1S7_GVCJBU'.
APPEND value TO list.
value-key = '1S7_GVCJCO'.
value-text = '1S7_GVCJCO'.
APPEND value TO list.
value-key = '1S7_GVCJIR'.
value-text = '1S7_GVCJIR'.
APPEND value TO list.
value-key = '1S7_GVCJEN'.
value-text = '1S7_GVCJEN'.
APPEND value TO list.
value-key = '1S7_GVCJPI'.
value-text = '1S7_GVCJPI'.
APPEND value TO list.
value-key = '1S7_GVCJSU'.
value-text = '1S7_GVCJSU'.
APPEND value TO list.
value-key = '1S7_GVCJFL'.
value-text = '1S7_GVCJFL'.
APPEND value TO list.
value-key = '1S7_GVCJOT'.
value-text = '1S7_GVCJOT'.
APPEND value TO list.
value-key = '1S7_GVCASV'.
value-text = '1S7_GVCASV'.
APPEND value TO list.
value-key = '1S7_GVCASE'.
value-text = '1S7_GVCASE'.
APPEND value TO list.
value-key = '1S7_GVCOOC'.
value-text = '1S7_GVCOOC'.
APPEND value TO list.
value-key = '1S7_GVCOHD'.
value-text = '1S7_GVCOHD'.
APPEND value TO list.
value-key = '1S7_GVCGEN'.
value-text = '1S7_GVCGEN'.
APPEND value TO list.
value-key = '1S7_GVDRI'.
value-text = '1S7_GVDRI'.
APPEND value TO list.
value-key = '1S7_GVDJOB'.
value-text = '1S7_GVDJOB'.
APPEND value TO list.
value-key = '1S7_GVDASV'.
value-text = '1S7_GVDASV'.
APPEND value TO list.
value-key = '1S7_GVDASE'.
value-text = '1S7_GVDASE'.
APPEND value TO list.
value-key = '1S7_GVDOOC'.
value-text = '1S7_GVDOOC'.
APPEND value TO list.
value-key = '1S7_GVDOHD'.
value-text = '1S7_GVDOHD'.
APPEND value TO list.
value-key = '1S7_GVVER'.
value-text = '1S7_GVVER'.
APPEND value TO list.
value-key = '1S7_GVVJOB'.
value-text = '1S7_GVVJOB'.
APPEND value TO list.
value-key = '1S7_GVVASV'.
value-text = '1S7_GVVASV'.
APPEND value TO list.
value-key = '1S7_GVVASE'.
value-text = '1S7_GVVASE'.
APPEND value TO list.
value-key = '1S7_GVVOOC'.
value-text = '1S7_GVVOOC'.
APPEND value TO list.
value-key = '1S7_GVVOHD'.
value-text = '1S7_GVVOHD'.
APPEND value TO list.
value-key = '1S7_GCRE'.
value-text = '1S7_GCRE'.
APPEND value TO list.
value-key = '1S7_GCCON'.
value-text = '1S7_GCCON'.
APPEND value TO list.
value-key = '1S7_GCCJOB'.
value-text = '1S7_GCCJOB'.
APPEND value TO list.
value-key = '1S7_GCCJBU'.
value-text = '1S7_GCCJBU'.
APPEND value TO list.
value-key = '1S7_GCCJCO'.
value-text = '1S7_GCCJCO'.
APPEND value TO list.
value-key = '1S7_GCCJIR'.
value-text = '1S7_GCCJIR'.
APPEND value TO list.
value-key = '1S7_GCCJEN'.
value-text = '1S7_GCCJEN'.
APPEND value TO list.
value-key = '1S7_GCCJPI'.
value-text = '1S7_GCCJPI'.
APPEND value TO list.
value-key = '1S7_GCCJSU'.
value-text = '1S7_GCCJSU'.
APPEND value TO list.
value-key = '1S7_GCCJFL'.
value-text = '1S7_GCCJFL'.
APPEND value TO list.
value-key = '1S7_GCCJOT'.
value-text = '1S7_GCCJOT'.
APPEND value TO list.
value-key = '1S7_GCCASV'.
value-text = '1S7_GCCASV'.
APPEND value TO list.
value-key = '1S7_GCCASE'.
value-text = '1S7_GCCASE'.
APPEND value TO list.
value-key = '1S7_GCCOOC'.
value-text = '1S7_GCCOOC'.
APPEND value TO list.
value-key = '1S7_GCCOHD'.
value-text = '1S7_GCCOHD'.
APPEND value TO list.
value-key = '1S7_GCCRD'.
value-text = '1S7_GCCRD'.
APPEND value TO list.
value-key = '1S7_GCCGEN'.
value-text = '1S7_GCCGEN'.
APPEND value TO list.
value-key = '1S7_GCDRI'.
value-text = '1S7_GCDRI'.
APPEND value TO list.
value-key = '1S7_GCDJOB'.
value-text = '1S7_GCDJOB'.
APPEND value TO list.
value-key = '1S7_GCDASV'.
value-text = '1S7_GCDASV'.
APPEND value TO list.
value-key = '1S7_GCDASE'.
value-text = '1S7_GCDASE'.
APPEND value TO list.
value-key = '1S7_GCDOOC'.
value-text = '1S7_GCDOOC'.
APPEND value TO list.
value-key = '1S7_GCDOHD'.
value-text = '1S7_GCDOHD'.
APPEND value TO list.
value-key = '1S7_GCVER'.
value-text = '1S7_GCVER'.
APPEND value TO list.
value-key = '1S7_GCVJOB'.
value-text = '1S7_GCVJOB'.
APPEND value TO list.
value-key = '1S7_GCVASV'.
value-text = '1S7_GCVASV'.
APPEND value TO list.
value-key = '1S7_GCVASE'.
value-text = '1S7_GCVASE'.
APPEND value TO list.
value-key = '1S7_GCVOOC'.
value-text = '1S7_GCVOOC'.
APPEND value TO list.
value-key = '1S7_GCVOHD'. -
How to use a case statement in where clause
Hi All,
I have a requirement which is to bring all the claims that are created in the last month.So, i wrote a query something like this
select * from claims
where
(Month(ClaimOpenDate) = Month(Getdate())-1 and year(claimopendate) = year(getDate()))
which would give me any new claims created in last month of current year, but this condition fails if we are in the first month of a new year( lets say if we are in 2016 jan then month(getdate())-1 would be 0 and year(getdate()) would be 2016 so we dont
find any records where year is 2016 and month is 0 for claimopen).
So, i would like to use a case statament or something which can help me get around this one.
Can someone please help me with any suggestions?
ThanksHi Jason,
Thanks a lot for your help. This is what exactly i am looking for but i just gave a sample query above below is my original query
select
row_number() over (order by [ClaimNumber]) as DataElementName
,c.PolicyNumber as PolicyNum
, c.FirstName as CustNameF
,c.LastName as CustNameL
,c.PolicyForm as PolType
,'Homesite' as Company
,[ClaimNumber] as ClaimNum
,E.office as Ofc
,e.Supervisior_FullName as Team
, RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FORepF
, case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FORepL
,e.AdjusterID as RepC -- not sure
,CONVERT ( varchar,c.LossDate ,101) as DOL
,convert (varchar,c.ClaimOpenDate,101) as DOR
,rtrim(c.Loss_State) as LossSt
,c.Loss_ZipCode as LossZIP
,c.Loss_City as LossCity
,c.LossType as FOL
,'' as PR
,'' as PRNum
,1 as FeaNum
,'HO' as FeaType
,case when rtrim(c.claimStatus)= 'Closed' then 'Closed' else 'Open' end as FeaStat
,'' as FeaOpen
,'' as FeaClosed
,s.PaymentIndemnityAmount as PaidAmt
,s.ReserveIndemnityAmount as Reserve
,'' as Sub
,'' as Sal
,'' as FeatOwnOfc
,e.Supervisior_FullName as FeatOwnTeam
,RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FeatOwnRepF
,case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FeatOwnRepL
,e.AdjusterID as FeatOwnRepCode
,NULL AS Description --not sure
from [Stg].[HS_DW_RV_Claims] c
inner join [dbo].[Claims_Primary_Adjuster] a on a.CLAIM_NUMBER = c.ClaimNumber
inner join [dbo].[vw_Adjuster] e on e.adjuster_Name = a.primary_ADJUSTER
left outer join [Stg].[HS_DW_LossClaimSummary] s on c.ClaimKey=s.ClaimKey
where c.LoadSource = 'CMS'
and
(s.PaymentIndemnityAmount <>0 or s.PaymentExpenseAmount <>0)
and
ClaimOpenDate BETWEEN DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP) -1, 0) AND DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP), 0)
UNION ALL
select
row_number() over (order by [ClaimNumber]) as DataElementName
,c.PolicyNumber as PolicyNum
, c.FirstName as CustNameF
,c.LastName as CustNameL
,c.PolicyForm as PolType
,'Homesite' as Company
,[ClaimNumber] as ClaimNum
,E.office as Ofc
,e.Supervisior_FullName as Team
, RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FORepF
, case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FORepL
,e.AdjusterID as RepC -- not sure
,CONVERT ( varchar,c.LossDate ,101) as DOL
,convert (varchar,c.ClaimOpenDate,101) as DOR
,rtrim(c.Loss_State) as LossSt
,c.Loss_ZipCode as LossZIP
,c.Loss_City as LossCity
,c.LossType as FOL
,'' as PR
,'' as PRNum
,1 as FeaNum
,'HO' as FeaType
,case when rtrim(c.claimStatus)= 'Closed' then 'Closed' else 'Open' end as FeaStat
,'' as FeaOpen
,'' as FeaClosed
,s.PaymentIndemnityAmount as PaidAmt
,s.ReserveIndemnityAmount as Reserve
,'' as Sub
,'' as Sal
,'' as FeatOwnOfc
,e.Supervisior_FullName as FeatOwnTeam
,RIGHT(e.adjuster_Name ,LEN(e.adjuster_Name)- charindex(',' ,e.adjuster_Name)) as FeatOwnRepF
,case when charindex(',' ,e.adjuster_Name) <> 0 then left(e.adjuster_Name,charindex(',' ,e.adjuster_Name)-1) else e.adjuster_Name end as FeatOwnRepL
,e.AdjusterID as FeatOwnRepCode
,DESCRIPTION --not sure
from Stg.IG_Document D
inner join [Stg].[HS_DW_RV_Claims] c on D.PARENTREF = C.ClaimNumber
inner join [dbo].[Claims_Primary_Adjuster] a on a.CLAIM_NUMBER = c.ClaimNumber
inner join [dbo].[vw_Adjuster] e on e.adjuster_Name = a.primary_ADJUSTER
left outer join [Stg].[HS_DW_LossClaimSummary] s on c.ClaimKey=s.ClaimKey
where c.LoadSource = 'CMS'
and
DESCRIPTION like '%Denial Letter%'
and
ClaimOpenDate BETWEEN DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP) -1, 0) AND DATEADD(mm, DATEDIFF(mm, 0, CURRENT_TIMESTAMP), 0)
So if i use your logic in the end for both the where clauses its been more than 10 minutes and the query is still running however if i use my old method it doesnt even take a second. Looks like its affecting the execution plan. Any suggestions to get around
this one please?
Thanks -
Is it possible to use the same Switch for two different clusters.
I have 10g Rac setup on windows.
Now I am planning to install 11gR2 on different servers.
Is it possible to use the same Switch for two different clusters.user9198027 wrote:
I have 10g Rac setup on windows.
Now I am planning to install 11gR2 on different servers.
Is it possible to use the same Switch for two different clusters.
Yes. Technically there will not be any conflict as long as the private addresses used by the 2 clusters do not collide, and provided that the switch's port capacity and bandwidth will not be exceeded.
Your NA (netadmin) can also configure the switch to separate the 2 Interconnects from one another (called partitioning when using Infiniband) - if the switch supports such features.
A major consideration is not to make the switch, public. That typically cause a range of problems and can have a serious impact on an Interconnect. But using 2 private networks on the same infrastructure should not have the same problems - if configured and implemented correctly. -
How to prevent Oracle from using an index when joining two tables ...
How to prevent Oracle from using an index when joining two tables to get an inline view which is used in an update statement?
O.K. I think I have to explain what I mean:
When joining two tables which have many entries sometimes it es better not to use an index on the column used as join criteria.
I have two tables: table A and table B.
Table A has 4.000.000 entries and table B has 700.000 entries.
I have a join of both tables with a numeric column as join criteria.
There is an index on this column in table A.
So I instead of
where (A.col = B.col)I want to use
where (A.col+0 = B.col)in order to prevent Oracle from using the index.
When I use the join in a select statement it works.
But when I use the join as inline view in an update statement I get the error ORA-01779.
When I remove the "+0" the update statement works. (The column col is unique in table B).
Any ideas why this happens?
Thank you very much in advance for any help.
Regards HartmutI think you should post an properly formatted explain plan output using DBMS_XPLAN.DISPLAY including the "Predicate Information" section below the plan to provide more details regarding your query resp. update statement. Please use the \[code\] and \[code\] tags to enhance readability of the output provided:
In SQL*Plus:
SET LINESIZE 130
EXPLAIN PLAN FOR <your statement>;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);Usually if you're using the CBO (cost based optimizer) and have reasonable statistics gathered on the database objects used the optimizer should be able to determine if it is better to use the existing index or not.
Things look different if you don't have statistics, you have outdated/wrong statistics or deliberately still use the RBO (rule based optimizer). In this case you would have to use other means to prevent the index usage, the most obvious would be the already mentioned NO_INDEX or FULL hint.
But I strongly recommend to check in first place why the optimizer apparently seems to choose an inappropriate index access path.
Regards,
Randolf
Oracle related stuff:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle:
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Update statement with joining other tables
Hi ,
I have two table one is containing xml file , basically i need to read from those xml file then update to another table based on some condition.
UPDATE TRCB_XBRL_STG_2 STG
SET PROFIT =
case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') is not null
THEN EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."')
WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..') IS NOT NULL
THEN extractValue(XBRL.xbrlfile,'//PROFIT ', 'xmlns:acra=".."')
ELSE STG.PROFIT
END,
SET REVENUE=
case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..."') is not null
THEN EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE.', 'xmlns:acra="..."')
WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..') IS NOT NULL
THEN extractValue(XBRL.xbrlfile,'//REVENUE', 'xmlns:acra="REVENUE"')
ELSE STG.REVENUE
END,
... (around 100 columns)
FROM TRCB_XBRL xbrl ,TRCB_XBRL_STG_2 STG
WHERE STG.XBRL_ID = XBRL.XBRL_ID Number of columns are around 100 , please anyone suggest how to use update statement with joining two tables.Hi,
If all the values needed to update a given row of table_x are coming from the same row of table_y (or from the same row of a result set of a query involving any number of tables), then you can do something like this:
UPDATE table_x x
SET (col1, col2, col3, ...)
= (
SELECT NVL (y.col1, x.col1)
, NVL (y.col2, x.col2)
, NVL (y.col3, x.col3)
FROM table_y y
WHERE x.pkey = y.expr
AND ...
WHERE ...
;If the WHERE clause depends on the same row of table_y, then it will probably be simpler and more efficient to use MERGE instead of UPDATE.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ {message:id=9360002} -
Need help in using a case statement in expression operator
Hi All,
I am using OWB version 10.2.0.1.0.
My requirement is to add a new column called call _zone_key in expression operator and map it to the target table. I need to use the below expression for populating call_zone_key values
Expression:
case when (INGRP1.CHARGETYPE in ('O','F') or INGRP1.TARIFF_GROUP in ('SMSINT','MMSINT')or ( INGRP1.CALL_TYPE = '002' and INGRP1.TARIFF_GROUP = 'MTV'))
then
(select call_zone_reltn_key from call_zone_reltn where
call_zone_cd=substr(case
when substr( INGRP1.B_SUBNO,1,2)='00'
then
substr( INGRP1.B_SUBNO,3)
else substr( INGRP1.B_SUBNO,1)
end,1,length(call_zone_cd))and rownum=1)
else -1
end
All the columns needed for using the above expression is available in INGRP1 but still I am unable to deploy the mapping using above expression. Call_zone_reltn table is also imported to the module. I am getting below error
Error:
Warning
ORA-06550: line 4980, column 2:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternativ
NEW_MOD_MAP_CELL_USAGE_FCT_PRE
Create
Warning
ORA-06550: line 4989, column 43:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
* & - + ; / at for mod remainder rem <an exponent (**)> and
or group having intersect minus order start union where
connect || multiset
If i replace the expression with numbers such as 1 or 2, I am able to deploy the mapping.
Kindly help in fixing this issue.
Thanks,
KabilanYou can't use the SELECT statement inside the expression, you need to join both tables before the expression. Use a Join operator with this JOIN condition:
CALCULATED_CALL_ZONE_CD = call_zone_reltn.call_zone_cd ( + )
Where Calculated_call_zone_cd proceed from a previous expression:
CALCULATED_CALL_ZONE_CD = substr(case when substr( INGRP1.B_SUBNO,1,2)='00' then substr( INGRP1.B_SUBNO,3) else substr( INGRP1.B_SUBNO,1) end,1,length(call_zone_cd))
And after joining both tables, you can use another expression to get the rownum, then another filter operator to keep only the rownum = 1, and now you can use your expression without the SELECT, using the call_zone_cd column from the outgroup in the joiner operator (you need to include that column in the filter operator to use it).
Regards
ANA GH -
Is it possible to use the case structure in on board progamming
Hi
I want to load a certain value in a variable in on board programming based on the encoder. How to implement this in 7344.No, it is not possible to use the labVIEW case structure in an onboard program. However, it is possible to implement the functionality you need by using a label, a jump to label on condition function and two on board variables. What you need to do is read the value of your encoder into one of the variables, once this value is in there you will use some of the variable arithmetic functions to compare its value to a value you would load into the second on board variable (the most common way is to use the subtract variables function). The result of the last varible operation is the used inside the jump to label on condition fucntion to evaluate the condition and to jump or not jump back to the label dependding on the result. For a much clearer explanation of this functional
ity as well as some example code, please refer to chapter 15 of the following manual:
http://digital.ni.com/manuals.nsf/websearch/EB609F9BA065EA7A86256D350060C9A0?OpenDocument&node=132100_US -
Should I use a CASE statement to accomplish or something else
So I have the following query right now
select *
--bulk collect into possession_leaders
from
select distinct
opt.team_id,
sch.game_code,
sch.game_code_1032,
sch.home_team_id_1032,
sch.home_team_id,
sch.home_team_name,
sch.home_team_nickname,
sch.home_team_abbrev,
sch.away_team_id_1032,
sch.away_team_id,
sch.away_team_name,
sch.away_team_nickname,
sch.away_team_abbrev,
opt.possession,
rank () over (order by possession desc) as rankings_order
from
customer_data.cd_soccer_schedule sch,
soccer.soccer_optical_team_gm_stats opt
where sch.game_code = opt.game_code
and sch.season_id = 200921
and opt.possession is not null
order by rankings_order asc
)It outputs the following (Sorry for it being so cramped together):
**Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it does
1 5358 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 69.5% 1
2 5354 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 58.1% 2
3 5721 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 56% 3
4 5360 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 55.6% 4
5 5361 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 55.4% 5
6 5362 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 50.1% 6
7 5363 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 49.9% 7
8 5358 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 44.6% 8
9 5362 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 44.4% 9
10 5363 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 44% 10
11 5362 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 41.9% 11
12 5359 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 30.5% 12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
so if team_id = home_team_id for example then I want the following...
sch.home_team_id_1032 as team_code_1032,
sch.home_team_id as team_code,
sch.home_team_name as team_name,
sch.home_team_nickname as team_nickname,
sch.home_team_abbrev as team_abbrev
and then the away team columns would be...
sch.away_team_id_1032 as opp_team_code_1032,
sch.away_team_id as opp_team_code,
sch.away_team_name as opp_team_name,
sch.away_team_nickname as opp_team_nickname,
sch.away_team_abbrev as opp_team_abbrev
and same thing vice versa if the team_id column matches the away_team_id
How is the best way to go about this? W/a case statement? and if so can someone please post the logic/Hi,
user652714 wrote:
So I have the following query right now
select *
--bulk collect into possession_leaders
from
select distinct
opt.team_id,
sch.game_code,
sch.game_code_1032,
sch.home_team_id_1032,
sch.home_team_id,
sch.home_team_name,
sch.home_team_nickname,
sch.home_team_abbrev,
sch.away_team_id_1032,
sch.away_team_id,
sch.away_team_name,
sch.away_team_nickname,
sch.away_team_abbrev,
opt.possession,
rank () over (order by possession desc) as rankings_order
from
customer_data.cd_soccer_schedule sch,
soccer.soccer_optical_team_gm_stats opt
where sch.game_code = opt.game_code
and sch.season_id = 200921
and opt.possession is not null
order by rankings_order asc
)It outputs the following (Sorry for it being so cramped together):
**Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it doesAre you sure?
The 6th column in the query is home_team name; the 6th column of the output has values like 5359 and 5354. Did you perhaps duplicate the rankings_iorder column at the beginning of the results?
Why don't you simplify the problem. Instead of 15 or 16 columns, 10 of which are twins (5 pairs of 2 columns), why don't you post a problem with 6 columns, 4 of which are twins? Pick short columns, such as home_team_abbrev rather than home_team_name.
Adding the other columns later should be easy; merely a matter of coping one of the columns ion the solution.
Whenever you have a problem, post some sample data and the results you want from that data.
In this case, the sample data can be about 6 columns from the result set below. I'll bet you can make a good sample set with fewer than 12 rows, also.
1 5358 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 69.5% 1
2 5354 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 58.1% 2
3 5721 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 56% 3
4 5360 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 55.6% 4
5 5361 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 55.4% 5
6 5362 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 50.1% 6
7 5363 870988 2009050810 10 5362 New York Red Bulls RB 11 5363 San Jose Earthquakes SJ 49.9% 7
8 5358 870961 2009041705 5 5358 D.C. United DC 9 5361 New England Revolution NE 44.6% 8
9 5362 870984 2009050207 7 5360 Los Angeles Galaxy LA 10 5362 New York Red Bulls RB 44.4% 9
10 5363 870983 2009050211 11 5363 San Jose Earthquakes SJ 17 5721 Chivas USA Chv 44% 10
11 5362 870945 2009040501 1 5354 Chicago Fire Chi 10 5362 New York Red Bulls RB 41.9% 11
12 5359 870986 2009050606 6 5359 Kansas City Wizards KC 5 5358 D.C. United DC 30.5% 12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
so if team_id = home_team_id for example then I want the following...
sch.home_team_id_1032 as team_code_1032,
sch.home_team_id as team_code,
sch.home_team_name as team_name,
sch.home_team_nickname as team_nickname,
sch.home_team_abbrev as team_abbrev
and then the away team columns would be...
sch.away_team_id_1032 as opp_team_code_1032,
sch.away_team_id as opp_team_code,
sch.away_team_name as opp_team_name,
sch.away_team_nickname as opp_team_nickname,
sch.away_team_abbrev as opp_team_abbrev
and same thing vice versa if the team_id column matches the away_team_idSorry, column names have to stay the same throughout the query. This is a very unusual request, and it's hard for me to imagine what you really want.
You miight be able to do a UNION and add rows that look like column headings.
No kidding, you have to post the results you want.
No matter how clear an idea you have of what those resutls should be, no one else knows, and it's much easier to post the correct results than to accurately describe them. -
Case statement 'when IN cursor'
Hi folks.
I am wondering if it is possible to use the IN command within a CASE statement?
I am trying to see if a parameter falls under certain dates in another table. I have a cursor declared which points at that column of dates, and my case statement is like so
case parameter_date when IN certain_dates then if_holiday := 1 else if_holiday := 2 end;
It doesn't like it when I try to compile. And my procedure is listed as being Invalid.
Thanks for any help :)I am wondering if it is possible to use the IN command within a CASE statement?Yes.
SQL> select dname
2 , case when deptno in ( select deptno from emp )
3 then 'Has staff' else 'empty' end
4 from dept
5 /
DNAME CASEWHEND
ACCOUNTING Has staff
RESEARCH Has staff
SALES Has staff
OPERATIONS empty
SQL>What we can't do is use PL/SQL cursors like this
case parameter_date when IN certain_dates then if_holiday := 1 else if_holiday := 2 end;
^^^^^^^^^^^^^They're not variables. At least, not that sort of variable.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
Case statement for dashboard text title based on NQ_SESSION.ROLES
Hello,
I figured out on my dashboard I can add a textbox
with the code '@{biserver.variables['NQ_SESSION.ROLES']}' and it shows the user groups. That works great. Now
I need to have a case statement or so that shows a text, that changes
with each user role i.e. each user role gets its own "report title" Is that possible?
Thanks.Hello,
Thanks for the column formula example.
Unfortunately in both cases it resolves to the ELSE clause even when the other two are true:
case when Locate('BIConsumer_Two', VALUEOF(NQ_SESSION.ROLES))>0 then @{VAR_REPORTTITLE}{'test'} when Locate('BIConsumer_One', VALUEOF(NQ_SESSION.ROLES))>0 then @{VAR_REPORTTITLE}{'test2'} else @{VAR_REPORTTITLE}{'test3'} end
case when Position('userrole1' in VALUEOF(NQ_SESSION.ROLES))>0 then 'w00t' else 'ang' end
The one below works (at least I can read test1 on the results page of my answers report:
case when Position('mytestrole' in 'mytestrole')>0 then @{VAR_REPORTTITLE}{'test1'} else @{VAR_REPORTTITLE}{'test'} end
The NQ_SESSION.ROLES comes like this:
'BIConsumer_One;BIAdministrator;AuthenticatedUser;BIConsumer;BIConsumer_Two;BIAuthor'
I realized why I could not resolve it. I did not define it as a session but presentation variable. So here it is a session variable:
case when Position('mytestrole' in 'mytestrole')>0 then VALUEOF(NQ_SESSION.VAR_REPORTTITLE) ='test1' else VALUEOF(NQ_SESSION.VAR_REPORTTITLE)='test2' end
but now there is an error: [nQSError: 26012] -
"key not valid for use in specified state" when installing itunes
I recently uninstalled an older version of itunes, and every time i try to install the newest version it wont work.
I just keep getting the message "key not valid for use in specified state". If you know what to do could you
please make it simple. also do not send me to apple's help section, it does not have ANY answers.
thanks.For "Key not valid for use in specified state" errors try moving the folder RSA from C:\Users\<User>\AppData\Roaming\Microsoft\Crypto\RSA to say C:\RSA (just in case there should be a need to restore it) then try installing again. This folder appears to act as a cache and should be rebuilt automatically as required.
There is a link to 7-zip in the Install missing components section of the user tip Troubleshooting issues with iTunes for Windows updates, but if you have the key not valid error the advice above should work, and there is no need to break down the setup file.
tt2 -
While doing a routine update from Lightroom 5.5 to v5.6 in Win 8.1, the installation halted at the start of the installation with the vague error message, "key not valid for use in specified state". Although v5.5 was working just fine, the install routine deleted the v5.5 application files. I rolled back to the previous system restore point (set just prior to the install) and recovered the executable files. However, now the 5.5 files won't open the default catalog, none of the backups, or even create a new catalog.
As v5.x was purchased as an update to v4.x, I've tried to reinstall the original Lightroom v4.x app from the factory disk. I get the same error.
Suggestions?
Thanks. DanI have a similar problem to Dan. while doing a routine upgrade from Lightroom 5.5 to 5.6 I got the
: "key not valid for use in specified state"
error and now Lightroom has completely disappeared. I've tried to uninstall, but there is nothing to uninstall. Going back to try to install the original 5.4 just results in the same error.
A problem may have been that I closed Lightroom when the upgrade started to download. It then re-opened again when the install was halfway through., I assumed that was an error and closed it. just after that the error first appeared in the installer.
I still had an older version of lightroom 4 installed. I've uninstalled it, and that didn't make any difference.
I've also tried removing anything in the registry left over from the old installs and that didn't help either.
Any suggestions?
CHeers, Angus
Maybe you are looking for
-
One line item delivery for 3rd party sales order
Hello Experts, We have configured a 3rd party sales order process where the PR gets created. We are using scheduling agreement(PO) and creating Schedule line and doing a GR for partial line items. The stock is recieved as a Sales Order stock. But wh
-
Very Poor Support Service in UK
I had to contact Support Services in the UK last Sunday, and I hope that no other Playbook user in the UK had to go through what I did. I have 3 faults on my Playbook, Dead Pixels, No GPS and Faulty Charging, I contacted Support and in a nutshell the
-
Advanced Queue - Timezone Configuration
Dear Reader If I create an advanced queue with the command "dbms_aqadm.create_queue_table", an entry in the table "system.aq$_queue_tables" results. However, what is not clear to me is why the TIMEZONE column of this table is populated with 00:00, si
-
Anyone figure out how to get Powershot G2 to work again after update to 1.5
All my raw files from my Powershot G2 are now "Unsupported" since the update. Has anyone figured out how to update the program to allow support for that camera again? Any help would be much appreciated! Thanks
-
How's to salute my problem. My ipad after upgrade ios 7 forget the password
How's to salute my problem Ipad after upgrade ios 7 forget the password