Using oracle decode function in ssQueryText
Hi,
I am populating the values for ssQueryText, ssSortField etc from the fragment parameters. Then i am using these field values in fragment jsp, put those values in the serverbean and executing the service. I am getting the results, and the results are also sorted the way i want.
The problem is i want to fetch the data from the DB, while fetching i want to check a column value, based on the value i want to temporarily modify that column value and only after modifying i want to sort the data in the table based on the value of modified column.
If some one has tried this earlier please suggest.
Thanks,
Santosh
stmt.executeQuery("select blahblahblah, DECODE(fieldName, password), blahblahblah FROM blahblah...")
Similar Messages
-
Use of DECODE function in Discoverer 3.1
Hi all,
Is there any better way of using DECODE in Discoverer 3.1, i dont want to use that function in my Discoverer User edition or Admin ed.
Many of my queries use the DECODE function.
Your help is greatly appreciated.If you created an instance of your time class that you called myTime
var myTime:Time = new Time(15,15,0);
and later you wanted another instance with the same time you could write
var myTime2:Time = myTime.clone()
It is just there for convienience and doesn't have anything much to do with MVC -
I want to use the following with decode, recently started on BODS.
Can you please provide the steps to use decode function
in source tabke fieldname is ordid and in target fieldname is Orderid
decode(Order_ID = 1709,lpad(Order_ID,7,'700'),Order_ID)
thank you very much for the helpful i1) In the mapping tab of target column, click on Functions, select Miscellaneous Functions category, you can find decode function in it. Lpad can be found in String functions category.
OR
2) You can directly script this or paste this code at the mapping tab. In this case, remove the Order_ID from the script wherever used, drag and drop this column from the input schema of Query transform to avoid the syntax error.
Regards,
Suneer -
Using mysql decode function in Java
Hi everybody,
mysql documentation says:
DECODE(crypt_str,pass_str) -->
Decrypts the encrypted string crypt_str using pass_str as the password. crypt_str should be a string returned from ENCODE().
I used the above function in a Python script and had no problem, but have difficulty using the same thing in my Java code.
I receive runtime error when tried decode() in my Java code in executeQuery("s");. As far as I know the decode() function should be compiled, I can't run the decode() in the mysql command tool and receive a response (as I compiled and ran it in my Python script).
Has anybody ever used this function in the Java code? How? What format did you use? What I should use instead of "s" in this code?
conn is a database connection:
stmt = conn.createStatement();
rs = stmt.executeQuery("s");
I even tried PreparedStatement, but no luck.
Any help is greatly appreciated.stmt.executeQuery("select blahblahblah, DECODE(fieldName, password), blahblahblah FROM blahblah...")
-
How to use oracle TRIM functionality in XML messages
When i am selecting data from XML message as per below query, it is returing values correctly.
SELECT extractValue(x.column_value, '/DETAILS/EMPID') as emp_id,
extractValue(x.column_value, '/DETAILS/NAME') as emp_name,
extractValue(x.column_value, '/DETAILS/SALARY') as emp_sal
FROM TABLE(
XMLSequence(
Extract( xmltype('<DETAILS><EMPID>2482</EMPID><NAME>SMITH</NAME><SALARY>4854</SALARY><LOC>CHENNAI</LOC></DETAILS>'),'/DETAILS'))) x;
But when i am selecting data by using below query some additional spaces also coming with column values
SELECT extractValue(x.column_value, '/DETAILS/EMPID') as emp_id,
extractValue(x.column_value, '/DETAILS/NAME') as emp_name,
extractValue(x.column_value, '/DETAILS/SALARY') as emp_sal
FROM TABLE(
XMLSequence(
Extract( xmltype('<DETAILS>
<EMPID>
2482
</EMPID>
<NAME>
SMITH
</NAME>
<SALARY>
4854
</SALARY>
<LOC>
CHENNAI
</LOC>
</DETAILS>'),'/DETAILS'))) x;
Please suggest how to remove additional spaces by using second query.
Thanks
Vikrant Jain.It appears that the ability to use XPath functions in the PATH expression doesn't work prior to 11g :
Connecté à :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> var xmldoc varchar2(4000)
SQL> begin :xmldoc := '<DETAILS>
2 <EMPID>
3 2482
4 </EMPID>
5 <NAME>
6 SMITH
7 </NAME>
8 <SALARY>
9 4854
10 </SALARY>
11 <LOC>
12 CHENNAI
13 </LOC>
14 </DETAILS>';
15 end;
16 /
Procédure PL/SQL terminée avec succès.
SQL> SELECT emp_id, emp_name, emp_sal
2 FROM XMLTable('/DETAILS'
3 PASSING XMLTYPE(:xmldoc)
4 COLUMNS
5 emp_id NUMBER PATH 'normalize-space(EMPID)',
6 emp_name VARCHAR2(20) PATH 'NAME',
7 emp_sal VARCHAR2(20) PATH 'SALARY');
SELECT emp_id, emp_name, emp_sal
ERREUR à la ligne 1 :
ORA-31011: Echec d'analyse XML
ORA-19202: Une erreur s'est produite lors du traitement la fonction XML (
LPX-00601: Invalid token in: '/*/normalize-space(EMPID)')Using it in XQuery will work though :
SQL> SELECT *
2 FROM XMLTable(
3 'for $i in /DETAILS
4 return element r
5 {
6 for $j in $i/*
7 return element {local-name($j)} {normalize-space($j)}
8 }'
9 PASSING XMLTYPE(:xmldoc)
10 COLUMNS
11 emp_id NUMBER PATH 'EMPID',
12 emp_name VARCHAR2(20) PATH 'NAME',
13 emp_sal NUMBER PATH 'SALARY'
14 );
EMP_ID EMP_NAME EMP_SAL
2482 SMITH 4854 -
How to use oracle nlssort function in order by clause?
If I need to use linguistic sort feature in Oracle, I can write a SQL like that:
Select product_name from product
order by NLSSORT(product_name, 'NLS_SORT=GENERIC_M');
How can I generate a SQL like this by Toplink?Hi,
To answer your query:-
http://abhishek-soablog.blogspot.com/2008/08/orclquery-database.html
Cheers,
Abhi... -
How to get no of days using oracle date function
Dear all,
i need different output from this query mentioned below.
suppose i have execute this query.
sql> select add_month(SYSDATE, -1 * 6) finaldate from dual;
it will give the output as
sql>FINALDATE
05-JUL-2009 13:46
now i need to get the total no days from the same query that means it should calculate the total no of days from july to current date and give the output.
if you can give any hint.
Regards
LaxmanOracle supports date arithmetic and uses day as a unit.For example, number of days from July 1, 2009 to SYSDATE
SQL> SELECT SYSDATE - DATE '2009-07-01'
2 FROM DUAL
3 /
SYSDATE-DATE'2009-07-01'
188.386968
SQL> SY. -
Hi,
I have a field in my table that stores an ID which is encoded using a C function. (third party database)
I have also been provided the C function that decodes that field to display the actual value. I have compiled this code using Visual Studio .Net 2003 to a dll file, but do not know how to use it in Oracle. Or are there other ways to use this decode function in Oracle?
I am on 9i database, Windows 2003 server.
Any help is appreciated.
Thank you.Hi, see:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9087161189226 -
Using DECODE Function to change data
I am trying to use the Decode function in a SQL statement to find a field that has a specific type, and when it finds that type, I want to blank out the results in a different field.
For example:
DECODE(ADDR_TYPE,'HOME',PHONE='') HOME_PHONEsomething like:
SQL> with t as
2 (select 219 id,
3 'BUS' addr_type,
4 '505-555-5555' phone
5 from dual
6 union
7 select 219 id,
8 'HOME' addr_type,
9 null phone
10 from dual
11 union
12 select 220 id,
13 'BUS' addr_type,
14 '101-111-1111' phone
15 from dual
16 union
17 select 220 id,
18 'HOME' addr_type,
19 null phone
20 from dual
21 union
22 select 223 id,
23 'BUS' addr_type,
24 '202-222-2222' phone
25 from dual
26 union
27 select 224 id,
28 'HOME' addr_type,
29 '303-333-3333' phone
30 from dual
31 union
32 select 225 id,
33 'BUS' addr_type,
34 null phone
35 from dual
36 union
37 select 226 id,
38 'HOME' addr_type,
39 null phone
40 from dual)
41 select a.id,
42 a.addr_type,
43 decode(a.addr_type,'BUS',phone,null) phone
44 from (select id, addr_type, phone,
45 row_number() over (partition by id order by id, decode(addr_type,'BUS',1,2)) rn
46 from t) a
47 where a.rn = 1;
ID ADDR PHONE
219 BUS 505-555-5555
220 BUS 101-111-1111
223 BUS 202-222-2222
224 HOME
225 BUS
226 HOME
6 rows selected.
SQL> -
Order by clause using decode function
Hi everybody,
i need below order in my report.
Connecticut
greenwich
stamford
bridgeport
New York
NYC
wrestcher
byram
Georgia
atlanta
athens
oconny
first i need above order in my view out put.
so in order by clause i used first decode function for State ordering
and in second decode function for city ordering.
i do not need order by ascending or descending.
so pls anybody can help me.
any help is greatly appreciated.
thanks.add asc after the decode. default is desc
-
Hello Friends,
I have a query that has different columns and I am not sure what the data type of each column is ...
I want to use decode function which displays the following if the value of the column is like this ..
if the value of column is -714E ie -700000000000000 then display as .A
if the value of column is -814E ie -800000000000000 then display as .B
NOTE ; don't know which column is having the value - and i don't know the data type of the column is ..
got to use the decode function for all the columns selected ..
I want to use decode function pls let me know how to write for this kind of requirement.
appreciate your help in this rgds.
thanks/kumarDear Sir / Madam,
Thanks for your understanding.
Right now I am facing a unique problem.
I am using decode function in a select statement. The columns are dynamic some columns are of type number and some are varchar datatypes. I want to apply decode function for every column irrespective of datatype.
What i am finding difficult is if the column is a number datatype , the decode funciton is working good but if the column datatype is varchar or char datatype then i am getting ..
here's the decode function..
decode (CHAI.EVNDRIVE,
-800000000000000,'.A',
-700000000000000, '.B',
-600000000000000 ,'.C',
-500000000000000 , '.D',
-400000000000000 , '.E',
-300000000000000 , '.F',
-200000000000000, '.G',
-100000000000000 , '.H',
-1000000000, '.R' ,CHAI.EVNDRIVE ) EVNDRIVE
report error:
ORA-01722: invalid number
pls let me know how to over come this kind of scenario.
is their a way to find whether the column datatype is number or char , so that i can check the column datatype before the decode funciton is applied ..
thanks ..
kumar -
Using of Oracle Text functions not working in JDev
Hi,
I'm confused about using Oracle Text functions in JDeveloper.
It's not possible for me to pass the sql syntax test while creating a view object with a custom query:
SELECT score (1) myScore,
dokumente.titel,
ctx_doc.snippet ('idx_dokumente_titel',
TO_CHAR (dokumente.dkt_id),
'searchstring'
) snippet
FROM dokumente
WHERE contains (titel, 'searchstring', 1) > 0;
I retrieve "ORA-00911: invalid character" for the contains-function.
(Using this statement in sql-worksheet works.)
Any ideas?Hi william,
Yes you need code abap to maintein your data. look at <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/2f/696d360856e808e10000009b38f839/frameset.htm">Business Data Toolset</a>, in the part of Dialog.
Regards.
Manuel -
DECODE Function In Reports 3.0
Hi,
When I use the decode function in a query (Reports 3.0.5.8.0) I receive an error message "Bind Variable Does Not Exist" (ORA-1006). When I remove the decode function from the query, the query compiles fine. All table and column references are existing.
Also, the same query runs perfectly fine from SQL*Plus. The OS is Win 2000, SP2
Any idea if this is a bug? Is there any way out? Do get back as this is very urgent.
The database is Oracle 8i Ent, 8.1.7 on AIX 4.3
The query is as follows:
SELECT NAM_CMP , COD_CMP , COD_CMP_REG ,
DECODE(FLG_CMP_SHP,'Y','S/',' /') || DECODE(FLG_CMP_AGT,'Y','A/',' /') || DECODE(FLG_CMP_CNE,'Y','C',' ') TYPE ,
DES_ADD_STT , DES_ADD_PLC , DES_ADD_STA , DES_ADD_POS , COD_CTY , COD_cou_iso ,
DAT_LST_AST , DAT_LST_UPD,
cod_dcl_box_num, decode(cod_imp_chg_way,'C','CASH','CREDIT') cod_imp_chg_way,
decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL) cod_imp_cre_way,
decode(flg_imp_prn_inv, 'N', null, flg_imp_prn_inv) flg_imp_prn_inv,
cod_bro_box_num, decode(cod_exp_chg_way,'C','CASH','CREDIT') cod_exp_chg_way,
decode(cod_exp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL) cod_exp_cre_way,
decode(flg_exp_prn_inv, 'N', null, flg_exp_prn_inv) flg_exp_prn_inv
FROM CMP
where dat_can is nullTry TO_CHAR(NULL) instead of NULL in all DECODE functions.
For example:
decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', TO_CHAR(NULL))
instead of:
decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL). -
DECODE function to validate date value and sort the records
Hi Friends,
I am looking for some query which can give me the required output,
I need to do this using SQL query only and I have tried using the MIN() and MAX() functions it was working fine with limited data, now after inserting the last record(in the below table) which has date for start_range and end_range in(mm/dd/yyyy hh24:mi:ss) format.
Because the data type is VARCHAR2 if I am using the MIN() function it is sorting as a string value, hence the min date is incorrect. I tried using validating the value to date or non date and tried to using MIN() and MAX() functions using the DECODE function, I am getting this error "ORA-01840: input value not long enough for date format".
select table_name,
DECODE(substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1),'// ::',
to_char(min(to_date(start_range,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),min(start_range)) MIN_RUNS_START_RANGE,
DECODE(substr(END_RANGE,3,1)||substr(A.END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1),'// ::',
to_char(max(to_date(END_RANGE,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),max(END_RANGE)) MAX_RUNS_END_RANGE
from MY_TABLE
GROUP BY table_name,
(substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1)),
(substr(END_RANGE,3,1)||substr(END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1))
Can sombody please advise what is the best way I can query this data with the required output.
The following are the source table and records and the out put records using the sql query.
MY_TABLE
TABLE_NAME(VARCHAR2),START_RANGE(VARCHAR2),END_RANGE(VARCHAR2)
TABLE1,1000,10000
TABLE2,ABCD,EEEE
TABLE3,01/12/2010 00:00:00,12/31/2010 23:59:59
TABLE1,10001,20000
TABLE2,EEEF,GGGG
TABLE3,01/01/2011 00:00:00,01/31/2011 23:59:59
OUTPUT :
TABLE_NAME,MIN(START_RANGE),MAX(END_RANGE)
TABLE1,1000,20000
TABLE2,ABCD,GGGG
TABLE3,01/12/2010 00:00:00,01/31/2011 23:59:59
Thanks
Kalycsi also think this is a very bad table design ...
but if you are not able to change it, you could split the select (date and non-date data) and combine the result with UNION like this:
with t as
SELECT 'TABLE1' table_name,'1000' start_range,'10000' end_range FROM dual UNION
SELECT 'TABLE2','ABCD','EEEE' FROM dual UNION
SELECT 'TABLE3','01/12/2010 00:00:00','12/31/2010 23:59:59' FROM dual UNION
SELECT 'TABLE1','10001','20000' FROM dual UNION
SELECT 'TABLE2','EEEF','GGGG' FROM dual UNION
SELECT 'TABLE3','01/01/2011 00:00:00','01/31/2011 23:59:59' FROM dual
SELECT table_name,
TO_CHAR(MIN(TO_DATE(start_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS'),
TO_CHAR(MAX(TO_DATE(end_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS')
FROM t
WHERE start_range LIKE '%/%/%:%:%'
GROUP BY table_name
UNION
SELECT table_name,
MIN(start_range),
MAX(end_range)
FROM t
WHERE start_range NOT LIKE '%/%/%:%:%'
GROUP BY
table_name;
TABLE_ MIN_VALUE MAX_VALUE
TABLE1 1000 20000
TABLE2 ABCD GGGG
TABLE3 01/12/2010 00:00:00 01/31/2011 23:59:59 -
Decode function involving 2 fields (urgent)
Hi .. I am trying to use the decode function involving 2 fields.
The query runs but does not produce the correct results. If
anyone knows, please reply .. Usually decode function involves
one column only but I have more
than one. The situation is : If ins_code = 2 or special_code =
MMI, put a 'Y', otherwise, it's a 'N'. Does anyone know how to
put this in a decode statement? ThanksThanks, Suresh ... but I have to put this condition using the
decode statement because that's how the rest of the program is
written. It's part of the script that I have to change. The
current statement is this: decode(ins_code, '2', 'Y', 'N'). I
have to change it to ins_code =2 or special_feature = MMI.
Please reply ... thanks a lot....
Maybe you are looking for
-
Re: Creative Cloud app gets stuck on spinning wheel on Mac OS 10.9.5
Jeff, Thanks for your reply. OK, so I am using approved OS 10.9.5 and am still having the same issue. Is there anyone who can help me get my CC apps installed on my second, studio machine? Or does the installer only work one time for every membership
-
Delayed save as dialog box.
I have an issue with any adobe product that I have on my machine. Illustrator, Framework, or photoshop. Whenever I go to save as, it is always delayed at least 10 seconds or longer. I have checked network drives that are no longer available, network
-
Can you get the album art to fill the screen?
1)Is it possible to get the album art to fill the screen on the nano? 2)If you make the gif more widescreen in dimensions will it fill more of the screen at the sides?
-
I am HAVING RHEL 5.5 EBS R12 Mozilla 3.0 JRE 1.5 JDK 1.5 but i am not able to open any form getting ERROR as : Missing plug in unknown plug in (application/x-java-applet;jpl-version=1.5.0_10)
-
Can't get Illustrator to reinstall on my computer
I have Adobe Illustrator CS2 on my computer - computer locked up - I tried to reinstall but Illustrator just says "The application Illustrator has unexpectedly quit." Never had a problem in the past reinstalled any software. Do think its a virus? Mes