Solved

Merge

Posted on 2006-07-05
3
401 Views
Last Modified: 2013-12-26
I am trying to merge 2 parts.
when I use it just as SQL script it works, but I recently made it through the PowerBuilder Window.
Could someone tell me what am I doing wrong?
Sometime it works, sometimes doesn't.
May be I miss something.
Thanks for your help in advance.

//With an embedded SQL

//cb_merge.Clicked()
//===================

Long ls_oid_to_delete, ls_oid_to_keep, to_item_oid, from_item_oid
String  temp_keep, temp_delete, from_sn, to_sn
int inv_status_oid, to_aircraft_oid, to_city_oid, to_status_oid
Datetime inv_move_date
//Get oid's from SingleLineEdit control

//temp_keep = sle_1.text
//temp_delete   = sle_2.text

ls_oid_to_keep = long(sle_1.text)
ls_oid_to_delete = long(sle_2.text)

to_city_oid = dw_1.getItemNumber(1, 'city_oid')
to_aircraft_oid = dw_2.getItemNumber(1, 'aircraft_oid')
to_status_oid = dw_3.getItemNumber(1, 'status_oid')
// insert oids as necessary -
// system will merge the two records into the "oid_to_keep"
// and purge the "oid_to_delete"

Select Serial_Number, item_oid into :from_sn, :from_item_oid from rotable_inventory, item_Master where rotable_inventory.item_oid = item_master.oid and rotable_inventory.oid = :ls_oid_to_delete;

Select Serial_Number, item_oid into :to_sn, :to_item_oid from rotable_inventory, item_master where rotable_inventory.item_oid = item_master.oid and rotable_inventory.oid = :ls_oid_to_keep;

Select Max(inv_move_date) into :inv_move_date from inv_move_log where inv_oid = :ls_oid_to_keep;

update inv_move_log
      set inv_oid = :ls_oid_to_keep,
            upd_timestamp = getdate()
      where inv_oid = :ls_oid_to_delete;

update work_order_data
      set inv_oid = :ls_oid_to_keep,
            upd_timestamp = getdate()
      where inv_oid = :ls_oid_to_delete;

update wo_inv_action
      set inv_oid = :ls_oid_to_keep,
            upd_timestamp = getdate()
      where inv_oid = :ls_oid_to_delete;

update mc_rotable
      set inv_oid = :ls_oid_to_keep,
            upd_timestamp = getdate()
      where inv_oid = :ls_oid_to_delete;

update purchase_order_data
      set inv_oid = :ls_oid_to_keep,
            upd_timestamp = getdate()
      where inv_oid = :ls_oid_to_delete;

update rotable_inventory
      set status_oid = 2428,
      upd_timestamp = getdate()
      where oid = :ls_oid_to_delete;

delete from rotable_inventory where oid = :ls_oid_to_delete;

Insert into Inv_Move_log (inv_oid, to_inv_status_oid, to_on_aircraft_oid,to_city_oid,  create_Date, inv_move_date, From_serial_no, To_serial_no, from_item_oid, to_item_oid, Updated_by_sym, upd_timestamp)
                                     Values(:ls_oid_to_keep, :to_status_oid, :to_aircraft_oid, :to_city_oid, getutcdate(), :inv_move_date, :from_sn, :to_sn, :from_item_oid, :to_item_oid, :g_login_id, getutcdate());
MessageBox("Merge","Merge is Complete. Database has been updated.")
Close(w_inventory_merge)
0
Comment
Question by:Namik48075
[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
3 Comments
 

Author Comment

by:Namik48075
ID: 17042742
I have changed it to be done with Stored procedure.
Now its giving me an error message

//With an embedded SQL

//cb_merge.Clicked()
//===================
Long ls_oid_to_delete, ls_oid_to_keep, to_item_oid, from_item_oid
int  to_aircraft_oid, to_city_oid, to_status_oid


//temp_keep = sle_1.text
//temp_delete   = sle_2.text

ls_oid_to_keep = long(sle_1.text)
ls_oid_to_delete = long(sle_2.text)

to_city_oid = dw_1.getItemNumber(1, 'city_oid')
to_aircraft_oid = dw_2.getItemNumber(1, 'aircraft_oid')
to_status_oid = dw_3.getItemNumber(1, 'status_oid')

//IF SQLCA.SQLCode <> 0 THEN
//   MessageBox ( "Error", "DECLARE failed" )
//   RETURN
//END IF;
DECLARE test_inventory_merge procedure for sp_inventory_merge(:ls_oid_to_keep, :ls_oid_to_delete, :to_aircraft_oid, :to_status_oid, :to_city_oid) using SQLCA;

EXECUTE test_inventory_merge;
//IF  ( SQLCA.SQLCode <> 0   ) &
//and ( SQLCA.SQLCode <> 100 ) THEN
//   MessageBox ( "Error", "EXECUTE failed" )
//   RETURN
//END IF

MessageBox("Merge","Merge is Complete. Database has been updated.")


Compile Error:

Database C0038: Line 1: Incorrect syntax near '0';

Please help.

Thanks  a lot.
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 85 total points
ID: 17079107
Hi,

I think it looks like database related problem....

1) check which driver you are using for connectivity.
2) is your stored procedure compiled and valid ?

in your code first comment stored procedure declaration and execution part and try to compile. If it compiles then it's sure that problem is in declaration and calling stored procedure..

Regards,
Sandeep
0
 
LVL 1

Expert Comment

by:sandhiyaa
ID: 17191601
Did you executed the procedure seperately at the backend?
Regards,
Sandhiya
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

740 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