Click here to Skip to main content
15,894,546 members
Home / Discussions / Database
   

Database

 
GeneralRe: parameter with the In function Pin
jschell28-Oct-10 8:42
jschell28-Oct-10 8:42 
AnswerRe: parameter with the In function Pin
Goutam Patra27-Oct-10 1:47
professionalGoutam Patra27-Oct-10 1:47 
GeneralRe: parameter with the In function Pin
Tamimi - Code27-Oct-10 2:42
Tamimi - Code27-Oct-10 2:42 
QuestionOracle to SQL porting [modified] Pin
Arudya26-Oct-10 17:54
Arudya26-Oct-10 17:54 
AnswerRe: Oracle to SQL porting Pin
Chris Meech27-Oct-10 3:14
Chris Meech27-Oct-10 3:14 
QuestionInserting in Multi table With one Store Procedure Pin
future383926-Oct-10 12:29
future383926-Oct-10 12:29 
AnswerRe: Inserting in Multi table With one Store Procedure Pin
PIEBALDconsult26-Oct-10 15:07
mvePIEBALDconsult26-Oct-10 15:07 
AnswerRe: Inserting in Multi table With one Store Procedure Pin
Mycroft Holmes26-Oct-10 20:13
professionalMycroft Holmes26-Oct-10 20:13 
future3839 wrote:
is there any approach to insert data with writing just one SP


This is a basic aspect of an SP

Receive values via variables in the procedure declaration

CREATE PROC StoreDumy
-- Declare
	@Var1 VARCHAR(100),@Var2 VARCHAR(100),@Var3 VARCHAR(100),@Var4 VARCHAR(100),
	@Var5 VARCHAR(100),@Var6 VARCHAR(100),@Var7 VARCHAR(100)



Insert the variables in the tables required. You may want to wrap the inserts in a transaction so that if 1 insert fails all inserts are rolled back and you are not left with orphaned data

As

DECLARE @ID int

begin TRAN	
	INSERT dbo.Country (Fld1, Fld2)
	VALUES(@Var1,	@Var2)
	
	SET @ID = SCOPE_IDENTITY()
	
	INSERT dbo.State (CtryID, Fld1, Fld2)
	VALUES(@ID, @Var3,	@Var4)
	
	SET @ID = SCOPE_IDENTITY()
	
	INSERT dbo.Town (StateID, Fld1, Fld2)
	VALUES(@ID, @Var5,	@Var6)	
	
COMMIT TRAN

Never underestimate the power of human stupidity
RAH

QuestionOfficial PostgreSQL forum Pin
Jassim Rahma26-Oct-10 4:51
Jassim Rahma26-Oct-10 4:51 
AnswerRe: Official PostgreSQL forum Pin
Mycroft Holmes26-Oct-10 12:24
professionalMycroft Holmes26-Oct-10 12:24 
GeneralRe: Official PostgreSQL forum Pin
Corporal Agarn27-Oct-10 0:56
professionalCorporal Agarn27-Oct-10 0:56 
GeneralRe: Official PostgreSQL forum Pin
Mycroft Holmes27-Oct-10 1:13
professionalMycroft Holmes27-Oct-10 1:13 
Questiondeploy PostgreSQL database Pin
Jassim Rahma26-Oct-10 3:56
Jassim Rahma26-Oct-10 3:56 
Questioncreate script for entire database in PostgreSQL Pin
Jassim Rahma26-Oct-10 3:55
Jassim Rahma26-Oct-10 3:55 
AnswerRe: create script for entire database in PostgreSQL Pin
Jules VDV26-Oct-10 4:31
Jules VDV26-Oct-10 4:31 
QuestionSQL Server CE : How to create a database from C++ with ADO Pin
Leif Goodwin26-Oct-10 2:11
Leif Goodwin26-Oct-10 2:11 
AnswerRe: SQL Server CE : How to create a database from C++ with ADO => SOLVED Pin
Leif Goodwin26-Oct-10 3:33
Leif Goodwin26-Oct-10 3:33 
QuestionField ordering in a table Pin
john john mackey25-Oct-10 7:10
john john mackey25-Oct-10 7:10 
AnswerRe: Field ordering in a table Pin
J4amieC25-Oct-10 21:21
J4amieC25-Oct-10 21:21 
AnswerRe: Field ordering in a table Pin
i.j.russell25-Oct-10 23:32
i.j.russell25-Oct-10 23:32 
AnswerRe: Field ordering in a table Pin
Mycroft Holmes26-Oct-10 3:04
professionalMycroft Holmes26-Oct-10 3:04 
GeneralRe: Field ordering in a table Pin
Gerben Jongerius26-Oct-10 3:41
Gerben Jongerius26-Oct-10 3:41 
QuestionSQL Server Trigger [modified] Pin
Jay Royall25-Oct-10 5:03
Jay Royall25-Oct-10 5:03 
AnswerRe: SQL Server Trigger Pin
Chris Meech25-Oct-10 6:13
Chris Meech25-Oct-10 6:13 
GeneralRe: SQL Server Trigger Pin
Jay Royall25-Oct-10 22:20
Jay Royall25-Oct-10 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.