Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

SQL Queries


  • Please log in to reply
4 replies to this topic

#1 comet@earth

comet@earth

  • Members
  • 170 posts
  • OFFLINE
  •  
  • Local time:10:49 PM

Posted 14 August 2012 - 09:46 AM

SQL> create table table1(no varchar2(10),name varchar2(10),check(no like 'ed10[0
-9]'));

Table created.

SQL> insert into table1 values('ed101','r');
insert into table1 values('ed101','r')
*
ERROR at line 1:
ORA-02290: check constraint (SYSTEM.SYS_C004024) violated


Where am I going wrong?
Thank you in advance

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:10:19 AM

Posted 14 August 2012 - 12:03 PM

Hmm... not positive what is going on here. I would say though that you'll probably be better off storing things as a real number rather than as a string. You can always format the string out later. (Combining is easy; parsing is hard).

What RDBMS are you using?

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 comet@earth

comet@earth
  • Topic Starter

  • Members
  • 170 posts
  • OFFLINE
  •  
  • Local time:10:49 PM

Posted 14 August 2012 - 12:37 PM

Oracle 10g.I didn't get you sir.An example would help.
Thank you for replying

#4 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:10:19 AM

Posted 14 August 2012 - 12:44 PM

I don't have an example -- what I'm talking about is to do the logic of adding the "ed" part in your application, not the database, and then just store the number as an INTEGER or similar.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#5 comet@earth

comet@earth
  • Topic Starter

  • Members
  • 170 posts
  • OFFLINE
  •  
  • Local time:10:49 PM

Posted 14 August 2012 - 11:30 PM

When I fire the query I should return the number and append 'ed' to the number but I am not building an application I am just practicing SQL queries from a booklet I found on the internet.If you tell me how to do it standalone I shall be very grateful.
Thank You




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users