473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

sql insert error

Hi,
I'm working on an asp where I wanted to do a simple insert using data
from another table, structure is:
Table A has columns - ID, Code, Type
Table B has columns - key, FName, LNAme, DOB, cd, etc...

I need to insert into A, using only the 'key' field from B, rest of the
values in A will be hardcoded in (code='XYZ', TYPE='A')

I tried this:

insert into TableA
values
(select key from TableB where cd='app', 'XYZ', 'A')

but it didn't work, I kept getting an error 'Missing Expression', using
Oracle 9i.

Also tried speicifying the columns

insert into TableA (ID, Code, Type)
values
(select key from TableB where cd='app', 'XYZ', 'A')

same error. Could someone help me with the insert.

Thanks.

Dec 5 '05 #1
3 1573
This isn't the right group for this - you should be asking in an Oracle
group as it has nothing to do with asp. However, your query is wrong for
what you're trying to do. I have minimal experience with Oracle, but would
suggest something like the following:

INSERT INTO TableA (ID, Code, Type)
VALUES
(SELECT key AS ID, 'XYZ' AS Code, 'A' AS Type FROM TableB WHERE cd='app')

If that works, or is at least what you're trying to do, I would suggest
reading up on [Oracle] SQL syntax.

Jevon
"phil2phil" <ph*********@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,
I'm working on an asp where I wanted to do a simple insert using data
from another table, structure is:
Table A has columns - ID, Code, Type
Table B has columns - key, FName, LNAme, DOB, cd, etc...

I need to insert into A, using only the 'key' field from B, rest of the
values in A will be hardcoded in (code='XYZ', TYPE='A')

I tried this:

insert into TableA
values
(select key from TableB where cd='app', 'XYZ', 'A')

but it didn't work, I kept getting an error 'Missing Expression', using
Oracle 9i.

Also tried speicifying the columns

insert into TableA (ID, Code, Type)
values
(select key from TableB where cd='app', 'XYZ', 'A')

same error. Could someone help me with the insert.

Thanks.

Dec 5 '05 #2
IMO try:
INSERT INTO TableA SELECT Key,'XYZ','A' FROM TableB

Values if or constants only...

--
Patrice

"phil2phil" <ph*********@yahoo.com> a écrit dans le message de
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,
I'm working on an asp where I wanted to do a simple insert using data
from another table, structure is:
Table A has columns - ID, Code, Type
Table B has columns - key, FName, LNAme, DOB, cd, etc...

I need to insert into A, using only the 'key' field from B, rest of the
values in A will be hardcoded in (code='XYZ', TYPE='A')

I tried this:

insert into TableA
values
(select key from TableB where cd='app', 'XYZ', 'A')

but it didn't work, I kept getting an error 'Missing Expression', using
Oracle 9i.

Also tried speicifying the columns

insert into TableA (ID, Code, Type)
values
(select key from TableB where cd='app', 'XYZ', 'A')

same error. Could someone help me with the insert.

Thanks.

Dec 5 '05 #3
Thanks to both for the help, i tried the below one first and i worked,
thanks again!

Patrice wrote:
IMO try:
INSERT INTO TableA SELECT Key,'XYZ','A' FROM TableB

Values if or constants only...

--
Patrice

"phil2phil" <ph*********@yahoo.com> a écrit dans le message de
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,
I'm working on an asp where I wanted to do a simple insert using data
from another table, structure is:
Table A has columns - ID, Code, Type
Table B has columns - key, FName, LNAme, DOB, cd, etc...

I need to insert into A, using only the 'key' field from B, rest of the
values in A will be hardcoded in (code='XYZ', TYPE='A')

I tried this:

insert into TableA
values
(select key from TableB where cd='app', 'XYZ', 'A')

but it didn't work, I kept getting an error 'Missing Expression', using
Oracle 9i.

Also tried speicifying the columns

insert into TableA (ID, Code, Type)
values
(select key from TableB where cd='app', 'XYZ', 'A')

same error. Could someone help me with the insert.

Thanks.


Dec 5 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
6
by: harborboy76 | last post by:
Hi, I am trying to insert a large number of rows into a table inside a SPL. But every time, I run the SPL, the table is locked because of the INSERT. When I tried to issue a COMMIT, right after...
8
by: 73blazer | last post by:
Hello, I'm looking for a way to make some of my insert templates more readable by placing comments in between the values. I cannot seem to find a way to do this with DB2, is there a way? I'm...
3
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The...
3
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using...
9
by: anachronic_individual | last post by:
Hi all, Is there a standard library function to insert an array of characters at a particular point in a text stream without overwriting the existing content, such that the following data in...
2
by: technocraze | last post by:
Hi guys, I have encountered this error when updating the values to the MS Acess table. Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.