Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert or Update statement for a query needed

Status
Not open for further replies.

3112005

Technical User
Nov 28, 2005
58
US
Is there a way to make this work for a query...

INSERT INTO table_name (column1,column2,column3)
values(xxx,xxx,xxx)
WHERE field = 'x'

I already have a string of column names and corresponding values and I need them inserted into an existing record.

I know this is normally an UPDATE statement, but my code containing my column string and value string are already in several pages.
 
In order to Update an exsiting row, you need to use an Update statment.

Jim
 
Your right it's an UPDATE Statement that I need, but I don't think I can use a basic one.

What I've got to work with is a website that was built before my time that works like an online work flow for our HR dept.

First page: Enter name, supervisor, employee number
Hit Save & Continue: Data added to table USERS
Second page: Auto-populate previous entries to top of page. Then Enter phone, fax, email
Hit Save & Continue: Data added to table USERS and an Email is sent out containing the information to the appropriate dept.

Now what's happend is my company wants to add new data fields for these pages. The problem is that data is going to be things like salary that they don't want to save it, just pass it in an email and then remove it from the table.

So what I've done is create a new table called PAN that will stores the info. that is going to be removed. What I don't know how to do is add these new fields to PAN at the same time I am updating fields to USERS.

The current code is very complex and lengthy, so I was hoping to be able to create a few lines of code that would work for a query string like...
Update fields where employee number is ""

The employee number will be in both tables PAN and USERS.
 
Yep, I want to update both tables.
 
Why not create a trigger for inserted/updated for USERS table and in it you can insert records in PAN table?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Sounds like a good idea. I've never used that before, but I'll take a look and see if I can get it to work.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top