• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79261
377
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic