Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

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

Forum : Correlated subqueries in UPDATEsSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 Correlated subqueries in UPDATEs 
 Author   Message 
  spendleton 
  
 Group: Members 
 Posts: 2 
 Joined: 2006-06-13 
 Profile
 Posted : 2006-06-13 10:26:24
I would like to update the salesrep field in my existing invoices. I would like to use the salesrep value that is stored in the Customer file. I would normally to this in SQL using a correlated sub query. When I run the following query: update Invoice set SalesReprefFullName = (select SalesRepRefFullName from Customer where Invoice.CustomerrefFullName = Company.FullName), I get the following error: [QODBC] Expected lexical element not found:  

 
Stuart 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-06-13 10:59:19

Sorry, even your nested SELECT statement is invalid. You always need to reference the TxnID for all update operations you do using QODBC. For example for Invoices the update operation would look like this:

update Invoice set SalesRepRefListID='10000-1197757777' where Invoice.TxnID='2B55-1071523067'

Where:
SalesRepRefListID is the List ID for a existing Sales Representative from the SalesRep table.
TxnID is the Transaction ID for the existing Invoice from the Invoice table.

 

  Top 
  spendleton 
  
 Group: Members 
 Posts: 2 
 Joined: 2006-06-13 
 Profile
 Posted : 2006-06-13 11:04:17
Ok, I see that, almost. According to your docs, SalesRepRefListID is a non-modifiable field - but SalesReprefFullName can be modified But how would I update ALL of my inovoices to show the salesreps that have been assigned to each customer? 

 
Stuart 
 
  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-06-13 11:27:12
This can't be done in a single SQL statement. It will require a program loop that reads each invoice line, checks if there's a SalesRepListID or not and if not, looks up the customer table, finds the Customer.SalesRepListID and builds the update statement that's executed. 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to