To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

SQL Course SQL Course > Ask questions about the lessons on SQL Course 1 and 2. If you have problems > with the interface, please post in the Feedback forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 01-10-2003, 12:06 PM
Rhonen Rhonen is offline
Junior Member
 
Join Date: Jan 2003
Posts: 2
1st time SQL User Needing Help.

I've created 3 tables: Vax_BCTable, PLC_BCTable_IN, PLC_BCTable_OUT

The Vax_BCTable consists of 5 columns:Vax_Dest, Vax_BC1, Vax_BC2, Vax_BC3, Vax_BC4. This Table has random (at this time) information in the cells. This data corresponds to a Destination field and a 4 part Bar Code Number field.

The PLC_BCTable_IN consists of 4 columns: PLC_BC1, PLC_BC2, PLC_BC3, PLC_BC4. This will be my control Table representing a 4 part bar code that was read from a bar code scanner.

The PLC_BCTable_OUT consists of 5 columns: PLC_Dest, PLC_BC1, PLC_BC2, PLC_BC3, PLC_C4. This will be a Table consisting of 1 row that will give the PLC the Bar Code information for verification and the destination on where that particular case with that bar code should go to.

My problem is that I can do a Query and obtain data from the Vax_BCTable that corresponds to the Bar Code Data in the PLC_BCTable_IN Table. However I can not seem to figure out how to place the resultant data into the PLC_BCTable_OUT Table.

I've been playing with SET commands but at this time I do not think its the correct command I'm looking for. I've also tried using the UPDATE command but I can't seem to get my variables to work out correctly. I can use constants fine but I can't seem to be able to place a Queried result field into a varriable name.

This is my existing code:

USE Vax_PLC_Tester
DECLARE @Vax_BC1 int
Select Vax_BC1, Vax_BC2, Vax_BC3, Vax_BC4, Vax_Dest
FROM Vax_BCTable, PLC_BCTable_IN
Where Vax_BC1 = PLC_BCTable_IN.PLC_BC1

SET @Vax_BC1 = 44

UPDATE PLC_BCTable_OUT
SET PLC_Dest = @Vax_BC1
Where PLC_BC1 = 2111

To make this code work (sort of) I had to make the PLC_BCTable_OUT.PLC_BC1 = 2111. This will place a "44" into my PLC_Dest field. What I'd like to do is have my PLC_BCTable_OUT table completly empty and have the results of the Query placed into this table.

Could somone help me with this or let me know what direction I should be going in? At this point I'm a bit confused on what to do next. I'll be digging in the Help files while this is posted in the hopes that I run accross something that is useful.

Thanks in advance.
Reply With Quote
  #2  
Old 01-10-2003, 01:19 PM
skhanal skhanal is offline
Experts
 
Join Date: Nov 2002
Location: New Jersey, USA
Posts: 3,369
Assuming you are using SQL Server

DECLARE @Vax_BC1 int
Select @Vax_BC1 = Vax_BC1
FROM Vax_BCTable, PLC_BCTable_IN
Where Vax_BC1 = PLC_BCTable_IN.PLC_BC1

UPDATE PLC_BCTable_OUT
SET PLC_Dest = @Vax_BC1
Where PLC_BC1 = 2111
Reply With Quote
  #3  
Old 01-10-2003, 02:28 PM
Rhonen Rhonen is offline
Junior Member
 
Join Date: Jan 2003
Posts: 2
Skhanal,

Thank you so much. That got me back on track with what I needed to do for this routine. I have the routine running pretty good now I just need to read up on Stored Procedures and find out how I can trigger this routine to run when the Database notices that the PLC_BCTable_IN Table contains data now.

Thanks again.
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:41 AM.


DatabaseJournal Recent Articles


 » Preparing To Upgrade Access Tables to SQL ...

 » Microsoft Windows PowerShell and SQL Serve...

 » New MySQL Enterprise with Query Analyzer B...

 » Quest Software Strengthens Committment to ...

 » Oracle Unveils New Event-Driven Middleware...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.