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.
what is the difference between these two and in where we use Primary key and where we choose Surrogate Key.How to understand the difference between these two keys.
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
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.
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..
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
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.
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;
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?
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
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?
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.
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.
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
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.
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.
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]....
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)
So I'm here creating some tables and if theres a guide where I can take a look at some Constraints Declarations , Mostly cause i have some values on the table that cannot be negative so i need to set constraints to be positive
I have created a softlink to a data file orig_file.dat using the command ln -s orig_file.dat orig_file_link.dat
Now is it possible to create an external table using this linked file orig_file_link.dat
I am using this linked file to minimise the space usage because every month we get different data files and external table creation is done as a batch job copying the data file to another file whenever a new data file arrives. External table is created with the new file. so i need to check whether it is possible with the linked file instead of copying the file.