Buy Support
Incidents |
If you can't find your answer
in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us
private or confidential information: |
Click Here
|
If you can't
login and post questions or you are having trouble viewing forum posts:
Click Here
|
Callback
Support |
If you live in USA, UK, Canada, Australia or New
Zealand, you can leave us details on your question and request us to call you back and discuss
them with you personally (charges apply). |
Click Here
|
Buy Support
Incidents |
If you can't find your answer
in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us
private or confidential information: |
Click Here
|
|
Error using nested SELECT statement inside INSERT |
Author |
Message |
|
Posted : 2006-07-27 07:06:01 |
I'm trying to create an entry in the Invoice table for a specific customer and job. The problem I'm experiencing is that I can't prepare the INSERT statement to create the invoice without first knowing both the CustomerRefListID and the CustomerRefFullName. Since the FullName is already known to be of the form "Company Name:Job Name", I would like to use a SELECT statement to obtain the CustomerRefListID given just the FullName:
INSERT INTO Invoice (CustomerRefListID, CustomerRefFullName) VALUES ((SELECT ListID FROM Customer WHERE FullName = 'Company Name:Job Name') , 'Company Name:Job Name')
When I try this query in the VB Demo application, it fails, providing the error message "[QODBC] Expected lexical element not found: <identifier>". I've gotten nested SELECT statements to work:
SELECT * from Invoice WHERE CustomerRefListID = (SELECT ListID FROM Customer WHERE FullName = 'Company Name:Job Name')
but I haven't had any luck getting the SELECT statement to work with an INSERT. Is there a way I can set the CustomerRefListID without knowing the exact ListID string, such as with only the known value of CustomerRefFullName? |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-07-27 09:05:35 |
You don't need to state both the CustomerRefListID and the CustomerRefFullName. It's either one, not both. You also cannot insert into the Invoice table unless it's part of a transaction. See: How do I create Invoices? |
|
|
|
|
Posted : 2006-07-28 08:22:24 |
Using only the CustomerRefFullName field works. Thanks, Tom! |
|
|
|
|