|
Home > Archive > SQL Anywhere database > August 2005 > Stored procedure to update a table
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Stored procedure to update a table
|
|
|
| I am trying to write a stored procedure to update a table from a condition
of a column on another table.
I have two tables Sales and Bt_Sales
I have a trigger that passes in three variables (v_sales_id, v_course_no,
v_customer_code)
Sales table(sales_id, customer_code,delete
d, .....)
Bt_Sales( bt_id, course_no[fk], sales_id[fk], deleted....)
I need to update the column Bt_Sales.deleted where course_no = v_course_no
AND for all sales_id that belong to a certain customer (v_customer_code).
Any help would be appreciated as it is 4am here and my brain cant function
anymore..
Thanks
ASA 9.02
| |
| Donna Osburn 2005-08-18, 8:23 pm |
| Try this
Update BT_Sales
Set deleted = ??
FROM BT_Sales
WHERE BT_Sales.course_no = Sales.course_no AND
Sales.v_customer_code = ??
> I am trying to write a stored procedure to update a table
> from a condition of a column on another table.
>
> I have two tables Sales and Bt_Sales
> I have a trigger that passes in three variables
> (v_sales_id, v_course_no, v_customer_code)
>
> Sales table(sales_id, customer_code,delete
d, .....)
> Bt_Sales( bt_id, course_no[fk], sales_id[fk], deleted....)
>
> I need to update the column Bt_Sales.deleted where
> course_no = v_course_no AND for all sales_id that belong
> to a certain customer (v_customer_code).
>
> Any help would be appreciated as it is 4am here and my
> brain cant function anymore..
>
> Thanks
> ASA 9.02
>
>
| |
|
| Yeah already tried something like this but get a correlation name not found
error.
<Donna Osburn> wrote in message news:4304f95f.4a45.1681692777@sybase.com...[color=darkred]
> Try this
> Update BT_Sales
> Set deleted = ??
> FROM BT_Sales
> WHERE BT_Sales.course_no = Sales.course_no AND
> Sales.v_customer_code = ??
>
| |
| Greg Fenton 2005-08-19, 3:23 am |
| MJN wrote:
> Yeah already tried something like this but get a correlation name not found
> error.
The FROM clause needs to reference both BT_Sales and Sales:
UPDATE BT_Sales
SET deleted = ??
FROM BT_Sales, Sales
WHERE BT_Sales.course_no = Sales.course_no
AND Sales.v_customer_code = ??
Hope this helps,
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
|
|
|
|
|