Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql statement problem

Posted on 1999-07-06
4
Medium Priority
?
142 Views
Last Modified: 2012-05-04
there is error in dbFA.Execute line
what the problem
i'm trying to copy one value of FTLQTY in fa_tmplocation table to another in another FULQTY in another fa_usrlocation table

sql = "SELECT * FROM fa_usrlocation,fa_tmplocation"
Set l_rs = dbFA.OpenRecordset(sql, dbOpenDynaset)
dbFA.Execute "Update fa_usrlocation Set FULQTY = FTLQTY FROM fa_tmplocation WHERE FTLDEFCODE = '" & usr_defcode & "' AND FTLDEFGRP = '" & usr_defgrp & "' AND FULSTRLOC = FTLSTRLOC AND FULEDLOC = FTLEDLOC"

Set wrkODBC = DBEngine.CreateWorkspace("NWorkspace", "admin", "", dbUseODBC)
   wrkODBC.DefaultCursorDriver = dbUseODBCCursor
Set dbFA = wrkODBC.OpenDatabase("IS", _
        dbDriverNoPrompt, False, _
        "ODBC;DATABASE=;UID=a1;PWD=a2;DSN=Oracle")
0
Comment
Question by:kheng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1522393
sql = "SELECT * FROM fa_usrlocation,fa_tmplocation"

should read

sql = "SELECT * FROM fa_usrlocation,fa_tmplocation;"

there must be a semicolon at the end of the SQL statment...

..-=ViKtOr=-..
0
 

Author Comment

by:kheng
ID: 1522394
it's the same
still not working
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1522395
Try putting the table name before the fields:
dbFA.Execute "Update fa_usrlocation Set fa_usrlocation.FULQTY = fa_tmplocation.FTLQTY FROM fa_tmplocation WHERE fa_tmp.locationFTLDEFCODE = '" & usr_defcode & "' AND FTLDEFGRP = '" & usr_defgrp & "' AND FULSTRLOC = FTLSTRLOC AND FULEDLOC = FTLEDLOC"


What exactly are you trying to acheive here? This can go better in a single query I think
0
 
LVL 2

Accepted Solution

by:
DavidMartin earned 200 total points
ID: 1522396
The problem is down to the database not knowing where to get the valuse from, you need to repeat the query for the replacement value.  The query should be similar to the following:

Update fa_usrlocation
Set FULQTY = ( select FTLQTY FROM fa_tmplocation where <repeat where clause> )
WHERE FTLDEFCODE = '" & usr_defcode & "' AND FTLDEFGRP = '" & usr_defgrp & "' AND FULSTRLOC = FTLSTRLOC AND FULEDLOC = FTLEDLOC"

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question