Name of column in select
Hi, I need to give a name column and work with this name in other column's. It's possible?
i.e.
select (case when shkzg = 'S' then 'MD' else 'D' end) as name, name, name||name, ....
You can NOT use the column alias, the way you intended to use, in SELECT clause, WHERE clause & GROUP BY clause.
But you can use it in ORDER BY clasue
It makes sense when you look at the order of execution of the clauses of the SELECT query.
Hope this helps
Dinesh
Similar Messages
-
How to change the "name of column" property of an text item in runtime?
How to change the "name of column" property of an text item in runtime?
I look the properties of items in help and found nothing about this!
It's possible?Hi,
an other solution is change the block property QUERY_DATA_SOURCE_TYPE from "Table" to "Sub-query" , than change at run time the property QUERY_DATA_SOURCE_NAME.
First create block and add items
The QUERY_DATA_SOURCE_NAME will be for ex. "Select 'A' as col1, 'B' AS col2, 'C' as col3 from dual"
Set into items the column name property to col1 , col2 ...
At run time change the query to "Select 'Z' as col1, 'X' as col2 , 'Y' as col3 from dual"
in this way you can change the source of column value.
Caution because if you change value type from varchar2 to date you must cast date into varchar2.
May be that this way is valid only for view data not for insert-update, i don't remember.
bye
Message was edited by:
Killernero -
How: making column value as column of select statement
Hi
Quickly I have searched in this forum for following solution but not able to find it.
I need to make a query in such a way that the value of one column in one table should act as a column-name of another table
Eg:-
tab1
col1,col2,*col3*,col4
tab2
col11 col22 col33 col44
row1 a b col3 d
row2 aa bb cc dd
So the query should be something like --- in row2 if the value is col3 then from tab1 I should pick the col3 in select statement (basically there will be some join in tab1 and tab2 )
Hope I am able to make u all understand my query.
regardsHi all,
Sorry for late response.Just now I checked all the replies.
Actually I tried in this way.
CREATE OR REPLACE function Proc_caption (in_tan varchar2, in_order in number)
return varchar2
is
d varchar2(100) ;
begin
SELECT col1 into d
from tab1
Where
col2 = in_tanid
AND col3 = 'Y'
AND col4 = in_order ;
return d ;
Exception
WHen No_DATA_FOund then
return 'N' ;
end ;
create or replace procedure proc_generate_view(in_tan varchar2, in_soc varchar2)
is
x varchar2(2000);
v4 varchar2(50) ;
v5 varchar2(50) ;
cnt number ;
begin
v4:= PROC_Caption (in_tan,4) ;
v5:= PROC_Caption (in_tan,5) ;
x := ' Create view v_generate as '
|| ' SELECT a , b, c, d ' ;
if v4 <> 'N' THEN
x := x || ' , ' || PROC_Caption (in_tan,4) || ' as Caption4 ' ;
end if;
if v5 <> 'N' THEN
x := x || ' , ' || PROC_Caption (in_tan,5) || ' as Caption5 ' ;
end if;
x := x || ' FROM tab2 WHERE col1 = ''' || in_socid || ''''
|| ' AND col2 = ''' || in_tan || '''' ;
select count(1) into cnt from USER_OBJECTS where OBJECT_NAME = 'V_GENERATE'
and OBJECT_TYPE = 'VIEW' ;
if cnt > 0 then
EXECUTE IMMEDIATE ' DROP view V_GENERATE' ;
END IF ;
execute immediate x ;
end ;
NOTE:- I have just renamed the table name and column names in order to make it non confedential...
I have created this successfully with actual table name and column names and able to get the result as per my requirement.
regards -
How to compare index names and columns from different user?
I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
WITH t AS
(SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
cnt
FROM ( SELECT index_owner,
index_name,
listagg (column_name, ',')
WITHIN GROUP (ORDER BY column_position)
indexed_cols
FROM dba_ind_columns
WHERE index_name='XPKTBL_A'
GROUP BY index_owner, index_name))
SELECT CASE
WHEN cnt > 1 THEN 'Indexes are different'
WHEN cnt = 0 THEN 'Indexes dont exist'
WHEN cnt > 1 THEN 'Indexes are identical'
END
commnt
FROM t
Result:
Indexes are different
but Actually if you check below they are same After when I run this query:
SELECT index_owner,
index_name,
listagg (column_name, ',') WITHIN GROUP (ORDER BY column_position)
indexed_cols
FROM dba_ind_columns
WHERE index_name='XPKTBL_A'
GROUP BY index_owner, index_name;
Result:
Index_owner
Index_name
Index_cols
USER1
XPKTBL_A
FIELD_A1
USER2
XPKTBL_A
FIELD_A1Hi,
Erhan_toronto wrote:
I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
WITH t AS
(SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
So index_owner is 'USER1' in one case, and 'USER2' in the other; right?
A string that starts with 'USER1' will be distinct from a string that starts with 'USER2', no matter what the rest of the string contains. Maybe you don't want to compare the owners, or maybe you meant to use some other column (such as table_name) instead of index_owner).
I hope this answers your question.
If not, post a little sample data (CREATE TABLE, CREATE INDEX and CONNECT statements), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
In OS X Lion, Finder will not "Arrange By Name" in "Column view".
If I select "Arrange By > Name" in "Column View" in any window, nothing happens. This is a massive inconvenience. I attached an image of a finder window of my applications below, in which the Column view with arrange by Name is configured, but the applications haven't been resorted by name.
It will arrange by name in Icon and List views, but not in Column view. Does anyone know how to solve this? Is it a glitch inherent to OS X Lion that Apple didn't catch?There seem to be a few glitches in the Arrange/sort model.
You can actually Arrange by and Sort By separately. You can get to the Sort options by holding down the Option key while selecting the Arrangement button.
However, there aren't any sort options when you Arrange by Name. And it doesn't change the sort by option when you switch to Arrange by Name.
Try setting the Arrange by to None. Then, hold down the option key and press the Arrange button. What is it sorted by? -
How get values of columns for selected rows in SortingTable
Hi,
is possible to get values of more columns for selected rows? I have SortingTable that have 1st column loaded from list and 2nd and 3rd columns are text areas where user must write some text. I need way how to get values from all three columns for selected rows.
My table looks like this:
System name I User Account I User Password
system1 ...............jblack ............. passw1
system2 ...............pdowe..............p@ssw
system3 ...............ekie................. pas123
Column System name is loaded from list, columns User Account and User Password are Text class. How can I get values for all three columns in case that I select e.g. system1 or system1 & system2?
I read [this post|http://forums.sun.com/thread.jspa?forumID=764&threadID=5220609] but there is described selection only for one column.
Code of my SortingTable is following:
<Field name='tblDalsiSystemy'>
<Display class='SortingTable'>
<Property name='align' value='center'/>
<Property name='sortEnable' value='false'/>
<Property name='selectEnable' value='true'/>
<Property name='pageSize' value='5'/>
<Property name='pageButtonAlign' value='center'/>
<Property name='columns'>
<List>
<String>System name</String>
<String>User Account</String>
<String>User Password</String>
</List>
</Property>
</Display>
<FieldLoop for='y' in='lstSystemList'>
<Field name='SystemName'>
<Display class='SortingTable$Row'>
<Property name='key'>
<ref>lstSystemList</ref>
</Property>
</Display>
<Display class='Label'>
<Property name='align' value='center'/>
<Property name='value'>
<ref>y</ref>
</Property>
</Display>
</Field>
<Field name='UserAccount'>
<Display class='SortingTable$Row'>
</Display>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
<Field name='UserPassword'>
<Display class='SortingTable$Row'>
</Display>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
</FieldLoop>
</Field>Getting value is performed by:
<ref>tblDalsiSystemy.selected</ref>Any help?
Thanks
PetrHi Ivan,
thanks for your advice - it works.
Here is my final code:
<Field name='tblDalsiSystemy'>
<Display class='SortingTable'>
<Property name='align' value='center'/>
<Property name='sortEnable' value='false'/>
<Property name='selectEnable' value='true'/>
<Property name='pageSize' value='5'/>
<Property name='pageButtonAlign' value='center'/>
<Property name='columns'>
<List>
<String>System name</String>
<String>User Account</String>
<String>User Password</String>
</List>
</Property>
</Display>
<FieldLoop for='y' in='lstSystemList'>
<Field name='SystemName'>
<Display class='SortingTable$Row'>
<Property name='key'>
<ref>lstSystemList</ref>
</Property>
</Display>
<Display class='Label'>
<Property name='align' value='center'/>
<Property name='value'>
<ref>y</ref>
</Property>
</Display>
</Field>
<Field name='Account[$(y)].login'>
<Display class='SortingTable$Row'/>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
<Field name='Account[$(y)].passwd'>
<Display class='SortingTable$Row'/>
<Display class='Text'>
<Property name='size' value='10'/>
<Property name='value'>
</Property>
</Display>
</Field>
</FieldLoop>
</Field>Maybe it could be helpful for somebody another :-)
Petr -
Passing table name and columns name as parameters to procedure
i need a procedure that take table name and column names as parameters .
it should display all values in those columns
like
if i execute procedure p ( t1,c1,c2)
it should display c1,c2 values in t1 table
if i execute procedure p ( t1, c1,c2,c3)
it should display c1,c2,c3 values in t1 tables
no of column parameters changesSee if this helps...
First, read the manual on collections.
Second, define your expected results. You want to output the results to the screen? You cannot perform a 'select' in PL/SQL. You will have to select your output into another collection, then loop through that.
Finally, I am curious why this is necessary versus performing a regular query.
Take a look at this incomplete code.
create or replace
package dave_pac
IS
TYPE col_name_list IS VARRAY(20) OF VARCHAR2(30);
PROCEDURE SFA_TAB_COL1
(p_tname IN VARCHAR2
,p_cnames IN col_name_list);
END;
create or replace
package body dave_pac
IS
PROCEDURE SFA_TAB_COL1
(P_tname IN varchar2
,p_cnames in col_name_list)
IS
l_stmt long;
l_rc number;
begin
l_stmt :='select '||p_cnames(1);
for i in 2..p_cnames.count
loop
l_stmt :=l_stmt||' , '||p_cnames(i);
end loop;
l_stmt:= l_stmt||' from '|| p_tname ;
execute immediate l_stmt;
end ;
END dave_pac; -
Names of column appearing in alv output after changing layout in alvgrid?
Hi all
I have a requirement where I am displaying 20 fields using alv grid(cl_gui_alv_grid). Now each time when I run I can change layout and can display any number of columns in output using change layout option.
My requirement is i need to know the column names of the fields which are displayed upon changing layout in output. Using this column names I have to write some logic in code. Each time number of column may vary as per the user selection. Is there any method or way to get the names of columns selected in output display?
Please help me in this regard.Hi,
During run time you will get the ALV layout info using this function module.
REUSE_ALV_GRID_LAYOUT_INFO_GET
Regards,
Anversha -
Can I refer name of column to function oblicz pasted below?
How can I do this?
nazwa - name of column from table pracownicy witch some float variables
PS:thanks 4 every help.
Greets Mike.
------begin function-----
create or replace function oblicz (nazwa varchar)
return number
is
l number(2);
begin
select avg('nazwa') <----- in here!
into l
from pracownicy;
return l;
end;
--------end function--------
Message was edited by:
axis_81Aren't the two exactly the same? No:
declare
l number(2);
begin
execute immediate 'select avg(empno) into :1 from emp' using l;
end;
Error at line 2
ORA-01745: invalid host/bind variable name
ORA-06512: at line 4
or
declare
l number(2);
begin
execute immediate 'select avg(empno) into :l from emp' using l;
end;
Error at line 2
ORA-01006: bind variable does not exist
ORA-06512: at line 4 -
Dict View name and column names
Hi,
Oracle 11.2.0.1
Windows XP
I wish to get the output of all the dictionary views with their name and column names something like this :
VIEW NAME
Name Null? Type
VIEW NAME
Name Null? Type
...Please tell me how do I get the above output for all the dict view from dict table.
Thanks.Step 1:
set serveroutput on;
set feed off;
set head off;
set pages 200;
spool dict.sql;
declare
tn varchar2(50);
cursor c is select table_name from dict order by table_name;
begin
open c;
loop
fetch c into tn;
dbms_output.put_line('begin');
dbms_output.put_line('dbms_output.put_line(' ||chr(39) || tn ||chr(39) ||');');
dbms_output.put_line('end;');
dbms_output.put_line('/');
dbms_output.put_line('desc ' || tn || ';');
exit when c%NOTFOUND;
end loop;
close c;
end;
Step 2:
Just edit dict.sql to remove top and bottom lines.
spool dictcols.txt
@dict.sql;
spool off;
But, this is not a good way to obtain your desired output. I am sure, other members can do it very smartly and efficiently.
Regards
Girish Sharma -
Putting a check box above column for selection in WD ALV
Hi,
Can anyone provide me a code snippet and help me how I can
provide a check box above column for selection in WD ALV.
Best Regards
SidHi Sid,
As far as I know we cannot put checkboxes directly above the Column headers.
You can achieve this functionality in a round above method
You can create a group of checkboxes above your ALV table with names of columns to be selected beside each check box and proceed with your further processing.
Also If you are just looking at which columns you need to select to be shown on the
ALV output
data: lr_standard_functions type ref to if_salv_wd_std_functions.
lr_standard_functions ?= wd_this->r_table.
lr_standard_functions->set_column_selection_allowed( ' ' ).
Hope this is of some help.
Regards,
Ismail.
Edited by: Ismail Basha on Jan 23, 2008 1:47 PM
Edited by: Ismail Basha on Jan 24, 2008 3:23 AM -
Update a column on select every row trigger?
I have a column in a table which is populated using random
number generator via an insert trigger. Is there a trigger call
I can make so that we may update this column ON FETCH/SELECT
with a new random number. Ideally will like to use a database
trigger to do this??? This is a wierd thing I need to do more
business related than anything else. Thanks.No triggers on selects, but you don't need to.
Create a view with SELECT7DBMS_RANDOM.RANDOM FROM7DUAL.
See below, blanks replced with middle dots for alignment777
I wasn't sure it would work so I tried it ( and I always wanted
to name a column "quazi")!
7SQL>7CREATE7OR7REPLACE7VIEW7station_random
777277AS
777377SELECT7location_number7777
77747777777,7call
77757777777,7name_location
77767777777,7country_state
77777777777,7previous_name_flg
77787777777,7lat
77797777777,7lat_flg
77107777777,7lon
77117777777,7lon_flg
77127777777,7elev
77137777777,7quazi
7714777FROM7worldwide_station_list
7715777777,7(7SELECT7DBMS_RANDOM.RANDOM7AS7quazi
7716777777777777FROM7DUAL
771777777777)
7718777777;
View7created.
7SQL>7select7*7from7station_random7where7rownum7<76;7
LOCATI7CALL77NAME_LOCATION7777777CO7P7777777777777LAT7L7777777777
777LON7L777777777777ELEV77777777777QUAZI
------7-----7-------------------7--7-7---------------7-7---------
------7-7---------------7---------------
3258307'77777PETROPAVLOVSKKAMCAT7'77N7777777777752.597N7777777777
158.397E77777777777777247777771629503002
8900407'77777SANAE7AWS77777777777'77N7777777777771.427S7777777777
772.487W777777777777781777777-1215566745
8950407'77777TROLL777777777777777'77N77777777777777727S7777777777
772.327E7777777777771290777777-964057571
9965607DB6567ENVIRONM7BUOY7230517'77N7777777777723.427N7777777777
7758.37E7'7777777777777777777-1438450404
9966507DB6657ENVIRONM7BUOY7230527'77N7777777777722.367N7777777777
7759.37E7'777777777777777777777404164777
Elapsed:700:00:00.01
7SQL>7r
771*7select7*7from7station_random7where7rownum7<76
LOCATI7CALL77NAME_LOCATION7777777CO7P7777777777777LAT7L7777777777
777LON7L777777777777ELEV77777777777QUAZI
------7-----7-------------------7--7-7---------------7-7---------
------7-7---------------7---------------
3258307'77777PETROPAVLOVSKKAMCAT7'77N7777777777752.597N7777777777
158.397E777777777777772477777-1470640679
8900407'77777SANAE7AWS77777777777'77N7777777777771.427S7777777777
772.487W77777777777778177777777-17578400
8950407'77777TROLL777777777777777'77N77777777777777727S7777777777
772.327E77777777777712907777777-26724017
9965607DB6567ENVIRONM7BUOY7230517'77N7777777777723.427N7777777777
7758.37E7'7777777777777777777-1870972567
9966507DB6657ENVIRONM7BUOY7230527'77N7777777777722.367N7777777777
7759.37E7'777777777777777777771035733761
Elapsed:700:00:00.01
Good Luck... -
Need a Query that Returns both Column Name with Column Data
Hi,
Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
Table: APP_INFO
COL1 - currently has the value of 10
COL2 - currently has the value of 'HELLO'
COL3 - currently has the value of 'QWERTY'
COL4 - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
COL1,10
COL2,'HELLO',
COL3,'QWERTY'
COL4,2000
Any help would be much appreciated.
Thanks.
Tony.Like this ?
SQL> select empno, ename, deptno from emp where deptno = 10;
EMPNO ENAME DEPTNO
7782 CLARK 10
7839 KING 10
7934 MILLER 10
SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
2 decode(t.id,1,to_char(empno),2,ename,3,deptno)
3 from (select emp.*, rownum rn from emp
4 where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
5 order by emp.rn, t.id
6 /
COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
EMPNO 7782
ENAME CLARK
DEPTNO 10
EMPNO 7839
ENAME KING
DEPTNO 10
EMPNO 7934
ENAME MILLER
DEPTNO 10
9 rows selected.Rgds. -
I have copied many photo's from another laptop to my Mac. The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder but my new photo's are all in iPhoto. I want to use directories for storing and iPhoto for viewing. Is this possible or do I need to have all my photo's in iPhoto??
MitchiPhoto is not a Photo Viewer. It's a Photo Manager and designed for looking after the files while you organise the Photos. It really works much better if you let it manage those files. If you use iPhoto you never go near those files because iPhoto is your start point for anything you want to do with your Photos - the point of the pplication.
You can run iPhoto in Referenced mode, where it does not copy the files to the Library, but I caution you that you are making life a lot more difficult for yourself by doing that.
How to, and some comments on why you shouldn't, are in this thread
https://discussions.apple.com/thread/3062728?tstart=0
Regards
TD -
I am using SSIS to extract fixed width data into a flat file destination and I keep getting below error. I have tried almost everything in this forum but still no solution. can anyone help me out to solve this problem.
[Flat File Destination [220]] Error: Failed to write out column name for column "Column 2".
[SSIS.Pipeline] Error: component "Flat File Destination" (220) failed the pre-execute phase and returned error code 0xC0202095
ThanksHi Giss68,
Could you check the Advanced tab of the Flat File Connection Manager to see whether the InputColumnWidth and the OutputColumnWidth properties of the Column2 has the same value? Please refer to the following link about the same topic:
http://stackoverflow.com/questions/10292091/how-do-i-fix-failed-to-write-error-while-exporting-data-to-ragged-right-flat-fil
If it doesn’t work, please post the sample data and the advanced settings of Column2 for further analysis.
Regards,
Mike Yin
If you have any feedback on our support, please click
here
Mike Yin
TechNet Community Support
Maybe you are looking for
-
How to load new planning application in EPM 11.1.1.2-DIM ESSBASE ADAPTER
how to load new planning application in EPM 11.1.1.2-DIM ESSBASE ADAPTER
-
I am looking to get a mac ever since I heard about Windows 8 in the fall. I need multi track recording hardware and software, I need video capture and editing, and i would like multi displays. Where do I start?
-
Turned on my IPOD and all songs & Data are gone
I didn't back up any of the CDs that I own, but is there any way to recover all my lost songs without re-loading them back onto Itunes? I didn't want to keep a huge library on my computer (because it didn't have enough memory left) but I never though
-
HCM changes to be passed to different vendors.. how to?
Hi guys, This is a HCM technical question... WE have the current implementation where we are implementing the benefits HCM sub module. The requirement is. we want to send across the benefits / family (0021 IT) information to other vendors when there
-
Currency key for Conversions using NODIM
Hello Experts, I have question related to Currency key. I have below mentioned scenario - My Report output looks something like this Doc No|Doc Value| 500 |USD | so KF value and currency key(USD) are in seperate fields(column in Bex Report) I seperat