Using a view instead of a select statement
Greetings Abapers
Ive got a problem. Im writing a program and one of the things i do is i use 2 select statements which are as follows:
Read all organisational relationships for all business partneru2019s linked to sales codes for all date ranges
select * from hrp1001 into table lt_hrp1001 " Get all external business partners
where plvar eq '01'
and sclas eq 'BP'
and relat eq '008'
or relat eq 'Z40'.
select * from hrp1001 appending corresponding fields of table lt_hrp1001 "Get all employees
where plvar eq '01'
and sclas eq 'BP'
and relat eq '291'
and otype eq 'S'.
I have however been told that i can use the database view HRVPADIC since the hrp1001 table is giving me duplicats which i dont want. Can anyone tell me how to use this view i.e. syntax and logic. I would really appreciate it.
Well, I don't see how using the view would be better. Why don't you just get all of the data at once:
SELECT * FROM hrp1001 INTO TABLE lt_hrp1001
WHERE plvar EQ '01'
AND sclas EQ 'BP'
AND ( ( relat EQ '008'
OR relat EQ 'Z40' )
OR relat EQ '291'
AND otype EQ 'S' ).
(I didn't test this so check it.)
Rob
Similar Messages
-
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
Using temporary tablespace for sort in select statement without spacifying
how can i use some particular temporary tablespace in select statement for sording without allocating any temporary tablespace to that user
Try to set for the current session the in memory sorting space to 0 before running your query:
SQL> alter session set sort_area_size = 0;The query should use the temporary tablespace.
Message was edited by:
Pierre Forstmann -
What is proper syntax for using PassBack in a Report page select statement
In my select statement I reference the passBack function using:
onClick="javascript:passBack()"
In my Page Header I (Typically) define the passBack function as:
<script language="JavaScript" type="text/javascript">
function passBack(passVal1,passVal2) {
opener.document.getElementById("P2000_CABLE_ID").value = passVal1;
opener.document.getElementById("P2000_CABLE_LABEL").value = passVal2;
window.opener.location.reload(true);
</script>
But I have never used the passBack function from the Select statement before and cannot happen onto the proper syntax.
The Page Items I want to pass are:
1. :P2004_CABLE_ID
2. :P2004_LABEL
I want to pass them to:
1. :P2000_CABLE_ID
2. :P2000_CABLE_LABEL
Can someone please help me out... Again?
Thanks- GaryLet's assume column XYZ has both numbers (1), and letters (any alphabet).
I have a case statement on SQL to turn any value that's not 1 into 0, then I am getting a sum of that column.
I am also grouping by Row A, B etc to get aggregated sum of column XYZ for those group.
Now on Crystal Reports function, I need to sum up values under column XYZ for all the groups.
If I try using sum function like below, I get an error stating:
"A number field or currency amount field is required here"
(sum({Command.XYZ}))
So I thought if I can use a case statement to change the non-numbers to 0 prior to sum that will probably resolve it. But I could not get the below case statement to work either (Error: A string is required).
SELECT {Command.XYZ}
Case 1:
1
Default:
0; -
Firefox not displaying buttons and boxes when allow other pages to use their fonts instead of my selection is not selected. The irritating thing is that Firefox used to display pages until FF 31. Please fix this
Thanks
RandyThe missing icons are supplied by a font that is downloaded from the server (@font-face) as you can probably see by little boxes that show the hex code of the characters.
You will have to make sure that you allow pages to choose their own fonts to see such an icon font.
*Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above" -
Use two secondary indexes in a select statement
hi, i want to use two secondary indexes in a select statement.
how can i do it?Hello,
To do it use the WHERE stm in the same order as the secondary stm is on SE11....To check if the index is used go to tcode ST05.
example
select * from ztable
WHERE BUKRS EQ 'BUK1' AND
ZFIELD EQ 'BOY'.
on se11 on the ZTABLE indexes setion must have a secondary index with
BUKRS and
ZFIELD.
BYE!!
Hope this helps!!
Gabriel -
HOW CAN I USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?
HI,
I AM SHABEER AHMED,
I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA BASED ON HEADER DATA .
THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
BYEHi,
1.Just see this:
SELECT * INTO CORRESPONDING FIELD OF TABLE itab
FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
INNER JOIN t3 ON t2f5 EQ t3f5 AND
t2f6 EQ t3f6 AND
t2f7 EQ t3f7.
2.But better to use for all entries.It increases the performance.
FOR ALL ENTRIES
Tabular Conditions
The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
Example for ALL ENTRIES
DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
WITH UNIQUE KEY TABLE LINE,
WA LIKE LINE OF TAB_SFLIGHT.
SELECT CARRID CONNID
INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
FROM SPFLI
WHERE CITYFROM = 'NEW YORK'.
SELECT CARRID CONNID FLDATE
INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
FROM SFLIGHT
FOR ALL ENTRIES IN TAB_SPFLI
WHERE CARRID = TAB_SPFLI-CARRID AND
CONNID = TAB_SPFLI-CONNID.
LOOP AT TAB_SFLIGHT INTO WA.
AT NEW CONNID.
WRITE: / WA-CARRID, WA-CONNID.
ENDAT.
WRITE: / WA-FLDATE.
ENDLOOP.
INNER JOINS
In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
SELECT...
FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
Example for INNER JOINS
REPORT demo_select_inner_join.
DATA: BEGIN OF wa,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
bookid TYPE sbook-bookid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY carrid connid fldate bookid.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
LOOP AT itab INTO wa.
AT NEW fldate.
WRITE: / wa-carrid, wa-connid, wa-fldate.
ENDAT.
WRITE / wa-bookid.
ENDLOOP.
Regards,
Shiva Kumar(Reward if helpful). -
I can't use my field-symbols in my select statement...
Hello experts,
I am have been having problems with my report for the past days. My problem is,
I declared a dynamic field symbol so that I can use it in my select statement
instead of the standard internal table. But it is giving me a dump. Below is my code:
REPORT zfr_forex_rev_acctg
NO STANDARD PAGE HEADING
LINE-COUNT 0
LINE-SIZE 100.
Data dictionary tables *
TABLES: bsis,
bsas,
tcurr,
t001.
FIELD-SYMBOLS: <fs_dyntable> TYPE STANDARD TABLE,
<fs_dynline> TYPE ANY,
<fs_fld> TYPE ANY,
<fs_data> TYPE REF TO data,
<fs_1> TYPE ANY,
<fs_2> TYPE ANY TABLE.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
METHODS: build_table,
get_data,
combine_data,
display_header,
display_results.
PRIVATE SECTION.
TYPES: BEGIN OF t_bsis_bsas,
zuonr TYPE bsis-zuonr,
gjahr TYPE bsis-gjahr,
belnr TYPE bsis-belnr,
bldat TYPE bsis-bldat,
waers TYPE bsis-waers,
blart TYPE bsis-blart,
dmbtr TYPE bsis-dmbtr,
wrbtr TYPE bsis-wrbtr,
hkont TYPE bsis-hkont,
amount TYPE bsis-wrbtr,
END OF t_bsis_bsas.
DATA: it_bsis_bsas TYPE STANDARD TABLE OF t_bsis_bsas,
v_counter TYPE i.
data declarations for internal table
DATA: lt TYPE lvc_t_fcat,
ls TYPE lvc_s_fcat,
fldname(50) TYPE c,
it_ddfields TYPE TABLE OF ddfield,
wa_ddfields LIKE LINE OF it_ddfields.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD build_table
METHOD build_table.
DATA: lv_from TYPE bsis-gjahr,
lv_asof TYPE bsis-gjahr,
lv_check TYPE i,
lt_data TYPE REF TO data,
lt TYPE lvc_t_fcat.
FIELD-SYMBOLS: <fs_year> TYPE gjahr.
ASSIGN lv_asof TO <fs_year>.
lv_from = p_year.
lv_asof = p_asof+0(4).
v_counter = lv_asof - lv_from.
wa_ddfields-fieldname = 'ZUONR'.
wa_ddfields-position = '0001'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000018'.
wa_ddfields-decimals = '00000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'GJAHR'.
wa_ddfields-position = '0002'.
wa_ddfields-datatype = 'NUMC'.
wa_ddfields-leng = '000004'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'BELNR'.
wa_ddfields-position = '0003'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'BLDAT'.
wa_ddfields-position = '0004'.
wa_ddfields-datatype = 'DATS'.
wa_ddfields-leng = '000008'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'WAERS'.
wa_ddfields-position = '0005'.
wa_ddfields-datatype = 'CUKY'.
wa_ddfields-leng = '000005'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'BLART'.
wa_ddfields-position = '0006'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000002'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'DMBTR'.
wa_ddfields-position = '0007'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000013'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'WRBTR'.
wa_ddfields-position = '0008'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000013'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'HKONT'.
wa_ddfields-position = '0009'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
wa_ddfields-fieldname = 'AMOUNT'.
wa_ddfields-position = '0010'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
DATA: lv_position TYPE i.
lv_position = 0011.
WHILE lv_check < v_counter.
<fs_year> = lv_asof.
wa_ddfields-fieldname = <fs_year>.
wa_ddfields-position = lv_position.
wa_ddfields-datatype = 'NUMC'.
wa_ddfields-leng = '000004'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
lv_asof = lv_asof - 1.
ADD 1 TO: lv_check, lv_position.
ENDWHILE.
CLEAR lv_position.
lv_position = 1.
LOOP AT it_ddfields INTO wa_ddfields.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
APPEND ls TO lt.
ADD 1 TO lv_position.
ENDLOOP.
CLEAR lv_position.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <fs_dyntable>.
ENDMETHOD.
METHOD get_data
METHOD get_data.
*get records from BSIS
SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
FROM bsis
INTO CORRESPONDING FIELDS OF TABLE <fs_dyntable>
WHERE bukrs = p_bukrs
AND hkont IN s_hkont
AND budat <= p_asof.
*get records from BSAS
SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
FROM bsas
APPENDING CORRESPONDING FIELDS OF TABLE <fs_dyntable>
WHERE bukrs = p_bukrs
AND hkont IN s_hkont
AND budat <= p_asof
AND augdt > p_asof.
ENDMETHOD.
START-OF-SELECTION.
DATA: main TYPE REF TO lcl_main.
CREATE OBJECT main.
CALL METHOD main->build_table.
CALL METHOD main->get_data.
Need help on this problem. Thanks a lot guys and take care!Hi guys,
I found out the problem and Andreas is right. Now, I am having problems when including DMBTR, WRBTR in my select statement. All the others are ok. Here is my modified code. Please suggest what I need to add/modify. Thanks a lot!
CLASS lcl_main IMPLEMENTATION.
METHOD build_table
METHOD build_table.
DATA: lv_from TYPE bsis-gjahr,
lv_asof TYPE bsis-gjahr,
lv_check TYPE i,
lt_data TYPE REF TO data,
lt TYPE lvc_t_fcat.
FIELD-SYMBOLS: <fs_year> TYPE gjahr.
ASSIGN lv_asof TO <fs_year>.
lv_from = p_year.
lv_asof = p_asof+0(4).
v_counter = lv_asof - lv_from.
ZUONR
wa_ddfields-fieldname = 'ZUONR'.
wa_ddfields-position = '0001'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000018'.
wa_ddfields-decimals = '00000'.
APPEND wa_ddfields TO it_ddfields.
GJAHR
wa_ddfields-fieldname = 'GJAHR'.
wa_ddfields-position = '0002'.
wa_ddfields-datatype = 'NUMC'.
wa_ddfields-leng = '000004'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
BELNR
wa_ddfields-fieldname = 'BELNR'.
wa_ddfields-position = '0003'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
BLDAT
wa_ddfields-fieldname = 'BLDAT'.
wa_ddfields-position = '0004'.
wa_ddfields-datatype = 'DATS'.
wa_ddfields-leng = '00008'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
WAERS
wa_ddfields-fieldname = 'WAERS'.
wa_ddfields-position = '0005'.
wa_ddfields-datatype = 'CUKY'.
wa_ddfields-leng = '000005'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
BLART
wa_ddfields-fieldname = 'BLART'.
wa_ddfields-position = '0006'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000002'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
DMBTR
wa_ddfields-fieldname = 'DMBTR'.
wa_ddfields-position = '0007'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000013'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
WRBTR
wa_ddfields-fieldname = 'WRBTR'.
wa_ddfields-position = '0008'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000013'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
HKONT
wa_ddfields-fieldname = 'HKONT'.
wa_ddfields-position = '0009'.
wa_ddfields-datatype = 'CHAR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
AMOUNT
wa_ddfields-fieldname = 'AMOUNT'.
wa_ddfields-position = '0010'.
wa_ddfields-datatype = 'CURR'.
wa_ddfields-leng = '000010'.
wa_ddfields-decimals = '000002'.
APPEND wa_ddfields TO it_ddfields.
DATA: lv_position TYPE i.
lv_position = 0011.
Additional fields for the years
WHILE lv_check < v_counter.
wa_ddfields-fieldname = <fs_year>.
wa_ddfields-position = lv_position.
wa_ddfields-datatype = 'NUMC'.
wa_ddfields-leng = '000004'.
wa_ddfields-decimals = '000000'.
APPEND wa_ddfields TO it_ddfields.
lv_asof = lv_asof - 1.
ADD 1 TO: lv_check, lv_position.
ENDWHILE.
CLEAR lv_position.
lv_position = 1.
LOOP AT it_ddfields INTO wa_ddfields.
CASE wa_ddfields-fieldname.
WHEN 'BLDAT'.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
ls-inttype = 'D'.
ls-ref_table = 'BSIS'.
ls-ref_field = 'BLDAT'.
WHEN 'WAERS'.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
ls-ref_table = 'BSIS'.
ls-ref_field = 'WAERS'.
when 'DMBTR'.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
ls-ref_table = 'BSIS'.
ls-ref_field = 'DMBTR'.
when 'WRBTR'.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
ls-ref_table = 'BSIS'.
ls-ref_field = 'WRBTR'.
WHEN OTHERS.
ls-col_pos = lv_position.
ls-row_pos = lv_position.
ls-fieldname = wa_ddfields-fieldname.
ENDCASE.
APPEND ls TO lt.
ADD 1 TO lv_position.
ENDLOOP.
CLEAR lv_position.
ASSIGN lt_data TO <fs_data>.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table = <fs_data>
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ASSIGN <fs_data>->* TO <fs_1>.
ASSIGN <fs_1> TO <fs_2>.
ASSIGN <fs_1> TO <fs_dyntable>.
ENDMETHOD. -
OWB 10.2 - View doesn't have SELECT statement.
Hi,
We migrated from OWB 10.1 to OWB 10.2. and I got stuck on weird behavior of views.
In 10.1. I had a mapping which ended up in a view. When I performed "reconcile outbound" the view was updated and it's SELECT statement reflected sources and transformations in the mapping.
In 10.2., however, the view's SELECT statement is empty, no matter of using synchronization (a successor to "reconcile" functionality).
I cannot deploy a view which doesn't have a select statement.
Anyone has come across this problem?You need to create a NetInstall image using System Image Utility. You can launch it from the "Tools" menu of Server.app.
To use System Image Utility, you will need an installed volume, or an Install Mac OS X application from the Mac App Store. -
How to use a table name in the select statement using a variable?
Hi Everybody,
I got a internal table which has a field or a variable that gets me some tables names. Now I need to retrieve the data from all these tables in that field dynamically at runtime. So could you suggest me a way out to use the select query which uses this variable as a table ?
Regards,
Mallik.Hi all,
Actually i need some more clarification. How to use the same select statement, if i've to use the tabname in the where clause too?
for ex : select * from (tab_name) where....?
Can we do inner join on such select statements? If so how?
Thanks & Regards,
Mallik. -
How to use column name as variable in select statement
hi,
i want to make a sql query where in select statement using variable as a column name. but its not working plz guide me how can i do this.
select :m1 from table1;
regardsHi,
Is this what you want..
SQL> select &m1 from dept;
Enter value for m1: deptno
old 1: select &m1 from dept
new 1: select deptno from dept
DEPTNO
10
20
30
40
SQL> select &m1 from dept;
Enter value for m1: dname
old 1: select &m1 from dept
new 1: select dname from dept
DNAME
ACCOUNTING
RESEARCH
SALES
OPERATIONS
SQL> select &&m1 from dept;
Enter value for m1: loc
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTON
SQL> select &&m1 from dept;
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTONIf you use single '&' then each time you fire the query, It will ask for the new value..
But if you will use double '&&' the value of m1 will be persistent across the session..
Twinkle -
What is the use of for all entries in select statement
what is the use of for all entries in select statement
hi,
FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
You can check the below code -
SELECT BUKRS BELNR GJAHR AUGDT
FROM BSEG
INTO TABLE I_BSEG
WHERE BUKRS = ....
SELECT BUKRS BELNR BLART BLDAT
FROM BKPF
INTO TABLE I_BKPF
FOR ALL ENTRIES IN I_BSEG
WHERE BUKRS = I_BSEG-BUKRS
AND BELNR = I_BSEG-BELNR
AND BLDAT IN SO_BLDAT.
*******************************8
look another example
what is the use of FOR ALL ENTRIES
1. INNER JOIN
DBTAB1 <----
> DBTAB2
It is used to JOIN two DATABASE tables
having some COMMON fields.
2. Whereas
For All Entries,
DBTAB1 <----
> ITAB1
is not at all related to two DATABASE tables.
It is related to INTERNAL table.
3. If we want to fetch data
from some DBTABLE1
but we want to fetch
for only some records
which are contained in some internal table,
then we use for alll entries.
1. simple example of for all entries.
2. NOTE THAT
In for all entries,
it is NOT necessary to use TWO DBTABLES.
(as against JOIN)
3. use this program (just copy paste)
it will fetch data
from T001
FOR ONLY TWO COMPANIES (as mentioned in itab)
4
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
bukrs LIKE t001-bukrs,
END OF itab.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
itab-bukrs = '1000'.
APPEND itab.
itab-bukrs = '1100'.
APPEND itab.
SELECT * FROM t001
INTO TABLE t001
FOR ALL ENTRIES IN itab
WHERE bukrs = itab-bukrs.
LOOP AT t001.
WRITE :/ t001-bukrs.
ENDLOOP.
Hope this helps!
Regards,
Anver
<i>if hlped pls mark points</i> -
Using variable in from close of select statement for LOV
Hi all,
I had a select list based on a query with a variable in it for the database schema. Something like this:
"select name, id from &SCHEMA..countries order by name". This warked in version 1.4.4..., I don't remember the rest. Now we upgraded to version 1.6.0.00.87 and I am trying to change the condition for this select item but I recieve this error:
1 error has occurred
LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
Whatever I'm trying to change for this item, it always gives me this error when I click on "Apply Changes" button. Everything works fine when I remove &SCHEMA. from the query and instead write directly the database schema name.
Can you help me?Sabiha,
This is a case where the builder cannot parse the query at design time because there is no state for &SCHEMA. in the session. You can try this trick, change the lov query to: if htmldb_application.get_current_flow_sgid(:APP_ID) = htmldb_application.get_sgid then
return 'select name d, id r from &SCHEMA..countries order by name';
end if;Notice also the addition of aliases for the column names.
Scott -
How to use case to replace the & in select statement
Oracle version : 11.1.0.6.0
RHEL
Hi,
I want to get a list of all expired and locked users but want to replace the "&" with and here is my code but it isn't working.
Please some guidance, thanks.
SQL> select username,
2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
3 ELS 'no locked users'
4 end) account_status
5 from dba_users
6 where account_status like 'EXPI%';
case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
ERROR at line 2:
ORA-00907: missing right parenthesis798188 wrote:
thanks for the comments I corrected the ELSE and 'EPX%' but still same error :
EOH> select username,
2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
3 ELSE 'no locked users'
4 end) account_status
5 from dba_users
6 where account_status like 'EXP%';
case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
ERROR at line 2:
ORA-00907: missing right parenthesisFirst of all, you do not need a CASE statement.
Did you see the where clause of your query??
6 where account_status like 'EXP%';do you realise that your query will always return those records for which value of account_status column starts with 'EXP'?
Why use CASE when it could be simply written like this :
SELECT username,
'EXPIRED AND LOCKED'
FROM dba_users
WHERE account_status LIKE 'EXP%' -
Trouble using the "into" keyword in a select statement
I was able to run the below query fine:
SELECT QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
Count(CFQR.RecKey) AS Cnt
FROM [HR_DEV_DM].[CFQ_TEST].CFQ_Referrals as CFQR
INNER JOIN [HR_DEV_DM].[CFQ_TEST].t_Qt_Typs as QTTYP
ON CFQR.QuoteType = QTTYP.Qt_Grp
WHERE (((CFQR.QuoteType) Not In ('AUTO/CYCLE','COMMERCIAL','CYCLE'))
AND ((CFQR.QuoteDate)>=DateAdd("m",-15,CONVERT (date, GETDATE())))
AND ((CFQR.RecCntdAsRefrl)=1))
GROUP BY QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
CFQR.RecChangeID
HAVING (((Count(CFQR.RecKey))>1) AND ((CFQR.RecChangeID) Is Null))
OR (((Count(CFQR.RecKey))>1)
AND ((CFQR.RecChangeID) Not In (1035)))
ORDER BY QTTYP.Qt_Grp, CFQR.RecKey;
I am trying to add the output columns into a temp table. But when I add the "into" statement, as shown below, it gives me errors:
SELECT QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
Count(CFQR.RecKey) AS Cnt
FROM [HR_DEV_DM].[CFQ_TEST].CFQ_Referrals as CFQR
into I_Dup_RecKey_Check_01
INNER JOIN [HR_DEV_DM].[CFQ_TEST].t_Qt_Typs as QTTYP
ON CFQR.QuoteType = QTTYP.Qt_Grp
WHERE (((CFQR.QuoteType) Not In ('AUTO/CYCLE','COMMERCIAL','CYCLE'))
AND ((CFQR.QuoteDate)>=DateAdd("m",-15,CONVERT (date, GETDATE())))
AND ((CFQR.RecCntdAsRefrl)=1))
GROUP BY QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
CFQR.RecChangeID
HAVING (((Count(CFQR.RecKey))>1) AND ((CFQR.RecChangeID) Is Null))
OR (((Count(CFQR.RecKey))>1)
AND ((CFQR.RecChangeID) Not In (1035)))
ORDER BY QTTYP.Qt_Grp, CFQR.RecKey;
Errors:
Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'into'.
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'CFQR'.
Msg 102, Level 15, State 1, Line 18
Incorrect syntax near 'Count'.
Msg 102, Level 15, State 1, Line 19
Incorrect syntax near 'Count'.
Please help.....You have put INTO into the wrong place :
SELECT QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
Count(CFQR.RecKey) AS Cnt
into I_Dup_RecKey_Check_01
FROM CFQ_Referrals as CFQR
INNER JOIN t_Qt_Typs as QTTYP
ON CFQR.QuoteType = QTTYP.Qt_Grp
WHERE (((CFQR.QuoteType) Not In ('AUTO/CYCLE','COMMERCIAL','CYCLE'))
AND ((CFQR.QuoteDate)>=DateAdd("m",-15,CONVERT (date, GETDATE())))
AND ((CFQR.RecCntdAsRefrl)=1))
GROUP BY QTTYP.Qt_Grp,
CFQR.ReferralCode,
CFQR.RecKey,
CFQR.RecChangeID
HAVING (((Count(CFQR.RecKey))>1) AND ((CFQR.RecChangeID) Is Null))
OR (((Count(CFQR.RecKey))>1)
AND ((CFQR.RecChangeID) Not In (1035)))
ORDER BY QTTYP.Qt_Grp, CFQR.RecKey;
Maybe you are looking for
-
Firefox 37 Beta on Windows 8.1 has lag and stuttering when scrolling
I just recently got a new laptop, and since the minute I've installed firefox on it there has been lag when scrolling webpages. It seems to start off not too badly, with there being some stuttering when I first open firefox, however it seems like the
-
My Ipod Classic 160 gb not Recognised on desktop
The Connected icon appears on my ipod ,Synchronizes with my laptop and immediately disconnects . The ipod is still recognized in itunes but doesnt show as a Hard disk on the desktop to transfer files into it. When i try to tranfer songs through itune
-
Arch router / connection share dns lookup works, but no ping [solved]
I lost some config and forgot how to set this up. I have a dual nic arch box with some clients behind it. dnsmasq serves dhcp and dns on the LAN side (192.168.10.0/24). WAN port of arch box (192.168.1.201) talks to actual modem (192.168.1.1). router
-
I don't have many issues I can't figure out. I've been using LR since Beta days... best software since PS. Anyway working on existing job, went to folder in LE 4.4 brought up job. Noticed that TWO of the photos I am needing to work with aren't in
-
I ve heard there is part of HR module needed to be installed
Hello I never dealth with HR. I am pure technical person. I ve heard there is part of HR module needed to be installed and I have to react very quicly. Can you help me please