×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!
  • Students Click Here

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Undeclared variable error

Undeclared variable error

Undeclared variable error

(OP)
Hello. I am hoping is a simple answer to this because I have not come across it before.
I have run similar code many times but now getting an error.
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[MySQL][ODBC 3.51 Driver][mysqld-5.6.33-log]Undeclared variable: BRACKET16_73

/start1.asp, line 51

CODE -->

SQL = "SELECT * INTO BRACKET16_"&IDT&" FROM BRACKET16_TEMP"
CONN.EXECUTE(SQL) 

When I run response.write it displays perfectly.

CODE -->

SELECT * INTO BRACKET16_73 FROM BRACKET16_TEMP 

Please help me understand what variable could be undeclared or why I am seeing this error.

Thanks,
Penguin

RE: Undeclared variable error

Well, MySQL is telling what it doesn't interpret as a table name: BRACKET16_73

If you want to create a new table look at this:
https://stackoverflow.com/questions/16809393/selec...
or more direct in the MySQL reference:
https://dev.mysql.com/doc/refman/8.0/en/create-tab...

In short, the syntax in MySQL is

CODE

CREATE TABLE BRACKET16_73 AS SELECT * FROM BRACKET16_TEMP; 

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Undeclared variable error

(OP)
I was under the impression that a select into created the table.
Is this not correct??

Thanks,
Penguin

RE: Undeclared variable error

(OP)
I did use your suggestion and it now works perfectly.
Thanks for the help and reply.

Thanks,
Penguin

RE: Undeclared variable error

Well, SQL isn't SQL and within MySQL just look at the reference about SELECT INTO:
https://dev.mysql.com/doc/refman/8.0/en/select-int...

The target is never a new table, it's a variable list, a file (TXT/CSV) or a dumpfile, but not a new table.

And if you have an existing table the command also is vice versa, the overall is an INSERT INTO then, and the SELECT as the source of data still comes afterwards:

CODE

INSERT INTO BRACKET16_73 SELECT * FROM BRACKET16_TEMP; 

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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