Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...On your site I feel quite confident that the contacts and feedback will make my life a little less hectic..."

Geography

Where in the world do Tek-Tips members come from?
kcella (Programmer)
8 Nov 07 23:18
I am trying to populate a temp table from a list of values I get back from a Java method call. I'm trying to do a batch insert, but cannot seem to find the right syntax. I tried

SELECT 'constant1' n from table
UNION ALL
SELECT 'constant2' n from table
INTO TEMP a;

The syntax works, but I am inevitably going to exceed the maximum statement length and I cannot use the same clasue again since the temp table already exists. I tried the followig, but I keep getting a syntax error:

INSERT INTO a
SELECT 'constant1' from table
UNION ALL
SELECT 'constant2' from table;

Any ideas? I really do not want to have to generate a separate insert statement for every value in my list.

Also, my table is guaranteed to only ever have one row so I just get back the singlular constant value. Is there a better way to force only one row instead of having to rely on the table only having one row? FIRST 1 is not supported within an INSERT or INTO.
mberni (IS/IT--Management)
27 Nov 07 15:25
hmm,

i tried both of your suggestions and never get an error.

Are you sure you do not suppress any details?

If you select a constant you will have to provide a pseudo-column-name, which i guess should be the "n" in your statement.

please check if you omitted something.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close