Shital Supase

Greenhorn
+ Follow
since Jun 05, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shital Supase

when multiple threads are created in a java program, will all the threads be passed to the operating system or just one thread ?
HELLO,

WRITE A TRIGGER AS GIVEN BELOW, WHICH WILL INSERT A NEW ROW IF , ITS FULFILLING THE CRITERIA FOR SALARY VALUE, OTHERWISE WILL RAISE AN ERROR & WILL CALL A PROCEDURE WHICH WILL ROLLBACK THE JOB.

------------------TRIGGER--------------------------------------------

CREATE OR REPLACE TRIGGER triggername BEFORE INSERT ON yourtablename
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW

DECLARE

BEGIN

IF :NEW.SALARY < 1000 THEN
RAISE_APPLICATION_ERROR('SORRY U CANT INSERT THIS ROW');
ROLLPROC;
END IF;

END;
/

--------------------------------------------------------------------------

--------------------PROCEDURE---------------------------------------------
CREATE OR REPLACE PROCEDURE ROLLPROC IS

PRAGMA AUTONOMOUS_TRANSACTION;

BEGIN

ROLLBACK;
DBMS_OUTPUT.PUT_LINE('ROLLBACK DONE');

END;
/
---------------------------------------------------------------------------


TRY TO WORK WITH THIS, YOUR PROBLEM WILL DEFINATELY GET SOLVED.

NICE TIME.
13 years ago
Hi,

I want to know , how to handle the mutating tables in triggers.
13 years ago
SQL
the problem statement is :

The database :

Emp(eid: integer, ename: string, age: integer , salary: real)
Works(eid: integer, did: integer, pct time: integer)
Dept(did: integer, budget: real , managerid: integer)

Query :. Define a table constraint on Dept that will ensure that all managers have age > 30


and the solution i tried is:


CREATE TABLE Dept ( did INTEGER,

buget REAL ,

managerid INTEGER ,

PRIMARY KEY (did),

FOREIGN KEY (managerid) REFERENCES Emp,

CHECK( ( SELECT E.age FROM Emp E, Dept D)

WHERE E.eid = D.managerid ) > 30 ))





but it's not working , giving error as

Subquery not allowed here .

What may b the problem in this solution ?
13 years ago
Can we change the position of attributes in tabel/realtion in Oracle ?
13 years ago
Hello Stu Derby,

Thanks for links for database problem. It's really very useful.

Have a nice time.
13 years ago
Now i got ur problem, i think u want to identify the primary key attributes of ur existing tables. OK.

U can just check which attribute(s) is/are defined as primary key of ur table by executing the command

desc <table_name>

it will show u the list of fields, their data types & constraint if any defined. So it will show u the word NOT NULL in front of the primary key field. & if it doesn't show it means u have still not defined primary key for ur table, so now u would have to alter the table.


That's it.
13 years ago
Hi Atish,

Ya exactly u have a way of defining a primary key after creating a table also. There u need to alter the table, using the command.

syntax:

alter table <table_name> add constraint <constraint_name> primary key(attribute_name);

e.g.:


alter table add constraint pk primary key(rollno);

Giving name to constraint is just for the sake of convinience & u can use it whenever u want to delete that constraint. But remember if u have created a table & inserted the data into the field which u now want to make a primary key then that field should have UNIQUE & NOT NULL values only otherwise it will not alter ur table to define existing attribute as primary key.

Just try it.

It will definately solve ur problem.
13 years ago
Hello Atish,

The basic aim behind defining the primary key in the table is to identify the record uniquely from ur table. The primary key is a set of one or more number of attributes which when taken collectively will identify the record uniquely from ur table. The syntax for defining a table is

create table <table name> (attribute1 datatype(size),attribute2 datatype(size),.............,primary key(atrributei));

create table students (rno number(3),name varchar2(20),.........................,primary key(rno));


This constraint of primary key imposes the constraints UNIQUE & NOT NULL on ur attribute(s).

Just try it.

If u have any problem u can still ask me / mail me at

sssupase@gmail.com

See u.
13 years ago
How to insert a record / tuple into the table / relation using select statement.
13 years ago
How to define a materialised view ?
13 years ago
shitalsupase@rediffmail.com

Hello Nee,

See i think there is basically a problem in table design itself. First of all u should have the tables in the normalised form, at least in 1NF . Means u should not have more than one value or a list of values at the intersection of a row & column. After that if the tables r normalised means if they r designed in some way like :

User_x(Full_Name,Login_Name,Group_id)

& Groups(Groupid,Group_name)


then it will definately solve the problem.if u can have design like this they i can give u the solution for ur problem also.Atually this is what u should have.

Ok . Try it.
13 years ago

Originally posted by Eric Lemaitre:
Hi Shital !

what is the difference between DBMS & RDBMS ?

The "R" stands for "Relational" ("DBMS" = "Data Base Management System", of course), for some databases are not relational (hierarchical for example), especially some legacy ones.

Best regards.




Thanks for reply ,

can u plz give me an example of both.

Have a nice day.
13 years ago

Originally posted by Eric Lemaitre:
Hi Shital !

what is the difference between DBMS & RDBMS ?

The "R" stands for "Relational" ("DBMS" = "Data Base Management System", of course), for some databases are not relational (hierarchical for example), especially some legacy ones.

Best regards.




Thanks for reply ,

can u plz give me an example of both.

Have a nice day.
13 years ago
shital580@rediffmail.com

Hello preethinj,

the bug in ur query is the statement whatever u have written as || 'like ''%'||whr ||'%'''

should b

|| ' like ''%'||whr ||'%'''

u have skipped the blank space between the field values & like keyword
13 years ago