PL/SQL :: Creating (If-Else) Statement?

May 2, 2013

We make a 'SELECT' and then create a file with the results and send it by email... what we want to do is , if there are no results from that select , not sending the email neither creating the file..

View 5 Replies


ADVERTISEMENT

Creating A Trigger Within If-else Statement

May 25, 2012

I would like to create a trigger on a table, but only if the table exists.

This is what i've got so far:

create or replace function tableExists (tablename in varchar2) return boolean
is
c int; 
begin    

[Code].....

This would give me the error:

PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: ( begin case declare exit for goto if loop mod null pragma raise return select update

View 1 Replies View Related

SQL & PL/SQL :: Creating DDL Statement Giving Error?

Apr 29, 2011

I have a question. If i insert some values to a table and then write a create statement. But if the create statement gives me error (eg: table name already exist). And without commiting if i come out the session will the insert commit?

View 9 Replies View Related

SQL & PL/SQL :: How To View Full Statement Of Creating Function

May 24, 2011

I executed the following statements

SQL> CREATE OR REPLACE Function test
2 ( name_in IN varchar2 )
3 RETURN number
4 IS
5 cnumber number;
6
7 cursor c1 is
[code]....

how I can view the full statement of creating the function.

View 1 Replies View Related

Variable Usage In Type Of Table Declaration Statement And Execute Immediate Statement

Aug 10, 2011

HOW to use variable P_TMPLID in following statement

TYPE typ_unrecon IS TABLE OF REC_' || P_TMPLID ||'_UNRECON%ROWTYPE index by binary_integer;

because its throwing error while compiling

and also in statement
FORALL i IN unrecondata.FIRST .. unrecondata.LAST SAVE
EXCEPTIONS
--STRSQL := '';
--STRSQL := ' INSERT INTO REC_' || P_TMPLID ||'_UNRECON VALUES ' || unrecondata(i);
-- EXECUTE IMMEDIATE STRSQL;
INSERT INTO REC_' || P_TMPLID ||'_UNRECON VALUES unrecondata(i);---throwing error on this statement
commit;
--dbms_output.put_line(unrecondata(2).TRANSID);
EXCEPTION

View 2 Replies View Related

SQL & PL/SQL :: Select Statement From Schemas In MERGE Statement In USING Clause

Sep 13, 2013

In the following merge statement in the USINg clause...I am using a select stament of one schema WEDB.But that same select statement should take data from 30 schemeas and then check the condition below condition

ON(source.DNO = target.DNO
AND source.BNO=target.BNO);

I thought that using UNIONALL for select statement of the schemas as below.

SELECT
DNO,
BNO,
c2,
c3,
c4,
c5,
c6,
c7
[code]....

View 5 Replies View Related

SQL & PL/SQL :: Select Statement Is Blocking A Delete Statement

Jan 11, 2012

I am using JDBC to run a few queries from my Java program (multi-threaded one).I am facing an issue where a select statement is blocking a delete statement. From the java code point of view, there are 2 different threads accessing the same tables (whith different DB connection objects).

When the block occurs (which i was able to find out from the java thread dump that there is a lock on oracle), the below is the output:

SQL> SELECT TO_CHAR(sysdate, 'DD-MON-YYYY HH24:MI:SS')
2 || ' User '||s1.username || '@' || s1.machine
3 || ' ( SID= ' || s1.sid || ' ) with the statement: ' || sqlt2.sql_text
||' is blocking the SQL statement on '|| s2.username || '@'
4 5 || s2.machine || ' ( SID=' || s2.sid || ' ) blocked SQL -> '
6 ||sqlt1.sql_text AS blocking_status FROM v$lock l1, v$session s1, v$lock l2 ,
7 v$session s2,v$sql sqlt1, v$sql sqlt2
8 WHERE s1.sid =l1.sid
9 AND s2.sid =l2.sid AND sqlt1.sql_id= s2.sql_id
AND sqlt2.sql_id= s1.prev_sql_id AND l1.BLOCK =1
10 AND l2.request > 0 AND l1.id1 = l2.id1 AND l2.id2 = l2.id2;
[code]...

From the above it can be seen that a select statement is blocking a delete. Unless the select is select for Update, it should not block other statements is not it ?

View 10 Replies View Related

SQL & PL/SQL :: Insert Into Statement Doesn't Insert All Rows Return By Select Statement?

Jan 12, 2011

If i inserted the values in table it gets inserting very few rows only.I dont know y it is?

View 15 Replies View Related

Creating ASM Instance?

Feb 7, 2011

creating an ASM instance. I've never done this before and searched all known documentation. I just can't seem to figure this out. This is an 11g database on a WinXp machine for testing purpose before attempting to do this on a live production environment

D:\app\user\product\11.1.0\db_1\BIN>localconfig add

Step 1: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'Dummy\user', privgrp '
Operation successful.

Step 2: creating new CSS service
Failed to create the new CSS service, err(5)
failed to create CSS services

View 6 Replies View Related

SQL & PL/SQL :: Creating A Surrogate Key

Feb 18, 2011

I have created a sequence and I would like to create a surrogate key in one of my tables that will take the values of the sequence. I searched for hours but couldn't find any example of how to do that.

View 1 Replies View Related

SQL & PL/SQL :: Creating A Trigger

Jul 19, 2011

I need to create a trigger for the below case:

index_id Time_vertex_id date rate pre_rate
4 1 17-06-2011 4.7 6.4
4 1 16-06-2011 6.4 7.4
4 1 14-06-2011 7.4
4 1 15-06-2011 8.4 7.4

the index_id and time_vertex_id will be unique and when the date is 17th i.e the first date will be inserted the current rate will be 4.7 and the previous rate will be blank and when another date is inserted i.e 16th the previous rate of 17th will be the current rate of 16th i.e 6.4.

when 14th is being inserted, the previous rate of 16th will be the current rate of 14th i.e 7.4 and if after 14th is being inserted, 15th is being inserted, then the previous rate of 16th should be updated as per the current rate of 15 say 8.5.

View 5 Replies View Related

SQL & PL/SQL :: Role Not Creating

Jun 3, 2010

If iam create a new role in scott/tiger user why not creating. can any one explan me.

SQL> create role test_role;
create role test_role
*
ERROR at line 1: ORA-01031: insufficient privileges

View 2 Replies View Related

SQL & PL/SQL :: Error With Creating Job

Sep 18, 2010

I am writing the following PLSQL code-

BEGIN

DBMS_SCHEDULER.CREATE_JOB
(
job_name=>'TRIAL JOB',
job_type=>'PLSQL BLOCK',
job_action=>
[code]........

The new table used above has the following structure

Name Null? Type
STAMP TIMESTAMP(6) WITH TIME ZONE

However I get the following error on execution and am not able to make out why?

BEGIN
*
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at line 3

View 4 Replies View Related

PL/SQL :: Sql For Creating Xml Data

Nov 14, 2012

I have a requirement to create an xml file from a table. The table has product number repeated for each values of attrbiutes. Is it possible to create an xml file with product_id only once and all the attributes and values listed under that.

Example

WITH tmp AS
(SELECT '0983433' AS product, 'color' prd_attr, 'blue' AS val
FROM DUAL
UNION
SELECT '0983433' AS product, 'size' prd_attr, '23' AS val

[Code]...

And the file should be like the following

PRODUCTS>
- <PRODUCT>
<ID>0384491</ID>
- <NATURE>
<SALE>Y</SALE>

[Code]....

View 4 Replies View Related

SQL & PL/SQL :: Creating A New Session

Mar 14, 2013

How to create a new session from a pl/sql. My requirement is that i will package which should run on new session and execute it.

BEGIN

A; --Calling package
B; --Calling package and this should run on new session.
C; --Calling Package
end;

Now when I will run the this plsql block, then A,C should execute will run in this package only but B will run separate session.Whole idea to have better performance. I heard we can use PRGMA AUTONOMOUS_TRANSACTION, but this is not working.

View 3 Replies View Related

Creating A User Through Forms 6i?

Sep 12, 2010

I created a form that would allow a user to create another user.i tried creating a user in forms 6i using the following code on the when button pressed:

BEGIN
forms_ddl('create user'||:user_name||'identified by'||:pasword);
commit_form;
END;

pasword and user_name are captured in the form.

View 2 Replies View Related

Creating Materialized View Log

Feb 7, 2013

There are 2 databases, database A and database B. Database A is Oracle 11.2.0.2 which runs on linux and Database B is Oracle 11.2.0.2 which runs on windows xp machine. In database A, there are 100's of tables which are being updated every 10 minutes or 15 minutes. For reporting purpose, the developer wants to run report for the tables. But since database A is being updated every now and then, generating reports takes almost 15 to 20 minutes. So the reports can be generated in Database B. Once in a day the database B should have the updated data from database A so that the reports can be generated in database B with less time. What could be the best solution for the database B to have the updated data on daily basis from database A in oracle?

View 3 Replies View Related

Creating Table With A Constraint?

Oct 16, 2006

how to i insert a constraint of words into the table example below.I am new to this stuff man.

Create table Orders
(
orderID Number(8) Primary Key,
orderDate Date Not Null,
methPmt Varchar2(10),
custID Number(5),
orderSource Number(2),
Foreign Key(custID) Reference Customer(custID),
Foreign Key(ordersource) Reference OrderSource(ordersource)
);

The catch is I am required to enter a constraint of the methPmt will only take values of "CASH", "CREDIT" or "CHEQUE" only.

How am I suppose to enter this constraint value into the creation of this table?

View 3 Replies View Related

Creating Cursor For Every Class?

Aug 24, 2008

I'm modifying a package which contains a function with different parameters (say cno, gno, pname etc) need to be passed though it and that function is called by the cursor later in the program. I need to create a cursor (select statement) for every class (a program set)...i.e. multiple select statements for a program set with different values. The parameters needed to be passed correspond to same columns in different tables...so do i have to refer those tables everytime i'm passing the parameters using a select statement? The Program accepts the parameters as an array (list of parameters) and returns a cursor and the program handles one program set (class) at a time. That parameter list will be in a loop..i.e. it will be repeated for every certain combination (say cno - pname combination). So ... How should i proceed and create a select statement with different parameters declared in the function of type string making it dynamic and returning them using ref cursor?

View 1 Replies View Related

Creating Extract File From DB?

Jun 22, 2010

I have data in multiple oracle tables. I have to create a extract flat file after applying some validation and business logic on it and store it in unix server with naming convention FF_RMS_SC_<<YYYYMMDDhhmm>>.txt.This job will be scheduled to run daily to create the flat file. I guess pl/sql and unix needs to be used.

View 1 Replies View Related

Creating Trigger Through Procedure

Jul 24, 2009

I am trying to create trigger through Procedure due to following reasons-

1. The name of the column on which trigger will execute, is to be fetched dynamically.
2. The name of the column to be updated, is to be fetched dynamically.

Here is the sample code-

CREATE OR REPLACE PROCEDURE test2
IS
var VARCHAR2 (4000);
uname VARCHAR2 (30);
attribtask VARCHAR2 (100);
mapcol VARCHAR2 (100);
BEGIN
[code].........

On execution, the procedure throws the error of 'Insufficient privileges'. The 'var' seems to be the main culprit because the issue disappears if var is set to 'select * from dual'. Also, if i take the output (value of var) given by DBMS_output.put_line function and execute it explicitly, trigger gets created.

In addition- The procedure is (and being executed) within the same user/schema under which trigger is going to be created.

View 2 Replies View Related

Error While Creating Catalog DB

Aug 6, 2010

error while creating a catalog db

error creating db
ORACLE error from recovery catalog database ORA-01552: cannot use system rollback segment for non-system tablespace 'TS'
ORACLE error from recovery catalog database:ORA-00942:table or view doesnt exist

RMAN-00571:--------------------------------------------------------------------------------------------------
RMAN-00569----------------ERROR MESSAGE STACK FOLLOWS-------------------------------------------
RMAN-00571:---------------------------------------------------------------------------------------------------
RMAN-06433:error installing recovery catalog

View 1 Replies View Related

Creating A Cross Tab Report

Aug 28, 2007

I need to create a report that show the overall performance of the system in hourly basic. I need to check all the transaction table in the system. So I try to find Cross Tab query. I need display hourly basic in column. From 00 hour to 23 hour.

In my table i will have a sysdate that track all the record DD/MM/YYYY HH24:Mi, so now i need so split it to a hourly in column. This is how it will look like. Think show in picture is easier.

Each row actually retrieve from a table. So basically i need to count each table, on that day got how many transactions then split all to a hourly basic and display it.

View 5 Replies View Related

Creating Trigger For Views

Sep 21, 2008

I have a table tblcustomer and a view called vworder. I need to create a trigger such that any data being added into vworder first checks if the field customerid has the data in customerid of tblcustomer.. all it has to do is spit out a error "Customer ID not found"

So I created a view such as

Quote: create or replace TRIGGER trig_order
BEFORE INSERT OR UPDATE ON vworder
FOR EACH ROW
DECLARE
cust_id VARCHAR2(20);
BEGIN
SELECT customerid INTO cust_id FROM tblcustomer WHERE customerid = :new.customerid;
EXCEPTION
WHEN NO_DATA_FOUND THEN
Raise_application_error(-20000, 'Customer ID Does Not Exist');
END;

But it comes with error

Quote: ORA-25001: cannot create this trigger type on this type of view 25001. 00000 - "cannot create this trigger type on views" *Cause: Only INSTEAD OF triggers can be created on a view. *Action: Change the trigger type to INSTEAD OF.

I am not an expert at all and I need to finish this today itself.

View 7 Replies View Related

SQL & PL/SQL :: Creating A View In Developer SUM

Oct 26, 2011

I am having trouble with creating a view based on the following: -

Total hours flown EVER, for each crew of the FBN001 on 20th October 2011.

Here is what i got so far (only works for each members flown on a particular flight, NOT on their whole hours flown in a period of a lifetime) : -

SELECT e.Employee_Number, e.FirstName, e.LastName,
SUM( ( (s.ESTIMATED_ARRIVAL) - (s.ESTIMATED_DEPARTURE) )*24)AS
TOTAL_HOURS_FLOWN
FROM SCHEDULE s, CREW_ASSIGNMENT ca, EMPLOYEE e
WHERE
s.Flight_Number = ca.Flight_Number
AND
s.Serial_Number = ca.Serial_Number
[code]...

View 20 Replies View Related

Creating A Procedure In SQL Server

Mar 12, 2011

Recently decided to try using Oracle. Previously when creating a procedure in SQL server I would have done the following.

Create PROCEDURE GetInfo AS
SELECT InfoID, Name, Description
FROM GetInfo;

How can I write this same procedure in Oracle?

View 10 Replies View Related

SQL & PL/SQL :: Creating One Pipeline Function

Sep 18, 2012

I am trying to create one pipelined function but facing some errors as below

SQL> CREATE OR REPLACE
2 FUNCTION FUN_PIPELINED_EMP
3 RETURN org_typ Pipelined
4 IS
5 CURSOR c1 IS SELECT EMPLOYEE_ID,DESIGNATION,DEPT_ID,PROJECT_ID,MANAGER_ID FROM
6 EMPLOYEE_DETAILS1;
7 org_rec c1%rowtype;
8 begin
[code]....

View 13 Replies View Related

SQL & PL/SQL :: Creating A Database From Scratch

Apr 10, 2011

I just started using SQL PL/SQL a couple of weeks ago and am now creating a database from scratch.The tables have all been created, and I'm now doing the triggers. One in particular is giving me a headache...

I have 3 different types of client, A, B and C. Each class gets a discount bigger than the one before, and you need to buy until you reach a threshold of X before you move to the next class. I'm trying to do the following trigger:

When I update one of the threshold for the class, I want to make sure the new value isnt bigger than the value of the next class. For example, if a client needs to buy for 100$ before moving to Class B from A and 200$ to move from Class B to Class C and I update the first threshold from 100$ to 250$, I want an error message to pop up saying the threshold is too high.

Right now the Class table looks like this:

Class ID (A,B and C)
Threshold (0,100 and 200)
Discount (0, 0.05, 0.10)

View 3 Replies View Related

SQL & PL/SQL :: Error In Creating DBMS_SCHEDULER Job?

Feb 25, 2013

I have create the following procedure to create individual jobs dynamically on each schema.

CREATE OR REPLACE PROCEDURE APSP.JOB_TEST_RAM
AS
V_SQL VARCHAR2 (1000);
BEGIN

[Code]....

While executing this procedure I am getting the below error.

PLS-00103: Encountered the symbol "APPS_XX" when expecting one of the following:

View 5 Replies View Related

SQL & PL/SQL :: Creating A View From Procedure

Mar 4, 2011

I have create a procedure as

create or replace procedure aa is
abc varchar2(1000);
begin
abc:='create or replace view abc_view as select * from abc';
execute immediate abc;
end;

When i try to execute the same as

BEGIN
aa;
END;

i got error as

ORA-01031: insufficient privileges
ORA-06512: at "EARS.AA", line 5
ORA-06512: at line 3

why i get this error. there is no problem in grants. the same create or replace view query works if i directly executes in sql.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved