|
How to execute morethan one insert statement in single shot?
08-28-2007, 09:48 AM
|
How to execute morethan one insert statement in single shot?
|
Posts: 2
Name: Jegan
|
hi,
Can anyone tell me, that how to execute morethan one INSERT query in a single shot?
I mean to ask that, i want to execute two INSERT statement, currently im doing that one as follow;
db.commandstring = "INSERT statement 1";
db.ExecuteNonQuery();
db.commandstring = "INSERT statement 2";
db.ExecuteNonQuery();
But now i want to execute the both statement under single ExecuteNonQuery();
Is there any chance to do like that? Can i concatenate Both INSERT statement in Single "CommandString" and execute ( db.commandString="INSERT statement1; INSERT statement2"; db.ExecuteNonQuery());
Give me a suggestion plz.
|
|
|
|
08-28-2007, 10:22 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
db.commandstring = "Insert statement 1;Insert Statement 2"
Never tried it before, but it might work.
|
|
|
|
08-28-2007, 10:46 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
|
if it is into MySQL ver >3.22
You can do
Code:
INSERT INTO tablename (column1,column2)
VALUES
('col1val','col2val'),
('col1val','col2val'),
('col1val','col2val'),
('col1val','col2val'),
('col1val','col2val')
;
For MS SQL it would be
Code:
INSERT INTO tablename (column1,column2)
SELECT 'col1val','col2val'
UNION ALL SELECT 'col1val','col2val'
UNION ALL SELECT 'col1val','col2val'
UNION ALL SELECT 'col1val','col2val'
UNION ALL SELECT 'col1val','col2val'
;
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-28-2007, 02:12 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,662
Name: John Alexander
|
Quote:
Originally Posted by ADAM Web Design
db.commandstring = "Insert statement 1;Insert Statement 2"
Never tried it before, but it might work.
|
In SQL Server ( any version) it works fine. In MS Access ( any version) it's not allowed.
|
|
|
|
08-29-2007, 04:09 AM
|
How to execute 2 queries in Single shot?
|
Posts: 2
Name: Jegan
|
Actually im trying to execute the following queries in single shot:
INSERT INTO CNSMR_SITE_ACTIVITY(CNSMR_ACTIVITY_ID, CNSMR_ID,ATTEND_YN, FEES_PAID_YN, TRANS_DT, TRANS_OPR, SITE_CALENDAR_ID, REGISTRATION_STATUS ) VALUES(1639,'28860','N','Y',to_date('08/29/2007','MM/dd/yyyy'),'1010201','4369','R')
INSERT INTO CNSMR_TRANSACTION(TRANSACTION_ID, ACTIVITY_ID, PREVIOUS_BALANCE, TRANSACTION_AMT,TRANSACTON_TYPE,CURRENT_BALANCE,CO MMENTS,OPERATOR_ID,TRANS_OPR,TRANS_DT,CNSMR_ACTIVI TY_ID,ACCOUNT_ID) VALUES (TRANSACTION_ID.NextVal,401,-150,4,'CR',-154,'CR For Registeration of Stich Hours on 8/29/2007', '' , '1010201', to_date('08/29/2007','MM/dd/yyyy'),1639,124)
For that i used ';' to seperate each query and 'Environment.NewLine' in C#.Net. But it showing error like "ORA-00933: SQL command not properly ended" IM using ORACLE 9. plz give me a solution:
|
|
|
|
08-29-2007, 06:34 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
|
(merged both threads so it makes sense and moved to database forum)
Oracle9i supports the INSERT ALL syntax
so
Code:
INSERT ALL
INTO CNSMR_SITE_ACTIVITY(CNSMR_ACTIVITY_ID, CNSMR_ID,ATTEND_YN, FEES_PAID_YN, TRANS_DT, TRANS_OPR, SITE_CALENDAR_ID, REGISTRATION_STATUS ) VALUES(1639,'28860','N','Y',to_date('08/29/2007','MM/dd/yyyy'),'1010201','4369','R')
INTO CNSMR_TRANSACTION(TRANSACTION_ID, ACTIVITY_ID, PREVIOUS_BALANCE, TRANSACTION_AMT,TRANSACTON_TYPE,CURRENT_BALANCE,CO MMENTS,OPERATOR_ID,TRANS_OPR,TRANS_DT,CNSMR_ACTIVI TY_ID,ACCOUNT_ID) VALUES (TRANSACTION_ID.NextVal,401,-150,4,'CR',-154,'CR For Registeration of Stich Hours on 8/29/2007', '' , '1010201', to_date('08/29/2007','MM/dd/yyyy'),1639,124)
should work
other than that it will have to be two separate transactions
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-29-2007, 04:03 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,662
Name: John Alexander
|
Wow, that's cool. I don't know much about Oracle, but its syntax looks easier to work with than Microsoft's.
|
|
|
|
08-30-2007, 05:47 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
|
It can be quite daunting to look at the enormous variations of syntax and commands that Oracle supports when you first start off with it.
I must admit I haven't kept up to date with it, Ver 8 is the latest I have on my test servers as the price is a bit daunting (GBP 2,000+ for the standard edition) when no current clients actually use it 
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-30-2007, 05:40 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
*Coughs up what i was eating*
Okay can someone please explain this to me because i really dont get it.
with the web as (i would think) everyone on here knows u can get everythign to run a server for free.
we have Apache MySQL and PHP
so why are people still paying for ASP and Oracle and all that when u have the free and perfectly usable versions?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
08-30-2007, 06:47 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
|
ASP is free. It's just native to the Windows platform.
That, and it does certain things (Access database integration, for example) that its contemporaries cannot.
|
|
|
|
08-30-2007, 06:53 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,662
Name: John Alexander
|
Quote:
Originally Posted by dansgalaxy
Okay can someone please explain this to me because i really dont get it.
with the web as (i would think) everyone on here knows u can get everythign to run a server for free.
|
Yeah, but with however many thousand years of history we have with money, everyone on here knows you get what you pay for.
Quote:
Originally Posted by dansgalaxy
we have Apache MySQL and PHP so why are people still paying for ASP and Oracle and all that when u have the free and perfectly usable versions?
|
Because when you put Oracle and MySQL side by side, it's like a Formula One race car and a donkey with three legs.
|
|
|
|
08-30-2007, 07:03 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
So is there no way to install ASP on linux?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
08-31-2007, 01:09 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 5,662
Name: John Alexander
|
ASP is a framework, not a program in and of itself. You can't actually install ASP on Windows. It's part of IIS, which only runs on some Windows versions.
If you can run Windows on Linux, and before you laugh Mac changed their whole architecture so they could run real Windows on a Mac, then it's fairly easy to run ASP on linux. Just go to the control panel, add/remove programs, Windows components, and install IIS. Then make sure the web service is running, set up your web site or application, and start calling it.
You can run ASP.NET on linux using Project Mono, if your code doesn't make any PInvoke calls.
|
|
|
|
08-31-2007, 09:41 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
eeeer ok..
so can u not install the asp engine or parser like PHP??
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
09-01-2007, 01:25 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
|
Quote:
Originally Posted by dansgalaxy
so can u not install the asp engine or parser like PHP??
|
The asp engine is part of Microsoft's web server application. You can install that; asp is a component of IIS. The company I work for added a dozen new web servers to their cluster ... of course new machines need a way to get the software on them.
But it's Windows software. Plenty of web servers out there around the internet run Windows. A small share overall, but the point is the web server is a box running Windows, and using IIS to handle requests for pages from the outside world. That could be for pure, static html, for asp, for asp.net using C++ or java...
|
|
|
|
09-01-2007, 12:12 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
ok sorry im probably being quite (is ammeturish the word? :\)
so is (like alot of MS stuf) basically lik unlike the *AMP set ups where they are like sepertae softwares Apache, PHP is ISS like the whole thing with ASP and a http software?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
09-01-2007, 04:54 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
|
You're very close... Think of it this way: - Linux = Windows
- Apache = IIS / Internet Information Services
- PHP = ASP or ASP.NET
Equals obviously doesn't mean is the same as, but that's how the Windows environment compares to the LAMP enviro. In both cases it's a stack, or a tree with the O/S at the root node, then software you can install onto that operating system that does the http stuff, and finally a scripting framework that gets run inside the web server application to let you do what you want.
I've worked in PHP, but never installed the whole infrastructure. For example, I did some hacking in wordpress to get my blog to do a few things that weren't possible outside the box, but my site is hosted on a server that's already set up to run PHP, and I used Fantastico to install WP. All I've really done is supply the content, and hack the template to use some different PHP code.
That said, I don't think you can install PHP without Apache? It would be the same situation in Windows; you can't have ASP without IIS.
|
|
|
|
09-01-2007, 07:26 PM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
ok, so could u install the ASP/ASP.NET on to a Apache/PHP/windows eviorment?
Or have PHP/ASP/ISS/WINDOWS ??
know what i mean?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
09-02-2007, 03:47 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
|
You can run PHP and Apache on Windows. I forget the software that does this for you, but it's possible. You can also run MySQL for Windows; I've done this. But you can't go the other way around; IIS, which hosts ASP, doesn't run on Linux.
Project Mono is an open source group building the software necessary to take Microsoft's .net framework and make it run on Linux and Mac O/S X. All of the screen shots are desktop software, but there's no reason you couldn't use .net code - C#, VB, Java - to replace PHP if they make that a priority to code...
|
|
|
|
09-02-2007, 09:31 AM
|
Re: How to execute morethan one insert statement in single shot?
|
Posts: 6,522
Name: Dan
Location: Swindon
|
i was thinking more could you install PHP to work with ISS like you can with Apache or does PHP and Apache, and ASP and ISS have to go with each other?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
|
« Reply to How to execute morethan one insert statement in single shot?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|