Hi there
This was the closest to Sybase I could see....
If I wanted to perform a multiple insert based on values in a table using, say a web app, I'd define a DataTable and bring in the elements using the where query, then iterate though the table using a for - next statement based on the total rows and insert new rows each time the code passed through the for - next loop...
I can build an event that will perform Inserts - but is it possible to carry out multiple inserts as in the first scenario?
Stumped!
2 2631
I'm now part way there... -
-
BEGIN
-
FOR names as curs CURSOR FOR SELECT Pre_Amount FROM Test_Nominal WHERE Pre_Months > 0
-
DO
-
INSERT INTO Test_Nominal (Normal_Credit, Trans_Date) VALUES (Pre_Amount, current date);
-
END FOR;
-
end
-
-
This will now perform the multiple inserts, but it is NOT inserting the value from the select statement....
Getting closer..
OK - got it working now... -
-
CREATE EVENT "Update_Sales_Prepayments"
-
SCHEDULE "Update_Sales_Prepayments_1" START TIME '07:00' ON ( 1 ) START DATE '2008-03-01'
-
HANDLER
-
BEGIN
-
-
FOR names as curs CURSOR FOR
-
-
SELECT Sales_Pre_Amount AS vAmount, Nominal_Code as vNominal FROM Nominal WHERE Sales_Pre_Months > 0
-
-
DO
-
-
INSERT INTO Nominal (Type, Ref, Details, Amount_Net, Ref2, Paid, Nominal_Code, Item_Date, Normal_Debit, Control_Debit, Control_Type) VALUES ('JD', 'System', 'Prepayment Adjustment', vAmount, vNominal, 'y', '5003', current date, vAmount, vAmount, '1103');
-
-
INSERT INTO Nominal (Type, Ref, Details, Amount_Net, Ref2, Paid, Nominal_Code, Item_Date, Normal_Credit, Control_Credit, Control_Type) VALUES ('JC', 'System', 'Prepayment Adjustment', vAmount, '5003', 'y', vNominal, current date, vAmount, vAmount, '1100');
-
-
END FOR;
-
-
UPDATE Nominal SET Sales_Pre_Months = (SELECT Sales_Pre_Months) - 1 WHERE Sales_Pre_Months > 0;
-
-
end
-
-
;
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ashish |
last post by:
Hi,
I am using PHP 4.2.3 and Sybase 12.0
I want to insert records in multiple tables in a database.
I also want to use transactions so that I can rollback in case there
was a problem.
I...
|
by: Burton Figg |
last post by:
I have a SELECT statement which holds a list of times (for adding
appointments to a database):
e.g.
<select name="time" id="time" size="3" multiple>
<option value="00:00">00:00</option>...
|
by: Joe |
last post by:
Hey,
I'm going to give some background on my situation in case anyone can
point out a way around my problem altogether... for the problem
itself, please skip to the bottom of the post. thanks....
|
by: sandip |
last post by:
Hi all,
I am facing a problem while migrating a Sybase SQL query to DB2 UDB.
The query involves left outer joins.
The Sybase query syntax is as follows :
select * from A, B, C
where A.id1...
|
by: Marizel |
last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I
often find myself with a query which I'd like to reuse, but with a
different datasource. These datasources generally have...
|
by: Metal2You |
last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that
accesses a Sybase database back end. We're using Sybase SQL Anywhere
9.0.2.3228. I have installed and registered the Sybase...
|
by: dan |
last post by:
within a loop i am building a sql insert statement to run against my
(programatically created) mdb. it works but it seems unreasonably SLOW!
Sorry, dont have the code here but the jist is very...
|
by: das |
last post by:
Hello all,
I am using the SqlDependency to subscribe to any new inserts into
a database table, I enabled the DB to be borker ready and subscrbed to
Query notifications on the database.
My C#...
|
by: assgar |
last post by:
Hi
I am having problem with my loping.
I don't know if I have chosen the correct approach.
GOAL:
I need to insert into a table event types for a specific date range.
The calendar the event...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |