Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Really basic SQL command help

Author  Topic 

newbeetoday
Starting Member

2 Posts

Posted - 2006-08-25 : 02:23:24
Hi, can somebody help me with some verification SQL commands that I need to run on an Oracle database?

In the Oracle table 'FEE', if the 'FEETYPE' column has a value of '3' for a record, then the 'PERCENTAMOUNT' column needs to be not null for that row - can somebody put this into a command for me so I can make lots like it?

another one I have is in the 'FEE' table, if the 'FEETYPE' column has a value of '1', the 'PERIOD' column needs to always have a value of '3' for that row - is there a command that can check the records that do/do not have this information?

Any halp is greatly appreciated :)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-25 : 02:27:42
I don't know the syntax for creating ORACLE constraints, but you should create a constraint on the table that prevents PERCENTAMOUNT to be NULL when FEETYPE = 3.

The second question can be solved the same say.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

newbeetoday
Starting Member

2 Posts

Posted - 2006-08-25 : 02:33:31
Sorry I was not clear enough in my initial question, I was after the SQLPLUS command to query an existing Oracle database. Can you help?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-08-25 : 03:18:06
[code]select *
from fee
where feetype <> 3 or feetype = 3 and percentamount is not null

select *
from fee
where feetype <> 1 or feetype = 1 and period = 3[/code]or[/code]select *
from fee
where feetype <> 3 or feetype = 3 and percentamount is not null
or feetype <> 1 or feetype = 1 and period = 3[/code]or[/code]select *
from fee
where not (feetype = 3 and percentamount is null
or feetype = 1 and period <> 3)[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-08-25 : 08:02:49
Hi newbeetoday,

This is a Microsoft SQL server (Sequel Server) Forum.
Ur Qs may be better answered (mainly PL-SQL / SQLPLUS stuff) in an Oracle Forum


Srinika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-25 : 23:52:02
Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -