Why DECODE can be used in the sql statement
Hello
Why not works sql1 but sql2.
decode (1,0,0,1) Select SQL 1) in the var of the double;
SQL 2) var = decode (1,0,0,1);
Please specify.
Kind regards
Kishore
decode has been implemented by Oracle to allow "if then else" type determination in SQL statements.
It was not necessary in PL because PL already had if THEN ELSE as part of the language.
Since that time became a standard ANSI for SQL, this CASE is now implemented in SQL and PL
It's just the way it is.
Your other does not work because it is the PL code, not a query SQL, and DECODE only exists in SQL.
You'd better stop using DECODE and start to use the CASE instead.
Tags: Database
Similar Questions
-
error in pseudo-column "DECODE" can be used within an SQL statement
Hi gurus,
Your help is grealty appreciated. Please help me.
I'm trying to see if I can use the function decode as below and get the error, here below vPlatformfrom value would be QA or MTS
vDataBase1 :='@'|| Decode (vPlatformfrom, 'STD', 'STD', 'QA', 'QA')
Before we check function NVL to a single platform, but now we need the database based on the platform is here.-vDataBase1 :='@'|| NVL (vPlatformto, 'MTS');
Error:
PLS-00204: pseudo-column "DECODE" or function may be used within an SQL statement
> So, here, instead of the decode function, I can use this case as below:
Well... you can, but why? In your CASE, you simply return the same value as the variable.
You might as well use: vDataBase1: = vPlatformfrom; It would reach exactly the same thing.
If vPlatformfrom can be a null value, you will need to decide what database to use or an exception. I think you're original code (NVL) were probably more correct, but I can't decide which.
(and don't bother selecting double, it is an unnecessary sql statement which must be analysed, etc..)
-
How to make a refund on an app that I bought by mistake I can not use in the United States
I have Down loaded and bought an antenna app companion that can not be used in the United States for $2.99. How can I get a refund
Purchases are considered final, but you can try the page 'report a problem' to contact iTunes Support and see if they will refund or credit you: http://reportaproblem.apple.com
Or you can try to contact iTunes support via this page: https://support.apple.com/contact or https://www.apple.com/emea/support/itunes/contact.html
-
Why I can't use the procedure in the select statement
Why I can't use the procedure in the select statementAnd you may not usa a SQL function if it has out parameters
SQL> create function myfun(p1 in out number) return number is 2 begin 3 p1:=1; 4 return 2; 5 end; 6 / SQL> select myfun(5) from dual; select myfun(5) from dual * ERRORE alla riga 1: ORA-06572: Function MYFUN has out arguments
In fact, the problem is that an output parameter is passed 'ref' and not 'val '...
Max
-
Hi all
I am new to TestStand. Still in the learning process.
What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?
Thanks in advance,
LaVIEWan
I'm sorry... I discovered that... its not at all possible to pass data to another sequence using variables... it must be through settings... once again I apologize for the display of such a stupid question
-
What should I do? why I can't use my world asks? It is said that it requires the latest version of blackberry id.
Use your browser to go to www.blackberry.com/appworld and download the latest version of AppWorld.
who should also update your BlackBerryID.
-
Why I can't use the nested aggregate function?
Hello Experts,
Why I can't use the nested aggregate function? There is not an ora-00979 group by error of expression.
Oracle Database 11 g Release 11.2.0.4.0 - 64 bit Production
Select
SUM (BOX WHEN (KSD_CREATEDATE BETWEEN TRUNC((KSD_CREATEDATE)) AND TRUNC(MIN(KSD_CREATEDATE)) +60) THEN 1 ELSE 0 END) AS col
DE TABLE_3_4
GROUP BY STC_FIRMANO
Thank you
GROUP BY will manage the SUM function, but the MIN is used incorrectly - use another SELECTION to get it, or work with only with a single line. Otherwise, you could do WITH... get the SUM of SELECT MIN...
-
Why I can't use the trial to convert PDF to Microsoft Word files
Why I can't use the trial to convert PDF to Microsoft Word files
Hi cathiechua,
You should definitely be able to convert PDF files to Word using Acrobat format. What happens when you choose file > save as other > Microsoft Word > Word Document?
Best,
Sara
-
How to COPY a BACKUP as the... CONTROLFILE can be used for the OPEN database
I create a document such as a "How To" to move a position for a Junior DBA controlfile.
But it seems that I'm the Junior because I am facing the following...
Action plan:
Move/rename a Controlfile
Version of the database: 11.2.0.3
Controlfiles moving of:
/ goldengate/ORCL/ORADATA /.
TO:
/ GoldenGate/ORCL/controlfile
Step 1: Set up environment variables
$> export ORACLE_SID = ORCL1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$> echo $ORACLE_SID
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ORCL1
$> export ORACLE_BASE = / u01/app/oracle
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$> echo $ORACLE_BASE
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/ u01/app/Oracle
$> export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/dbhome_1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
$ echo $ORACLE_HOME
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/U01/app/Oracle/product/11.2.0.3/dbhome_1
Step 2: Check control_files parameter
$> echo "see THE PARAMETER control_files | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
VALUE OF TYPE NAME
------------------------------------ ----------- ------------------------------
control_files string/goldengate/ORCL/ORADATA/control
ol01. CTL, / goldengate/ORCL/ORA
DATA/control02.ctl
Step 3: Closing the open database
$> echo 'SHUTDOWN IMMEDIATE'; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The database is closed.
The database is dismounted.
ORACLE instance stops.
Step 4: Editing of the database
$> echo "STARTUP MOUNT"; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ORACLE instance started.
Total System Global Area 4275781632 bytes
Bytes of size 2235208 fixed
822084792 variable size bytes
3439329280 of database buffers bytes
Redo buffers 12132352 bytes
Mounted database.
Step 5: Creating a copy of the current controlfile
$> echo "AS BACKUP COPY CURRENT CONTROLFILE FORMAT ' / goldengate/ORCL/CONTROLFILE/control01.copy.ctl'; ' | RMAN target / nocatalog
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Recovery Manager: release 11.2.0.3.0 - Production Fri Oct 22 17:03:27 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID = 1420762587, is not open)
using the control file of the target instead of recovery catalog database
RMAN >
From 22 October 15 backup
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID = 58 type of device = DISK
channel ORA_DISK_1: from data file copy
copy the current control file
tag name=/goldengate/ORCL/CONTROLFILE/control01.copy.ctl output file = RECID = 1 STAMP = 893783011 TAG20151022T170329
channel ORA_DISK_1: datafile copy complete, duration: 00:00:03
Backup finished at 22 October 15
RMAN >
Complete recovery manager.
Step 6: Change of parameter control_files
$> echo "ALTER SYSTEM SET control_files='/goldengate/ORCL/CONTROLFILE/control01.copy.ctl' SCOPE = SPFILE;" | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Modified system.
Step 7: Closing of the mounted database
$> echo 'SHUTDOWN IMMEDIATE'; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ORA-01109: database is not open
The database is dismounted.
ORACLE instance stops.
Step 8: Installation of the database
$> echo "STARTUP MOUNT"; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ORACLE instance started.
Total System Global Area 4275781632 bytes
Bytes of size 2235208 fixed
822084792 variable size bytes
3439329280 of database buffers bytes
Redo buffers 12132352 bytes
Mounted database.
Step 9: Check control_files parameter
$> echo "see THE PARAMETER control_files | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
VALUE OF TYPE NAME
------------------------------------ ----------- ------------------------------
control_files string/goldengate/ORCL/CONTROLFILE/c
ontrol01. Copy.CTL
Step 10: Open the mounted database
$> echo "ALTER DATABASE OPEN"; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ALTER DATABASE OPEN
*
ERROR on line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option of database open
$> echo "ALTER DATABASE OPEN NORESETLOGS"; | sqlplus-s "virtue sysdba".
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ALTER DATABASE OPEN NORESETLOGS
*
ERROR on line 1:
ORA-01610: recovery using BACKUP CONTROLFILE option must be
Then...
$> sqlplus/nolog
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL * more: Production release 11.2.0.3.0 the game Oct 22 17:14:43 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL > CONNECT sysdba virtue
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Connected.
SQL > RECOVER DATABASE with the HELP of BACKUP CONTROLFILE until CANCEL;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ORA-00279: change 621941 September at 22/10/2015 16:57:33 needed to screw 1
ORA-00289: suggestion:
/U01/app/Oracle/product/11.2.0.3/dbhome_1/DBS/arch1_11_892981851.dbf
ORA-00280: change 621941 thread 1 is in sequence #11
Specify the log: {< RET > = suggested |} Filename | AUTO | CANCEL}
Cancel
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Cancelled media recovery.
SQL > ALTER DATABASE OPEN;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ALTER DATABASE OPEN
*
ERROR on line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option of database open
Issues related to the:
What am I misunderstanding? BACKUP COPY THAT isn't really a COPY.
Why I can't use the 'copy' of the controlfile created by RMAN?
Note:
If I just copy the controlfile to the new location when the database shuts down everything works fine.
Thanks in advance.
Juan M
It is also mentioned in https://docs.oracle.com/cd/E11882_01/server.112/e25494/control.htm#ADMIN11288
Create additional Copies, rename and move the control files
-
How can I pass a condition of the table in the sql statement?
For example, in the table in the COND Varchar2 column (200) there is the value ' VAR > 10'.
| COND |
|' VAR > 10' |
where VAR is the name of the table column. I would like to make statement CASE WHEN VAR > 10 AND 0... I tried with as subquery
WHEN BOX (SELECT COND FROM TABLE WHERE...) THEN 0, but it does not work.
Hello
You can do this by using dynamic SQL.
that is to say:
declare v_stm varchar2(4000); v_cond varchar2(100); v_result integer; begin select cond into v_cond from yourtable where a=1; v_stm := 'select case when '||v_cond||' then 0 ...'; -- dynamic sql execute immediate v_stm into v_result; end; /
Remember that, in general, dynamic SQL has a performance degradation that SQL static and should be avoided when possible.
Storage condition or the SQL statements in the tables is not a good practice.
Kind regards.
Alberto
-
no user key can be used for the instance of the component integration "Contact."
I try to use the InsertOrUpdate method on the contacts. All I'm trying to add is a first contact name, first name, telephone number and the owner. Using InsertOrUpdate I get, no user key can be used for the instance of the component integration "Contact."
I can use the Insert method with no problems. What Miss me? Why the InsertOrUpdate method will not insert it?
Thank you.Hey... I also had the same problem into account.
so I tried to give the ExternalSystemId. and it worked... It should work once you set the external id.
Concerning
Balaji Tr. -
Touch digital can be used on the iPhone 6?
Touch digital can be used on the iPhone 6?
Hello
Touch digital can only be sent and received on Apple Watch (any model).
Apple Watch requires iPhone 5 or later.
More information:
-
A Mac mini, purchased in the UNITED Arab Emirates can be used in the USA with only change the power cord?
Yes.
http://www.Apple.com/Mac-mini/specs/
the voltage may vary from 100-240 V AC.
-
Hi I got a new Apple Watch as a gift at Christmas - sport band, white, 42 mm. 7000 series. Since this is my first Apple Watch, I wonder if I should check all options at the store before opening the box. Is it possible to buy separately strips that can be used with the watch? Thank you, in advance, for any advice, guidance, you can offer the wisdom.
Hi, Kate
Yes - any band Apple Watch 42 mm fits your Apple Watch.
Non-Sport bands have different lengths, then check the circumference of your wrist and see Apple Watch Sizing Guide (that compares all the Apple strips) before you buy separate bands:
http://www.Apple.com/shop/watch/Sizing-Guide
Try them in an Apple Store, it's also a great option.
The Sport of Apple Watch also has an anodized aluminum housing, while the non-sport bands have different metals of cards and/or links (this does not affect the compatibility, only appearance).
Information on how to pass the tapes: change your Apple Watch band - Apple Support
-
Messaging Instant Lync can be used with the Hosted Exchange mail server?
Messaging Instant Lync can be used with the Hosted Exchange mail server? Let me rephrase the question. As everyone knows already Lync messenger is used with Office 365, but can be used with the same way hosted exchange server, it is used with Office 365?
You will find support for MS Lync in these forums-online http://social.technet.microsoft.com/Forums/en-us/category/ocs
Maybe you are looking for
-
3.6.13 uninstalling will interfere with beta
I noticed install beta do not uninstall 3.6.13.I'm happy with beta 4.0 - can I uninstall 3.6.13?
-
AutoPlay will not read photo card
AutoPlay window does not come to the top when I put my photo memory card into the slot on my laptop. It works well until a few weeks ago. Can someone help me,... .chet33
-
Internet Explorer 10 is suitable for Vista?
Hello What is internet explore 10 for Vista? I'm a little worried after reading so many articles on Windows 8, and the fact that my laptop isn't a touchscreen-driven device, do you think it will be a problem if I update my computer? Thank you
-
My current C: drive becomes full and needs more space. I bought a disc more SSD 1 TB and I want to clone that grow so it will replace my c drive with them having to reinstall windows 7. How should we do about it?
-
Change the level of internet security via cmd
I have no internet explore installed, after update, I lost my ability to change internet options. I am not install so I need to change the level of security via the command prompt. OR could someone tell me what that update the required internet optio