Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
How to execute morethan one insert statement in single shot?
Old 08-28-2007, 09:48 AM How to execute morethan one insert statement in single shot?
Junior Talker

Posts: 2
Name: Jegan
Trades: 0
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.
jegankumar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-28-2007, 10:22 AM Re: How to execute morethan one insert statement in single shot?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
db.commandstring = "Insert statement 1;Insert Statement 2"

Never tried it before, but it might work.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 08-28-2007, 10:46 AM Re: How to execute morethan one insert statement in single shot?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-28-2007, 02:12 PM Re: How to execute morethan one insert statement in single shot?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by ADAM Web Design View Post
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 04:09 AM How to execute 2 queries in Single shot?
Junior Talker

Posts: 2
Name: Jegan
Trades: 0
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:
jegankumar is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 06:34 AM Re: How to execute morethan one insert statement in single shot?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
(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?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-29-2007, 04:03 PM Re: How to execute morethan one insert statement in single shot?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Wow, that's cool. I don't know much about Oracle, but its syntax looks easier to work with than Microsoft's.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 08-30-2007, 05:47 AM Re: How to execute morethan one insert statement in single shot?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-30-2007, 05:40 PM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
*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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 08-30-2007, 06:47 PM Re: How to execute morethan one insert statement in single shot?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 08-30-2007, 06:53 PM Re: How to execute morethan one insert statement in single shot?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by dansgalaxy View Post
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 View Post
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 08-30-2007, 07:03 PM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
So is there no way to install ASP on linux?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 08-31-2007, 01:09 PM Re: How to execute morethan one insert statement in single shot?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 08-31-2007, 09:41 PM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-01-2007, 01:25 AM Re: How to execute morethan one insert statement in single shot?
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
Quote:
Originally Posted by dansgalaxy View Post
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...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 09-01-2007, 12:12 PM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-01-2007, 04:54 PM Re: How to execute morethan one insert statement in single shot?
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
You're very close... Think of it this way:
  1. Linux = Windows
  2. Apache = IIS / Internet Information Services
  3. 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.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 09-01-2007, 07:26 PM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-02-2007, 03:47 AM Re: How to execute morethan one insert statement in single shot?
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
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...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 09-02-2007, 09:31 AM Re: How to execute morethan one insert statement in single shot?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to How to execute morethan one insert statement in single shot?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.57861 seconds with 12 queries