Display column value as column name
Hi,
I have a requirement to display column names as column values and vice versa. Pls suggest how to do this.
Test data
create table oratest as select 'saurabh' "name",23 "age" from dual;
SQL> select * from oratest;
name age
saurabh 23Expected output
saurabh 23
name age
Ok, I've only got 10g here at the minute, so this is what I'd do...
SQL> ed
Wrote file afiedt.buf
1 DECLARE
2 v_v_val VARCHAR2(4000);
3 v_n_val NUMBER;
4 v_d_val DATE;
5 v_ret NUMBER;
6 c NUMBER;
7 d NUMBER;
8 col_cnt INTEGER;
9 f BOOLEAN;
10 rec_tab DBMS_SQL.DESC_TAB;
11 col_num NUMBER;
12 v_rowcount NUMBER := 0;
13 v_name VARCHAR2(20);
14 v_age NUMBER;
15 v_sql VARCHAR2(4000);
16 v_str VARCHAR2(250);
17 v_und VARCHAR2(250);
18 BEGIN
19 select "name", "age"
20 into v_name, v_age
21 from oratest;
22 v_sql := 'SELECT ''name'' as "'||v_name||'", ''age'' as "'||v_age||'" from dual';
23 c := DBMS_SQL.OPEN_CURSOR;
24 DBMS_SQL.PARSE(c, v_sql, DBMS_SQL.NATIVE);
25 d := DBMS_SQL.EXECUTE(c);
26 DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
27 --
28 -- Bind local return variables to the various columns based on their types
29 FOR j in 1..col_cnt
30 LOOP
31 CASE rec_tab(j).col_type
32 WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
33 WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); -- Number
34 WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); -- Date
35 ELSE
36 DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Any other type return as varchar2
37 END CASE;
38 END LOOP;
39 -- Display the header
40 FOR j in 1..col_cnt
41 LOOP
42 v_str := v_str || rpad(rec_tab(j).col_name,30,' ')||' ';
43 v_und := v_und || rpad('-',30,'-')||' ';
44 END LOOP;
45 v_str := rtrim(v_str);
46 v_und := rtrim(v_und);
47 DBMS_OUTPUT.PUT_LINE(v_str);
48 DBMS_OUTPUT.PUT_LINE(v_und);
49 --
50 -- This part outputs the DATA
51 v_str := '';
52 LOOP
53 v_ret := DBMS_SQL.FETCH_ROWS(c);
54 EXIT WHEN v_ret = 0;
55 v_rowcount := v_rowcount + 1;
56 FOR j in 1..col_cnt
57 LOOP
58 CASE rec_tab(j).col_type
59 WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
60 v_str := v_str||rpad(v_v_val,30,' ')||' ';
61 WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
62 v_str := v_str||lpad(to_char(v_n_val,'fm999999999999'),30,' ')||' ';
63 WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
64 v_str := v_str||rpad(to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),30,' ')||' ';
65 ELSE
66 DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
67 v_str := v_str||rpad(v_v_val,30,' ')||' ';
68 END CASE;
69 END LOOP;
70 v_str := rtrim(v_str);
71 dbms_output.put_line(v_str);
72 END LOOP;
73 DBMS_SQL.CLOSE_CURSOR(c);
74* END;
SQL> /
saurabh 23
name age
PL/SQL procedure successfully completed.
SQL>Now, with 11g you can actuall create the DBMS_SQL cursor from the top part of the code...
18 BEGIN
19 select "name", "age"
20 into v_name, v_age
21 from oratest;
22 v_sql := 'SELECT ''name'' as "'||v_name||'", ''age'' as "'||v_age||'" from dual';
23 c := DBMS_SQL.OPEN_CURSOR;
24 DBMS_SQL.PARSE(c, v_sql, DBMS_SQL.NATIVE);And using the new function in 11g's DBMS_SQL package called dbms_sql.to_refcursor and convert the DBMS_SQL cursor to a REF CURSOR which you can then use in your applications (if that's the way you need to go)...
http://www.oracle.com/technology/oramag/oracle/07-nov/o67asktom.html
Whatever route you take though, you won't do this simply in SQL as the column names of a query are required to be known before any data is retrieved when a query (cursor) executes. You can see that when you use the DBMS_SQL package, where the query has to be parsed and the column names and descriptions are determined before any fetching of data.
Similar Messages
-
HOWTO: use table column value as tag name in XMLElement (9iR2)
Hi,
maybe what I'm trying to do simply does not work, but here is my sample:
select XMLElement(DUMMY, DUMMY).getClobVal( ) as SAMPLE
from DUAL;
returns the following XML
<DUMMY>X</DUMMY>
But what I want to get is
<X>X</X>
because "X" is the value of column "DUMMY" for table DUAL
Is there a way to do this in PL/SQL XML-DB in Oracle 9i-R2?
TIA,
StefanDo you mean something like this?
1* select xmlelement(EVALNAME last_name, last_name) from employees
SQL> /
XMLELEMENT(EVALNAMELAST_NAME,LAST_NAME)
<Abel>Abel</Abel>
<Ande>Ande</Ande>
<Atkinson>Atkinson</Atkinson>
<Austin>Austin</Austin>
<Baer>Baer</Baer>
<Baida>Baida</Baida>
<Banda>Banda</Banda>
<Bates>Bates</Bates>
<Bell>Bell</Bell>
<Bernstein>Bernstein</Bernstein>
<Bissot>Bissot</Bissot>
<Bloom>Bloom</Bloom>
<Bull>Bull</Bull>
<Cabrio>Cabrio</Cabrio>
<Cambrault>Cambrault</Cambrault>
<Cambrault>Cambrault</Cambrault>
<Chen>Chen</Chen>
<Chung>Chung</Chung>
<Colmenares>Colmenares</Colmenares>
<Davies>Davies</Davies>
.If you do then you're gonna have to upgrade to 10.2.0.2.
In 10.2.0.1 you'll get...
SQL> select xmlelement(EVALNAME last_name, last_name) from employees
2 /
ERROR:
ORA-19039: Keyword EVALNAME reserved for future use
no rows selected
SQL>And earlier versions.... well, you probably won't even get that. -
hi
i am storing different values in a column like(A-RSTI1234/B-RSTUY1234)
using delimiter. now i want to display this stored value in different fields like(xfield=RSTI1234 and yfield=RSTUY1234) can any body help me in achieving this!!
thanks n regards
sunil
e-mail [email protected]How can I achieve this?
The solution should be more general for situation if many tabs are involved,....So do you expect a generalized SQL statement that handles are arbitrary number of tables with arbitrary column names?
It would be helpful if you provided DDL (CREATE TABLE ...) for tables involved.
It would be helpful if you provided DML (INSERT INTO ...) for test data.
It would be helpful if you provided expected/desired results & a detailed explanation how & why the test data gets transformed or organized. -
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 add a column to a list created with the Dynamic List Wizard to display the values of the fiel
Hi,
ADDT, Vista, WAMP5.0
We have 2 tables: clients_cli (id_cli, name_cli, tel_cli, and several more fields) and cases_cas (id_cas, idcli_cas, court_cas, and a lot of other fields).
Clients may have many cases, so table cases_cas have a foreign key named idcli_cas, just to determine which case belongs to which client.
We designed the lists of the two tables with the Dynamic List Wizard and the corresponding forms with Dynamic Form Wizard.
These two forms are linked with the Convert Dynamic List and Form Wizards, which added a button to clients list named "add case".
We add a client and then the system returns to the clients list displaying all clients, we look for the new client just added and then press "add case", which opens the Dynamic Form for cases, enter all case details and everything processes ok.
However, when we view the cases list it display all the details of the case, including the column and values for the foreign key idcli_cas. As you can image, it is quite difficult for a human to remember the clients ids.
So, in the cases list we added a another column, named it Name, to display the names of the clients along with cases details. We also created another recordset rsCli, selected the clients_cli table, displaying all columns, set filter id_cli = Form Variable = idcli_cas then press the Test button and everything displays perfect. Press ok.
Then, we position the cursor inside the corresponding cell of the new Name column, go to Bindings, click on name_cli and then click on insert. The dynamic field is inserted into the table cell as expected, Save the page, and test in browser.
The browser call the cases list but fails to display the values of the Name column. The Name column is simply empty.
This issue creates a huge problem that makes our application too difficult to use.
What are we doing wrong?
Please help.
Charles1. Start transaction PM01, Create Infotype, by entering the transaction code.
You access the Create Infotype screen.
2. Choose List Screen.
3. In the Infotype no. field, enter the four-digit number of the infotype you want to create.
When you specify the infotype number, please remember to enter any leading zeros.
4. In the Screen Number field, enter the screen number of the list screen you want to enhance.
5. Choose Create.
The Dictionary: Initial screen appears:
6. Create the list screen structure.
7. Choose Activate.
8. Return to the Enhance List Screen in the Enhance Infotypes transaction (PM01).
9. Choose Create All.
The additional fields are displayed on the list screen, however, they contain no data.
The fields can be filled in the FORM routine FILL-LISTSTRUCT in the generated program ZPnnnn00. The FORM routine is called for each data record in the list.
Structure ZPLIS is identified when it is generated with a TABLES statement in the program ZPnnnn00.
The fields can be filled from the Pnnnn structure or by reading text tables. -
Clicking add button to display the values
requrement is like this
Could anyone give suggestions with some code .
we have lovs using this one we are searching for the value(ex emloyee name) that value is returned to the base page filed like message text input . we have add button, when ever we click that button to display the value(ex employee name ,desigantion this is from another table )on that same page.I could not understand your requirement. Post more details of the requirement with specific details.
Message was edited by:
Srini -
My spreadsheet looks like this:
Monday Tuesday Wednesday
Name 1 OFF 4:30 PM 4:30 PM
Name 2 5 PM OFF 4:30 PM
Name 3 4:30 PM 5 PM OFF
Name 4 4 PM OFF OFF
I would like to create a spreadsheet for each day that will display the values sorted by time, as follows (e.g. Monday):
Name In Time
Name 4 4 PM
Name 3 4:30 PM
Name 2 5 PM
Any help would be greatly appreciated. Thanks!Here's an example, using the provided data:
I've set the alignment on Main to Automatic (except for row 1) to distinguish between numeric and quasi numeric values (aligned right) and text (aligned left). This is a visual aid to developing the table, and would likely be changed for appearance in the end version.
Columns E, F and G of Main are index columns listing the RANK of numeric/date and time values in columns A, B and C respectively. Text values cause RANK to throw an error, which is caught by IFERROR, which returns a value of 999, chosen to be well above any of the RANK values returned. A small amount ( ROW()/100000 ) is added to each result to prevent duplicate results is cases like column D, where duplicate times appear.
Formula: Main::E2: =IFERROR(RANK(B2,B,1),999)+ROW()/100000
Fill down the column, and right to column G.
These columns may be hidden.
The three daily columns use a single formula each, revised to match the index columns from which they determine the row containing each piece of data to be copied, and to match the columns from which they retrieve that data. The formulas from row 2 of these tables are listed here in the order (left to right) that they are used in the second row of tables above. Parts that are edited from one formula to another are shown in bold.
=IF(SMALL(Main :: $E,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$E,ROW()-1),Main :: $E,0)-1,0))
=IF(SMALL(Main :: $E,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$E,ROW()-1),Main :: $E,0)-1,1))
=IF(SMALL(Main :: $F,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$F,ROW()-1),Main :: $F,0)-1,0))
=IF(SMALL(Main :: $F,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$F,ROW()-1),Main :: $F,0)-1,2))
=IF(SMALL(Main :: $G,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$G,ROW()-1),Main :: $G,0)-1,0))
=IF(SMALL(Main :: $G,ROW()-1)>999,"",OFFSET(Main :: $A$1,MATCH(SMALL(Main::$G,ROW()-1),Main :: $G,0)-1,3))
Each of the formulas is filled down its column.
Each of the functions used is described in the iWork Formulas and Functions User Guide, a useful resource to have on hand when you are writing (or attempting to 'decode') Numbers formulas, The guide (and the Numbers '09 User Guide) may be downloaded from the Help menu in Numbers '09.
Regards,
Barry -
My spreadsheet looks like this:
Monday...
Name 1 4PM
Name 2 4PM
Name 3 5PM
Name 4 5PM
Name 5 4PM
I would like to create a spreadsheet that will display the values as follows:
Openers (4PM) Closers (5PM)
Name 1 Name 3
Name 2 Name 4
Name 5
Any help would be greatly appreciated. Thanks!Hi Shawn,
I think this will do it for you:
There's an auxiliary column in your data entry table. It counts the entries for each distinct time.
The formula in the auxiliary column's body rows is:
=COUNTIF(OFFSET(B$1, 0,0,ROW()), B)&"--"&B
The formula in the Summary table's body rows is:
=IFERROR(OFFSET(Schedule::$A$1, MATCH(ROW()-1&"--"&A$1, Schedule :: $C, 0)-1, 0), "")
Regards,
Jerry -
How to fetch the junk values of a column and the column name in oracle
Hello,
Can anyone help me in writing a procedure/dynamic SQL to fetch the column where the junk values appears and its value. Eg: If emp table contains ID and Name columns, and ID column contains junk values, the result should be the Id column and the junk value/s. It should be dynamic because next time if the other column contains junk values(like $,%...), the query should display the other column too..
Thanks in advance..Try this, I'm not sure if it'll help... and get some idea...
try to modify it as per your requirement -
select * from junk_vals;
1 ranit1
2# ranit2
3 ranit3
4$ ranit@4
5 ranit5
6 r^anit6
select 'ID', id, val from junk_vals
where regexp_like(id,'[^a-zA-Z0-9]')
UNION
select 'VALUE', id, val from junk_vals
where regexp_like(val,'[^a-zA-Z0-9]');
-- "Output :"
ID 2# ranit2
ID 4$ ranit@4
VALUE 4$ ranit@4
VALUE 6 r^anit6
NOTE - I've considered anything other than Alphabets and Numbers as a Junk Value
Edited by: ranit B on Jan 4, 2013 5:07 PM
-- o/p added -
Problem in displaying row vale as column name
Hello Experts,
Please help me,its very urgent....
i want to dispaly a column value as a column name.
i have two column into selete statement and i want to dispaly one column value as a column name and other column value as a single row.
My query is :
SELECT MAX(DECODE (NAME,'virtualDeviceId',VALUE))vdid ,
MAX(DECODE (NAME,'virtualDeviceType',VALUE)) vdevtype,
MAX(DECODE (NAME,'domainName',VALUE)) vdevtype1,
MAX(DECODE (NAME,'sCTPPortSip',VALUE)) vdevtype2,
MAX(DECODE (NAME,'signallingIpAddress',VALUE)) vdevtype,
MAX(DECODE (NAME,'signallingNetworkMask',VALUE)) vdevtype,
MAX(DECODE (NAME,'uDPPort',VALUE)) vdevtype,
MAX(DECODE (NAME,'uDPPortEnum',VALUE)) vdevtype,
MAX(DECODE (NAME,'sCTPPort',VALUE)) vdevtype,
MAX(DECODE (NAME,'sCTPPortM3UA',VALUE)) vdevtype FROM(
SELECT extractvalue(VALUE(l),'/S109:trafficParameters/S109:name'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') NAME,
extractvalue(VALUE(l),'/S109:trafficParameters/S109:value'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') VALUE
FROM INTERFACE_MESSAGE_DESTINATION imd ,TABLE(xmlsequence(EXTRACT(XMLTYPE(imd.remote_request),'/activateConnection_Payload/jobBody/subnetworkConnection/S109:aEndTerminationPoint/S109:managedElement/S109:physicalTerminationPoint/S109:connectionTerminationPoint/S109:trafficDescriptor/*'
, 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"'))) l
WHERE message_id ='NIAS/0000041608') GROUP BY VALUE ;
output is :
Col1 Col2 col3 col4 col5 col
1.'1001105' '1001105'
2. 'MGC'
3.'value' 'value' 'value'
output display : MGC in Col2 and in row 2, 'values' are in col4 and col5 and in row 3.
I want all values in a single row.
Please help me
Surender RanaIt is ugly to force multiple rows into a single row. But it can be done and can be done dynamically as the following approach shows.
SQL> create or replace type TStrings as table of varchar2(4000);
2 /
Type created.
SQL>
SQL> create or replace function ForceColumns( cur SYS_REFCURSOR ) return TStrings is
2 setCols TStrings;
3 setResults TSTrings;
4 begin
5 setResults := new TStrings();
6 loop
7 fetch cur into setCols;
8 exit when cur%NOTFOUND;
9
10 if setCols.Count > 0 then
11 setResults.Extend( setCols.Count );
12 for i in 1..setCols.Count
13 loop
14 setResults( setResults.Count-i+1 ) := setCols(i);
15 end loop;
16 end if;
17 end loop;
18
19 return(setResults);
20 end;
21 /
Function created.
SQL>
SQL> select
2 ForceColumns(
3 CURSOR(
4 select TStrings(object_id,object_name,object_type) from user_objects where rownum <= 5
5 )
6 ) as RESULT_SET
7 from dual
8 /
RESULT_SET
TSTRINGS('TABLE', 'A', '70998',
'PROCEDURE', 'ABC', '54360',
'TABLE', 'ANIMALS', '84829',
'TABLE', 'B', '69604',
'PROCEDURE', 'BUILDNAMEMAP', '70155')
SQL>Note that as the row can contain any number of columns, it needs to be dynamic. This approach uses a collection type called TStrings to achieve this. -
How to display item when mouse moves over Column value??
Hi there
It would be helpful if you could resolve the following :
i) I need to display the column 'A' values of my report in a Text field when mouse moves over column B of my report.
ii) I can able to display the same column value when mouse moves over or onclick happens. but my requirement is something like i have to display the other column value when mouse moves over.
iii) Also i noticed that, i can able to display the item only on "Display only Item" and not on Text field.
Any pointers to display my column value in Text field when onclick happens on my report column?
iv) One more thing that i noticed, i can able to perform onclick or mouse over only on Editable column and not on
non editable columns.
Any pointers on how to achieve the same when mouse moves over Non editable column of report?
Reference: I have created a dummy application (refer the following link), where i can able to display column value Salary on display only item using mouse move Event.
My requirement: when i click column Ename , the text field should show salary.
http://apex.oracle.com/pls/otn/f?p=56045:1
User:guest
Pswd: apex_demo
Any pointers on this would be appreciated.
Thanks
VijayVijay,
If you use Jquery then this should do the trick.
$(document).ready(function() {
$(".t20Report t20Standard tr").hover(function() {
$("#P2_SALARY").attr("innerHTML",$(this).find("td:last input").attr("value"));
{code}
after looking at the source of your page it seems that your class for your report region is *class="t20Report t20Standard"* I am not 100% sure but you might have to correct that in the template. I am not sure how the selector will handle the space in the class name.
Hope this helps,
Tyson -
Hey,
I am trying to only display a column value one time for a record, not a static value. The value changes and there can be many values. I do not think grouping will work since the Date value is dynamic. I am using Oracle for Toad 10.5. There are 4 records with this test data.
select Date, Person, Language, Country
from TableA
TableA
Date Person Language Country
01/25/2013 James English
12/20/2012 James English
US
AFWould like to only display
Date Person Language Country
01/25/2013 James English
12/20/2012
US
AFThanks for reading this thread!
Edited by: Nikki on Jan 7, 2013 1:08 PMHi,
You can use the analytic ROW_NUMBER function to see if a given row is the 1st row in a group, and only display the person and language columns when it is:
WITH got_r_num AS
SELECT dt -- DATE is not a good column name
, person, language, country
, ROW_NUMBER () OVER ( PARTITION BY person
, language
ORDER BY dt
) AS r_num
FROM table_x
SELECT dt
, CASE WHEN r_num = 1 THEN person END) AS person
, CASE WHEN r_num = 1 THEN language END) AS language
, country
FROM got_r_num
ORDER BY person, language, dt -- If wanted
;Your front end may also have a way to hide those values when you want. The BREAK feature in SQL*Plus does this; I don't know if Toad has anything comparable.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) where the query above produces the wrong results, and also post the right 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 {message:id=9360002} -
I want to display one column values with multiple symbols
i am created one report.
my column name is offshore & on shore i want display 3 values with % symbol, then i want show 4 th value as $ 2000,
but it was allowing only one format $ or % but i need to display symbols with my values.Try the following :
give a name to the following formula like @getvalue
Numbervar x;
if
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("ANI"), CurrentSummaryIndex) = 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Offshore Other"), CurrentSummaryIndex) = 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Syntel"), CurrentSummaryIndex)= 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Employee"), CurrentSummaryIndex) = 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Contractor"), CurrentSummaryIndex) = 0 and
//(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Mgt consult"), CurrentSummaryIndex) = 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Clerical"), CurrentSummaryIndex) = 0 and
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Other"), CurrentSummaryIndex) = 0
then
x:=0
else
x:=(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("ANI"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Offshore Other"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Syntel"), CurrentSummaryIndex))
(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("ANI"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Offshore Other"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Syntel"), CurrentSummaryIndex)+
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Employee"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Contractor"), CurrentSummaryIndex) +
//GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Mgt consult"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Clerical"), CurrentSummaryIndex) +
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("Other"), CurrentSummaryIndex)
) * 100
Now create a new formula and check the value of the above formula :
if {@getvalue} > 50 Then
"$"&{@getvalue}
else
{@getvalue}&"%"
Hope this will resove the issue.
Thanks,
Sastry -
Display More then one column in to POP LIST OF VALUE Item
Dear All,
i want to display More then one column in to POP LIST OF VALUE Item like POINTNO,CITY_NAME,REGION_NAME,POSTEL_CODE .
How can i display these 5 Column in to POP UP LIST OF VALUE Item.
Thanks
VedantHi,
Here is my example how to get the address data from address book:
on page, where is the IR report with many columns (as a popup page) there is a Column Link of URL type - you can choose any colulmn .
In the URL address type: javascript:passBack('#ID#', '#NAME#', '#SURENAME#', '#COMPANY#', '#STREET#', '#CITY#', '#POSTAL_CODE#', '#STATE#' );self.close();
self.close function close the popup after fetch.
It will call a passBack function declared in page header.
Example:
<script language = "JavaScript">
function passBack(v_addr_id, v_name, v_suren, v_comp, v_street, v_city, v_postal_code, v_state) {
opener.document.getElementById('P2_ADDRESS_ID').value = v_addr_id;
opener.document.getElementById('P2_ADR_NAME').value = v_name;
opener.document.getElementById('P2_ADR_SURENAME').value = v_suren;
opener.document.getElementById('P2_ADR_COMPANY').value = v_comp;
opener.document.getElementById('P2_ADR_STREET').value = v_street;
opener.document.getElementById('P2_ADR_CITY').value = v_city;
opener.document.getElementById('P2_ADR_POSTAL_CODE').value = v_postal_code;
opener.document.getElementById('P2_ADR_STATE').value = v_state;
</script>
If you want set only one value, just make a similar function with only one parameter.
I hope it will help to you
J -
Displaying the values from a single column into two columns???
hi buddies.....I've a table "Stock" and its fields are:
Date, Invoice#, prod_id, sal_qty, pur_qty, rate, status
The "rate" column stores the rate value on which a product was sold or purchased and "status" column values are like "S" for Sale,"OP" for opening and "P" for purchase.
The problem here to me is that I'm unable to pick the purchase & sale rate of a product based on the status either "S" or "P". Is it possible to pick the purchase rate of a product sold between a specified limit of dates??? and show both sale & purchase rates in two separate columns in the result sets for a given product in a specified duration. The resulte set format should be like this:
Prod_id Sale_Rate Pur_RateDear Dmitri,
Let me tell u my case more elaborately so that u can have a better insight on my problem. I've a Stock table to which I'm trying to use to calculate current stock quantity, its value and profit per sale transaction. It has following simple description.
Stock_Table:
Invoice# Date Product Batch# Sale_QTY Pur_QTY Rate Status
Pur-001 01/01/05 Asprin AB123 0 100 10 OP --(Opening)
Pur-002 02/01/05 Paracetamol CD456 0 150 15 OP
Pur-002 03/01/05 Menthol XY333 0 80 7 OP
Pur-003 01/01/05 Asprin ZZ990 0 50 8 P ..(Purchase)
Sale001 02/01/05 Asprin AB123 10 0 2 S
Sale001 02/01/05 Paracetamol CD456 5 0 16 S ..(Sale)
Sale002 04/01/05 Asprin ZZ990 6 0 10 S
Sale002 04/01/05 Paracetamol CD456 7 0 20 S
Sale002 04/01/05 Menthol XY333 4 0 10 S
From this design can u calulate the difference of sale & purchase rate of a product during a range of dates(which is the Profit)? i.e firstly pick a sale transaction and then minus the purchase rate of the product from the sale rate in that sale transaction by looking at the product name and its batch number.
While solving this case, please keep in mind that I'm using Oracle 8.0 which doesn't support inlined Sub-Query(a query within FROM clause). So giving u a hint(although I'm not genious enough;), I tried the Self Join at Stock Table by picking the sale rows at first and then purchase rows afterwords by giving this table two different names. I also tried the following query by joining the Sale Table with Stock Table. Is it the right way I'm heading towards???
SELECT S.Sale_Date, SD.Invoice#, SD.Product, SD.QTY, SD.Rate Sale_Rate,
ST.Rate Pur_Rate, ST.Product
FROM Invoice_Master S, Invoice_Detail SD, Stock ST
WHERE S.Invoice# = SD.Invoice#
AND ST.Status IN('OP','P')
AND ST.Product = SD.Product
AND S.Sale_Date BETWEEN :From_Date AND :To_Date
AND SD.Product = P.Product
ORDER BY S.Sale_Date
Maybe you are looking for
-
Change name of generated extract structure
Hi, when creating a generic datasource for texts based on a table / view I face the following problem. The abap developments are done using a /xyz/ partner name space, so the table has the name /xyz/mytable created in a package /xyz/mypackage. The sy
-
Confused about this error.
I'm new to Java, and I'm trying to do some work with the Graphics2d library. But whenever I try to run any sample code (like below), I get this weird error: java.lang.NoClassDefFoundError: ShapeExample Exception in thread "main" What's up? It seems t
-
Error in creating despatch advice
Hi all, While creating a despatch advice, system is throwing an error that is "Delivery has not yet been put away / picked (completely) Message no. VL609" Any idea that which configuration has been missed? Please respond. Best Regards, AI.
-
I restored my photos to my new computer from an external HD. I updated to the 5.02. The problem I am having is that PS will not put these photos on screen in the Organizer. The cursor spins. I am using Windows 7, coming from XP. How can I get my pho
-
When I added my photos to my ipod, they were all in order because I put them in numerical order in my photo album. However, about 10 photos were placed in other areas and weren't in order. I tried removing them and doing it again, and the same thing