473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How To Create A Procedure That Returns 2 Variables

I want to ensure every serial number in a table has the same amount after each update to avoid a situation where the same serial number holds different values in different rows .


CREATE TRIGGER myupdate (a,b)
AFTER INSERT ON myTable
FOR EACH ROW
BEGIN
SELECT a=lastInsertedAmount
SELECT b=lastInsertedSerialNumber
END

CREATE PROCEDURE myUpdate(a,b)
BEGIN
UPDATE myTable
SET Amount = a
WHERE SerialNumber = b;
END
Jun 10 '14 #1
1 1200
Luuk
1,047 Expert 1GB
If you really want to avoid this, you should put your serial number, and the amount in another table. This way you will only have one record which will hold the amount per serial number.
Jun 10 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: nikolacace | last post by:
Hi, I have a stored procedure (the code is below) that I use to retrieve one value from my database. I tested the code in Query Analyzer, and it works (I get the value I was looking for). However,...
2
by: andres | last post by:
hi all, thanks for everyone for your support! i have a report being built in studio 2005. It calls a stored procedure. The SP runs a query and gets a data set which then loops through to get...
6
by: cmay | last post by:
I am writing some code generation stuff and I am trying to get a script like this to work: IF (something) BEGIN CREATE PROCEDURE Whatever AS SELECT 1 as one END
8
by: peteh | last post by:
Hi All; I have what I hope is a simple environmental problem. I have some SQL that creates a VERY simple procedure. When the create is executed from Quest (from a Windows client) - no problem. As...
2
by: Joe Rattz | last post by:
I am trying to create an XmlReader using XmlReader.Create, but it always returns {None}. I have tried several examples from the web, and Create always returns "{None}". Here is my code: ...
2
by: masri999 | last post by:
I have a requirement in SQL 2005 in Development database 1. Schema dbo owns all objects (tables,views,SPs,UDFs etc) . 2. Only DBA's ( who are database owners ) can create, alter tables ....
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
6
by: yin_n_yang74 | last post by:
I am trying to create a report in Crystal Reports (v 8.5). I have a stored procedure to pull data from two databases and parameters. There are multiple one-to-many relationships and the stored...
3
by: PRAW | last post by:
Hi I am working on a way to Create procedure to insert a set of records for a project in a database.Now there are 11 tasks and they are to be added in each project in a table Task_Name ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
0
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...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.