Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Exclamation Unanswered: SQL problem: Table Level, a reserved word?

    Hello people,

    It is embarrashing to ask this, but anyway ...

    I have this SQL query:

    "SELECT * FROM Level WHERE MaterialPK=1"

    The debugger says: "Syntax error in FROM clause". MaterialPK is a number, so it doesn't require the ' . Anyway, I already tried this :-)
    I tried with the same SQL but changing the table Level for Material, as my table Material has a field with the same name, and it works. So there must be a problem with the table Level. The table level has a composed primary key with MaterialPK and SupplierPK.
    Or maybe the word Level in SQL is used for something more, i.e., it is a reserved word. I don't know.
    Can somebody help with this silly question?
    Note: I already checked the exact name of the table, I am right with this ;-)

  2. #2
    Join Date
    Jan 2004
    Posts
    492

    Re: SQL problem: Table Level, a reserved word?

    Originally posted by pipeio
    Hello people,

    It is embarrashing to ask this, but anyway ...

    I have this SQL query:

    "SELECT * FROM Level WHERE MaterialPK=1"

    The debugger says: "Syntax error in FROM clause". MaterialPK is a number, so it doesn't require the ' . Anyway, I already tried this :-)
    I tried with the same SQL but changing the table Level for Material, as my table Material has a field with the same name, and it works. So there must be a problem with the table Level. The table level has a composed primary key with MaterialPK and SupplierPK.
    Or maybe the word Level in SQL is used for something more, i.e., it is a reserved word. I don't know.
    Can somebody help with this silly question?
    Note: I already checked the exact name of the table, I am right with this ;-)
    I believe it is, but you won't know until you try! Just make a copy of the database under a different name and change the table name. If that works, that is your problem.

    I'm guessing it really is your problem b/c that SQL statement shouldn't fail.

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I tried it, I think it is a reserved table's name for the security level.
    I am not sure.

    Anyway you can not say Select * From level

  4. #4
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: SQL problem: Table Level, a reserved word?

    Ey, thanx. I already tried this morning to change the name into Levels, instead of Level. It works! unbelievable.

  5. #5
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107

    Re: SQL problem: Table Level, a reserved word?

    Originally posted by pipeio
    Ey, thanx. I already tried this morning to change the name into Levels, instead of Level. It works! unbelievable.
    maybe you try to use naming conventions like beginning all Tablenames with "tbl" that generally keeps you out of such problems

    cheers

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    bachatero, do you also name your columns colFoo and colBar?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    hell no!
    but my systemtables stb, my querys qry, sqr and so on .. it comes to a point where that makes perfect sence ..

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    it may make perfect sense to you, but logically, there is a huge inconsistency in your advice -- if you prepend a prefix onto a table name to avoid a reserved word, then you should really do the same to column names

    n'est-ce pas?

    i mean, there may be other reasons why you feel it is advantageous to prepend the type-of-what-it-is onto the name, but if you're going to advise doing it to avoid using reserved words, then you should be consistent

    as you may have guessed, i do not subscribe to the belief that there is any valid reason for the prefix

    5) Prefixes on variables and schema objects.
    ...
    What you are doing is trying to expose the physical storage choices in your logical data model all over again. And you are making your code hard to read. Try to read "Paris in the Spring," "nounParis prepIn artThe nounSpring" and see if the prefixes make it easier to understand; now imagine that was a 20 word sentence with subclauses.
    -- Ten Things I Hate About You
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Jan 2004
    Posts
    492
    Originally posted by r937
    it may make perfect sense to you, but logically, there is a huge inconsistency in your advice -- if you prepend a prefix onto a table name to avoid a reserved word, then you should really do the same to column names

    n'est-ce pas?

    i mean, there may be other reasons why you feel it is advantageous to prepend the type-of-what-it-is onto the name, but if you're going to advise doing it to avoid using reserved words, then you should be consistent

    as you may have guessed, i do not subscribe to the belief that there is any valid reason for the prefix
    Interesting article - though the part about using propietary Oracle syntax because their product is so bad is laughable. They must be doing something right if they are the top DB manufacturer. Of course they are going to use some propietary features - what else would distinguish them?

  10. #10
    Join Date
    Mar 2004
    Location
    Berlin, Germany
    Posts
    107
    nice way to see it .. but i guess any further discussion would get philosophical, but U R for sure right that using hungarian notation just out of the sense to avoid reserved words would be nonsense. I do have my experience in MS Access and I do things the way they appear best to me .. which doesn't mean to be the universal right thing. I'd say advices here are to give people ideas .. find their way .. not to implant any dogmas into their thinking .. so let's have a beer and forget about the rest ..

  11. #11
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    It was only a question, jejejej, I solved the problem, thanx.

    Everybody became susceptible ... :-D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •