• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Sybase database - insert statement problems

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table(CODE_LOOKUP) with 3 columns(CL_ID,CL_RC,CL_DESC)

i wanted to insert a new column taking the max(id)+1

This is the sql query i am trying to insert

INSERT INTO CODE_LOOKUP(CL_ID,CL_RC,CL_DESC)
values(max(CL_ID)+1, 'Region0', 'Region0');

I couldnot execute the Query..it throws me out saying
com.sybase.jdbc2.jdbc.SybSQLException: The name 'CL_ID' is illegal in this context. Only constants, constant expressions, or variables allowed here. Column names are illegal.

what is the correct way or Is there any other way i can insert the column into the database...
 
Marshal
Posts: 80768
488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is too late to put an autoincrement on CL_ID, I presume?

How about a stored procedure which sets a variable to the value from max(CL_ID), then puts the value (+1) back in the column later?

Anybody else got any ideas?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic