In Oracle, Can i use if exits clause in a query?
In Oracle, Can i use if exits clause in a query?
For example, "Drop table if exists tablename"
Is the above command valid in oracle?
If not then is there any equivalent for if exists clause?
Here is the SP code code that might help you to Drop a table if it exisit, whith out throwing an error if the table is not present.
create or replace PROCEDURE DROP_TABLE(TabName in Varchar2)
IS
temp number:=0;
tes VARCHAR2 (200) := TabName;
drp_stmt VARCHAR2 (200):=null;
BEGIN
select count(*) into temp from user_tables where TABLE_NAME = tes ;
if temp =1 then
drp_stmt := 'Drop Table '||tes;
EXECUTE IMMEDIATE drp_stmt;
end if;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END DROP_TABLE;
Call this SP in your Scripts by : CALL DROP_TABLE ('<Table Name>')
Hope this Helps!
Regards,
Kaarthiik
Similar Messages
-
Can't use ";" in sql clause with Oracle 8.X
Can't use ";" in sql clause with Oracle 8.X
I can't use ";" at the ending of sql clause in VB program. First this program can use with Oracle 7.3.4 database. But now i need to upgrade DB to Oracle 8.1.7 ,program can't operate. It show error Runtime 40002
and 37000:ODBC driver for oracle/invalid charactor
ThankyouI've seen a lot of discussion about semicolons in SQL
sent from 3rd party applications. A web search should
bring up the discussions.
Also you might get more response if you ask this question
somewhere else. This is not a VB forum, so you may
not reach relevant people.
-- CJ -
How can i use Order by inside a sub query in Oracle
Hi!,
Please help me, it's an urgent... how can i use Order by clause
SELECT SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.dDate
, (SELECT nvl(S.Qty,0) FROM Stock S , DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.dDate <= DD.dDate and rownum=1
ORDER BY DD1.dDate DESC*) as StockQty
, (SELECT nvl(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.dDate > DD.dDate
AND DD2.dDATE=DD.dDate
) as TotalQtySold
FROM SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0;
kindly help
Thank you.Actually I'm converting Procedures from SQL Server to Oracle.
Actual Stored Procedure in SQL Server is as follows.
SELECT --top 10000
SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.Date
, (SELECT TOP 1 ISNULL(S.Qty,0) FROM dbo.Stock S , dbo.DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.Date <= DD.Date
ORDER BY DD1.Date DESC) as StockQty
, (SELECT ISNULL(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.Date > DD.Date
AND DD2.DATE=DD.Date
) as TotalQtySold
--INTO TEMP_Salesfact
FROM dbo.SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0 -
Can I use User Exit u2013 IWOC0004 u2013 Change Single-Level List for TCODE IW37N?
Hi All,
Can I use User Exit u2013 IWOC0004 u2013 Change Single-Level List for TCODE IW37N?
In documentation of the User Exit I can see that I can use this user Exit for IW37(Program - RIAFVC20) , but I want to use this for IW37N (RIH_ORDER_OPERATION_LIST).
Please tell me is it possible.
With best regards,
NarendraHi Pete Sir,
I am on 4.7 , how to work with it. I am going to use screen exit IW0110018 and I want to add User fields in the IW37N.
Thanks with best regards,
Narendra -
Can we use Group by Clause here?
All,
Can we use group by clause in the date column?
If yes, will it work for these kind of values '11/12/2009 12:30:45 PM' and '11/12/2009 4:30:45 PM'......Hi,
frontier007 wrote:
All,
Can we use group by clause in the date column?
If yes, will it work for these kind of values '11/12/2009 12:30:45 PM' and '11/12/2009 4:30:45 PM'......Yes, GROUP BY works with DATEs.
Remember that DATEs always include hours, minutes and seconds, so '11/12/2009 12:30:45 PM' and '11/12/2009 4:30:45 PM', though they are in the same calendar day, are different DATE values. If you want them to be in the same group, then use TRUNC.
For example:
SELECT TRUNC (entry_date) AS entry_dt
, SUM (amount) AS daily_amount
FROM orders
GROUP BY TRUNC (entry_date)
;Edited by: Frank Kulash on Oct 30, 2009 4:55 AM -
How do you use 3 Where Clauses in a query
Hi, i am trying to figure out how to use 3 Where Clauses in a Query where 2 of the Where Clauses uses a Sub query.
Display the OrderID of all orders that where placed after all orders placed by “Bottom-Dollar Markets”.
Order the result by OrderID in ascending order.
First WHERE clause checks for OrderDate and uses a sub query with ALL keyword.
Second WHERE clause use equals and sub query.
Third WHERE clause uses equal and company name.
This is what i have so far but i am pretty confused on how to do this.
My Code for NorthWind:
Select OrderID
From Orders o
Where o.OrderID IN (Select OrderDate From Orders Where Orders.OrderID > ALL
(Select CompanyName From Customers Where CompanyName = 'Bottom-Dollar Markets'));
The book shows how to use the ALL Keyword but not in a Sub query with Multiple Where Clauses.
Select VenderName, InvoiceNumber, InvoiceTotal
FROM Invoices JOIN Vendors ON Invoices.VendorID = Vendors.VendorID
WHERE InvoiceTotal > ALL (Select InvoiceTotal From Invoices Where VendorID = 34)
ORDER BY VendorName;>Where Orders.OrderDate
> ALL (Select
CompanyName
The comparison operator (>) requires compatible data types.
DATETIME is not compatible with VARCHAR string for comparison.
Here is your homework:
SELECT orderid
FROM orders o
WHERE o.orderdate > ALL (SELECT orderdate
FROM orders
WHERE shipvia = (SELECT Max(shipvia)
FROM orders o
INNER JOIN customers c
ON c.customerid =
o.customerid
WHERE
c.companyname = 'Bottom-Dollar Markets'));
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
Can I use a OID rule for a Query SQL Lov of BIP?
Hi. Can I use OID data (rules) for a query sql lov in BIP? Ex. filters users/store.
Thank you.
R.Hi,
I didn't look at the example, but if you want to secure your application then you should use container managed security. Read this .
Anyway, you could add this before return "good"; in your login_action()
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", user);Then, you can access this from anywhere in the application by using #{sessionScope.username}.
Pedja -
Hi,
Can anybody tell me if i can use user exits for not applying cost centre fields for Assets and liabilites gl a/c when we post transcations in fb60 0r fb50 f-22 etc
warm regards
Manjunathhi Manjunath,
you can try to set up a substitution and see if it is working. On the other hand P/L accounts must have a CO object by posting, of course cost center is just one option.
ec -
Oracle can only use 2GB on Windwos XP Server
Hi all,
Is the following statement true or false:
"If the Oracle database runs on the Windows XP server (without access to the Datacenter version of Windows), the single-process architecture limits the Oracle database server to about 1.75GB of RAM in total. So, if we have 8GB of RAM on the server, users connected to Oracle can use only about 2GB of it."
Thanks in advance.This was why I posted in the first place... Like I said, it is not just copied (not verbatim, at least not from the edition I read), and it is taken out of context.
In this case, the chapter talks about how to develop oracle applications, the mentioned section (p 10) has an example of how not to by ignoring how oracle works and hence using more connections than really needed - it is not a chapter about Windows memory architecture.
According to the link I mentioned above, even XP has ability to use larger-memory techniques e.g. a larger user address space (3GB). But who or which note, doc, etc. is correct? Like Tom always pushes towards, you should not just swallow the bait, instead try to find out what it means yourself, build your own understanding.
Message was edited by:
orafad -
How do I exit a java program based on condition can i use system.exit
I have java program that is called by another program that I dont have control on. My program returns a bigdecimal... but if the ordernumber is empty in my program i dont wnat to do anything.. does system.exit work in that condition... i put it int he else if ordernumber is empty condition.. but i dont think that is the right approach..
When software module is expected to bring some result, it should bring the result, positive or negative. I think you should check what your counterpart software expects as positive or negative result. And then implement your software this way. You can use System.exit, but this call is employed usually to indicate status with the software after it's completion and not to return any resulting value.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#exit(int) -
How Can I use a Variable in Data Controls query. Frank Kindly check...
Hii,
I am using JDeveloper 11g ADF BC.
My Requirement is that I hv a login screen which is taken from [http://blogs.oracle.com/shay/simpleJSFDBlogin.zip].
I hv attached BC in this application. I want to use the login usercode in the next pages after login screen. Next screen contains 3 list items which will be populating based on the user. So I created <af:selectOneChoice> using the BC( Just drag & dropped the column into the page from the data controls). But in the data control i want to use this usercode for passing the condition. Now Data is coming without any condition.
So How can I use the usercode in the Data controls query.
When I tried to display the usercode in the next page it is showing by binding the value. its code is follows
<af:outputText value="#{backing_getUser.uid}"
The program for checking the username & Password is follows.
package login.backing;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.sql.*;
import java.util.List;
import java.util.Map;
import oracle.adf.view.rich.component.rich.output.RichMessage;
import oracle.jdbc.OracleDriver;
public class GetUser {
private RichInputText uid;
private RichInputText pid;
private RichCommandButton commandButton1;
private RichInputText inputText1;
private RichInputText inputText2;
public void setUid(RichInputText inputText1) {
this.uid = inputText1;
public void setPid(RichInputText inputText2) {
this.pid = inputText2;
public RichInputText getUid() {
return uid;
public RichInputText getPid() {
return pid;
public void setCommandButton1(RichCommandButton commandButton1) {
this.commandButton1 = commandButton1;
public RichCommandButton getCommandButton1() {
return commandButton1;
public String login_action() {
// Add event code here...
String user = this.getUid().getValue().toString();
// String pass = inputText2.getValue().toString();
String pid = this.getPid().getValue().toString();
Connection conn;
conn = getConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery ("SELECT usercode FROM guser where usercode = '"+user.toUpperCase()+"' and pwd=F_TEST('"+pid.toUpperCase()+"')");
if (rset.next()) {
conn.close();
return "good";
conn.close();
} catch (SQLException e) {
System.out.println(e);
return "bad";
public static Connection getConnection() throws SQLException {
String username = "ACCTS";
String password = "ACCTS";
String thinConn = "jdbc:oracle:thin:@SERVER1:1521:G5PS";
DriverManager.registerDriver(new OracleDriver());
Connection conn =
DriverManager.getConnection(thinConn, username, password);
conn.setAutoCommit(false);
return conn;
public void setInputText1(RichInputText inputText1) {
this.inputText1 = inputText1;
public RichInputText getInputText1() {
return inputText1;
public void setInputText2(RichInputText inputText2) {
this.inputText2 = inputText2;
public RichInputText getInputText2() {
return inputText2;
-----Hi,
I didn't look at the example, but if you want to secure your application then you should use container managed security. Read this .
Anyway, you could add this before return "good"; in your login_action()
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("username", user);Then, you can access this from anywhere in the application by using #{sessionScope.username}.
Pedja -
Can we use global structure while designing a query on a multiprovider
hai friends,
If i build a multiprovider on cubes for which the query design on those cubes contains global sturctures ,
Can i use those global structures while designing a query on a multiprovider (which contains those cubes)Hi Vamsi,
The structure from the base cubes will not automatically be available for the queries created on the multiprovider. The only way to get the structure there is to copy a query from the base cube to the multiprovider. You can use transaction RSZC to do this.
Hope this helps... -
Can I use multiline SQL commands in a query (within a component)?
I would like to modify the following query:
<td>ItranslationString</td>
<td>
INSERT INTO TRANSLATIONSTRINGS (daKey, daLanguage, daTranslation, daStringFlag, daSourceFile) VALUES (?, ?, ?, 'N', ?)
</td>
<td>daKeyField varchar
daLanguageField varchar
daTranslationField varchar
StringTranslationFilename varchar
</td>
so that the daSourceFile a) is selected from another record, if it exists b) uses the constant, if not.
In SQL Command the commands (without placeholders) look:
declare c integer;
res varchar(30);
key_var varchar(100);
def_lang_var varchar(5);
begin
key_var := 'newString';
def_lang_var := 'en';
res := 'ap_string.htm';
select count(*) into c FROM TRANSLATIONSTRINGS WHERE daKey = key_var AND daLanguage = def_lang_var;
if c > 0 then
select daSourceFile into res FROM TRANSLATIONSTRINGS WHERE daKey = key_var AND daLanguage = def_lang_var;
end if;
INSERT INTO TRANSLATIONSTRINGS (daKey, daLanguage, daTranslation, daStringFlag, daSourceFile) VALUES (key_var, 'cs', 'translation', 'N', res);
end;
However, such a query does not work in the query resource (multiline commands cannot be used?).
Neither can I think of one line query that would provide the same functionality (tried to test with COALESCE).Yes, I got the point. The query looks like:
INSERT INTO TRANSLATIONSTRINGS (daKey, daLanguage, daTranslation, daStringFlag, daSourceFile)
SELECT daKey, daLanguage, daTranslation, daStringFlag, daSourceFile FROM (
select 'newString1' daKey, 'en' daLanguage, 'transl' daTranslation, 'N' daStringFlag, daSourceFile FROM TRANSLATIONSTRINGS WHERE daKey = 'newString1' AND daLanguage = 'cs' UNION ALL SELECT 'newString1' daKey, 'en' daLanguage, 'transl' daTranslation, 'N' daStringFlag, 'default' daSourceFile FROM DUAL)
WHERE rownum<=1;
so that's the way how to solve it via SQL.
(Since I can't use DECLARE, I need to bind entry parameters as many times as they appear in the query - not a very nice way, but it works).
The question still is, whether there is a way how to use a multiline query in Component Queries. Even though it is not mentioned specifically in the documentation, it seems it is NOT to be possible by design. So the real question is really WHY - I guess it would be a little bit more convenient to begin/commit transactions, use variables, etc. in a multiline query.
Yet, Sam, thanks! -
Can we use any exit of COR1 to include storage type?
Hi experts
Our requirement is to add storage location & storage type check while creating process order in COR..
I found that we have one user exit PPCO0005 by which we can change the storage location..
Please explain me how can I do that & how can I include storage type in that..
THanks & RegardsHi
Thanks for your response..
In that given exit we can add our logic for the storage location but can we add the same to include storage type..
Please explain.. Also how can we add logic for the storage location.. Handling user exits for the first time.. kindly guide...
@Nambiar : I need to add storage type in material availability check when it haapens when we enter reqd qty while creating process order in COR1
Thanks & Regards -
Variable selection issue can we use variable exit for the below problem
Hi experts,
i have query in which i have an infoobject which is a characterstic i have even set the sort property for that infoobject but when the variable screen comes up and when we go into the selection screen all the help values are not sorted in the way i have set them. for example
ihave project managers like below
A
B
C
D
E
F
G
H
instead of displaying in order above its displyaing in
H
A
G
C
B
D
F
How to set it right.
thanks and regards
Message was edited by:
Neel KamalHi
actually i have done the same thing its getting displayed in the bex analyzer but not in the protal.
thanks and regards
Message was edited by:
Neel Kamal
Maybe you are looking for
-
Macbook pro mid 2012 suddenly very slow
I've had my Macbook Pro 13" (not retina) mid 2012 8 GB RAM for over two years and all of sudden it went from running as fast and smoothly as Usain Bolt to running about as fast as I do, which is extremely slow. Every time I try to do something on my
-
after upgrading my iphone ios from 5.1.1 to 6.0 wverythings seems to work fine. until today i was using my wi-fi network to download an application and suddenly wi-fi tirned off and when i went to the settings i cannot click on (on/off) wi-fi) it is
-
I was able to install and have an icon on my desktop. When i click on it it automatically pops a box up that says: Firefox has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a
-
No validation in BPEL server for XSLT
Hi there, I have set up an XSLT mapping from one schema to another, if my input xml is placed in the test tool on the JDeveloper then it succesfully validates the tranformation and shows an error. When the project is deployed the transformation occur
-
How to backup a Windows 2008 R2 KMS to prevent reactivation in case of failure?
Hi all, I'd like to know if there is a solution to backup a Windows 2008 R2 KMS configuration to prevent reactivation of the KMS in case of reinstallation. I just want to not being limited by the number of KMS activation with the same key. Thx in adv