Results 1 to 3 of 3

Thread: 1st time SQL User Needing Help.

  1. #1
    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.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,922
    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

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •