Home » SQL & PL/SQL » SQL & PL/SQL » Beginner: Need some simple code checking
icon4.gif  Beginner: Need some simple code checking [message #387892] Sat, 21 February 2009 09:38 Go to next message
mustaine85
Messages: 7
Registered: February 2009
Junior Member
Hi,
I'm extremely new to Oracle and just need some help getting some code of mine to work.
I'm using Notepad++ to edit my code.
When I run it there are errors (SP2-0734: unknown command beginning..) for all columns and their constraints except building_code
I'm using 10.2.0.
Thanks for any help Smile


create table BUILDING (
	building_code	char(1) 	
					CONSTRAINT pk_building PRIMARY KEY 
					CONSTRAINT check_upper_bcode 
					CHECK(building_code = UPPER(dname)
					CONSTRAINT bcodecheck CHECK( building_code between 'A' and 'Z'),
				
	name			varchar(30)
					CONSTRAINT bdgname_notnull NOT NULL,
	building_loc	varchar(30)
					CONSTRAINT bdg_loc_notnull NOT NULL,
	building_locno	number(3)
					CONSTRAINT bdg_locno_notnull NOT NULL
					CONSTRAINT format_building_locno CHECK 
(
					(substr(emp_code,1,1) is ('G' or 'F' or 'S' or 'T') and
                	(substr(emp_code,2,1) between '0' and '9') and
                	(substr(emp_code,3,1) between '0' and '9')
					),
)

[Updated on: Sat, 21 February 2009 09:52]

Report message to a moderator

Re: Beginner: Need some simple code checking [message #387901 is a reply to message #387892] Sat, 21 February 2009 11:00 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
If you get the mentioned error "SP2-0734: unknown command beginning.." in sqlplus, step 1 is to check for (and remove) empty lines in your script.
sqlplus cannot handle empty lines within a SQL statement.

[Updated on: Sat, 21 February 2009 11:01]

Report message to a moderator

Re: Beginner: Need some simple code checking [message #387911 is a reply to message #387892] Sat, 21 February 2009 11:08 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Remove blank lines.

Regards
Michel
Re: Beginner: Need some simple code checking [message #387992 is a reply to message #387892] Sun, 22 February 2009 23:45 Go to previous messageGo to next message
ashoka_bl
Messages: 398
Registered: November 2006
Location: Bangalore
Senior Member

Hi,

Is this what you looking for ?

CREATE TABLE building (
   building_code  CHAR(1) ,
   NAME        VARCHAR(30),
   building_loc   VARCHAR(30),
   building_locno NUMBER(3)
   CONSTRAINT pk_building PRIMARY KEY,
   CONSTRAINT check_upper_bcode CHECK(building_code = UPPER(NAME)),
   CONSTRAINT bcodecheck CHECK( building_code BETWEEN 'A' AND 'Z'),
   CONSTRAINT bdg_loc_notnull NOT NULL,
   CONSTRAINT bdg_locno_notnull NOT NULL,
   CONSTRAINT bdgname_notnull NOT NULL,
   CONSTRAINT format_building_locno CHECK ((SUBSTR(emp_code,1,1) IN ('G' , 'F' , 'S' , 'T')) AND
                                    (SUBSTR(emp_code,2,1) BETWEEN '0' AND '9') AND
                              (SUBSTR(emp_code,3,1) BETWEEN '0' AND '9')
                                  )
)


But where is EMP_CODE and other columns which are referenced in CHECK Constraint !!

Regards,
Ashoka BL
Re: Beginner: Need some simple code checking [message #388035 is a reply to message #387992] Mon, 23 February 2009 01:04 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What does your post add to what I said?
Do you think OP is so silly he does not know how to remove blank lines? Your post is offensive.

Regards
Michel
Previous Topic: Using Weekly data updates to Update a Table by row growth and not column growth
Next Topic: how to show dynamic column aliases
Goto Forum:
  


Current Time: Sun Dec 04 10:23:38 CST 2016

Total time taken to generate the page: 0.05666 seconds