Hello,
I am having difficulty finding a way to convert this code into a stored
procedure on SQL Server...Here is the original code - IF Request("updflag" & n) = "Y" then
-
-
-
cmdTemp.CommandText = " SELECT ast.asset_id, " & _
-
" mast.meter_read_due_dt, mast.meter_sort,
-
mast.update_flag " & _
-
" From asset ast, meter_asset mast" & _
-
" WHERE (ast.asset_id='" & Request("assetcode"
-
& n) & "')" & _
-
" AND (ast.asset_id = mast.asset_id)"
-
-
-
cmdTemp.CommandType = adCmdText 'Text Command
-
Set cmdTemp.ActiveConnection = BEConn 'Set database connection
-
objRS.Open cmdTemp, , adOpenKeyset, adLockOptimistic
-
If Not objRS.EOF and Not objRS.BOF then
-
sAssetCD = objRS.Fields("asset_id").value
-
dtMeterDate = objRS.Fields("meter_read_due_dt")
-
objRS.Fields("meter_sort") = Trim(Request("newsort" & n))
-
objRs.Fields("update_flag") = "Y"
-
objRS.Update
Now I have figured out that you can do if exists (select.....)begin <do update> end
But I need records returned to my ASP code as well. Is this possible?
1 8202
Hello,
I am having difficulty finding a way to convert this code into a stored
procedure on SQL Server...Here is the original code - IF Request("updflag" & n) = "Y" then
-
-
-
cmdTemp.CommandText = " SELECT ast.asset_id, " & _
-
" mast.meter_read_due_dt, mast.meter_sort,
-
mast.update_flag " & _
-
" From asset ast, meter_asset mast" & _
-
" WHERE (ast.asset_id='" & Request("assetcode"
-
& n) & "')" & _
-
" AND (ast.asset_id = mast.asset_id)"
-
-
-
cmdTemp.CommandType = adCmdText 'Text Command
-
Set cmdTemp.ActiveConnection = BEConn 'Set database connection
-
objRS.Open cmdTemp, , adOpenKeyset, adLockOptimistic
-
If Not objRS.EOF and Not objRS.BOF then
-
sAssetCD = objRS.Fields("asset_id").value
-
dtMeterDate = objRS.Fields("meter_read_due_dt")
-
objRS.Fields("meter_sort") = Trim(Request("newsort" & n))
-
objRs.Fields("update_flag") = "Y"
-
objRS.Update
Now I have figured out that you can do if exists (select.....)begin <do update> end
But I need records returned to my ASP code as well. Is this possible?
Solved...I think anyway!! - CREATE PROCEDURE dbo.p_update_asset
-
@asset_code varchar(20),
-
@newsort varchar(20),
-
@assetID varchar(20) OUTPUT,
-
@duedate datetime OUTPUT,
-
@update varchar(20) OUTPUT,
-
@sort varchar(20) OUTPUT
-
AS
-
-
DECLARE @rowcount int
-
DECLARE @ID varchar(20)
-
-
SELECT @assetID = ast.asset_id,
-
@duedate = mast.meter_read_due_dt,
-
@sort = mast.meter_sort,
-
@update = mast.update_flag
-
FROM asset ast, meter_asset mast
-
WHERE (ast.asset_id = @asset_code)
-
AND (ast.asset_id = mast.asset_id)
-
-
SET @rowcount = @@rowcount
-
SET @ID = @assetID
-
-
If @rowcount <> 0
-
BEGIN
-
UPDATE meter_asset
-
SET meter_sort = @newsort,
-
update_flag = 'Y'
-
WHERE (@assetID = @asset_code)
-
AND (@assetID = meter_asset.asset_id)
-
END
-
GO
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Harald Servat Gelabert |
last post by:
Dear news-team
I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under FreeBSD).
I'm having problems when updating a column of a table (it updates an extra
column).
As an...
|
by: Smartin |
last post by:
Can anyone help me get this update query right?
The SELECT subquery does select the rows I want to update when taken on
its own.
However when I add the UPDATE piece it finds no rows to update....
|
by: Ed L. |
last post by:
I think I'm seeing table-level lock contention in the following function
when I have many different concurrent callers, each with mutually distinct
values for $1. Is there a way to reimplement...
|
by: abhi81 |
last post by:
Hello All,
I have a table on which I have created a insert,Update and a Delete trigger. All these triggers write a entry to another audit table with the unique key for each table and the timestamp....
|
by: liviusbr |
last post by:
Hello!I need to update the column SALARIU as follows :
If the number of nume_sectie is 1 then it wil remain unchanged
If the number of nume_sectie is 2 then it will be multiplied by 1.01
If the...
|
by: cris1978 |
last post by:
Hi,
I'm trying to do this query to update the results in a table, it's compiling and running without problems, but it's not updating the table, could you guys help me?
Many Thanks!
...
|
by: osward |
last post by:
Hello there,
I am using phpnuke 8.0 to build my website, knowing little on php programing.
I am assembling a module for my member which is basically cut and paste existing code section of...
|
by: magnolia |
last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time...
|
by: oskhan |
last post by:
Hello Everyone,
I have a little different problem and I though anyone might give me any idea that what is going wrong.
I have a view which consists of 3 tables linked by UNION ALL, overall...
|
by: tjc0ol |
last post by:
Hi guys,
Im just wondering that I cannot update my database throught datagrid datalist control, and the only thing works is that I can delete, cancel, edit but when I clicked update link...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |