alter table Syntax error

Last post 05-12-2008 2:55 AM by david wendelken. 6 replies.

Sort Posts:

  • alter table Syntax error

    05-11-2008, 2:05 AM
    • Loading...
    • piyuwithu
    • Joined on 05-11-2008, 5:53 AM
    • Posts 3

     OracleCommand cm= new OracleCommand("alter table temp add ["+TextBox1.Text+"] varchar2(10)",conn);

    conn.Open();

    cm.ExecuteNonQuery();

    conn.Close(); 

     

    when execute this code one error will fire it;s ORA-00904:invalid identifier

     give me Some solution

     

  • Re: alter table Syntax error

    05-11-2008, 3:31 AM

    I do not believe that oracle uses [ ] characters to delimit a column name.

    Instead, it uses double-quote " marks. 

     

    That said, I advise you NOT to modify your code to include double-quote marks around the column name! 

    By default, oracle will force identifiers to upper case and does not allow spaces in an identifier.  If you put " marks around the column name, it will store it in whatever case your user entered it into.

    However, EVERY SINGLE TIME you want to access that column with a lowercase name, you will have to remember to put the " marks around it.

    Oracle programmers are not used to doing this, which means you will probably have a bunch of errors in your code to find and debug. 

    If this answered your question, be sure to mark it as the answer. That way, everybody after you will know it's the answer also!
  • Re: alter table Syntax error

    05-12-2008, 1:03 AM

     Here is the solution -

    =============================

    OracleCommand cm = new OracleCommand("alter table addressmaster add " + TextBox1.Text + " varchar2(10)", conn);

    conn.Open();
    cm.ExecuteNonQuery();

    conn.Close(); 

    ==============================

    You have to remove [ and ].

    And at my end all insert,update,delete operations on this column are working. 


     

    Hope it helps.

    -Manas

    =======================================
    If this post is useful to you, please mark it as answer.
  • Re: alter table Syntax error

    05-12-2008, 1:47 AM
    • Loading...
    • piyuwithu
    • Joined on 05-11-2008, 5:53 AM
    • Posts 3

     thanks for reply

    i will used ur code but one error come

    it's ORA-01735: invalid ALTER TABLE option


    give some solution

  • Re: alter table Syntax error

    05-12-2008, 1:53 AM

     Can u plz show me full code and the value u r passing in text box.

    Hope it helps.

    -Manas

    =======================================
    If this post is useful to you, please mark it as answer.
  • Re: alter table Syntax error

    05-12-2008, 1:58 AM
    • Loading...
    • piyuwithu
    • Joined on 05-11-2008, 5:53 AM
    • Posts 3

      protected void btnADD_Click(object sender, EventArgs e)
        {
            cminsert = new OracleCommand("insert into domain_master values(domainid_Sequence.NextVal ,'" + txtDomainName.Text + "','" + txtRemarks.Text + "','" + txtTotalPoints.Text + "')", connDom);      
            connDom.Open();
            cminsert.ExecuteNonQuery();
            connDom.Close();
            altertemp();
            txtDomainName.Text = "";
            txtRemarks.Text = "";
            txtTotalPoints.Text = "";        

        }
        protected void altertemp()
        {
                OracleCommand cm = new OracleCommand("alter table temp add " + txtDomainName.Text + " varchar2(70)", connDom);
                connDom.Open();
                cm.ExecuteNonQuery();
                connDom.Close();           
        }

     

    it's give me error ORA-01735: invalid ALTER TABLE option

    and i pass values is string
  • Re: alter table Syntax error

    05-12-2008, 2:55 AM
    Answer

     

    What value are you passing in? Oracle has very particular rules for column names. Max 30 characters in length.  Must be a letter of the alphabet, a digit, or an _ character.  Cannot start with a digit.  Cannot have spaces in it unless you put double quote marks " around it (and that's a darn fool thing to do!)


     

    If this answered your question, be sure to mark it as the answer. That way, everybody after you will know it's the answer also!
Page 1 of 1 (7 items)
Microsoft Communities
Page view counter