Two Laptop Bag*
The moose likes JDBC and the fly likes WITHOUT STORED PROCEDUREs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "WITHOUT STORED PROCEDUREs" Watch "WITHOUT STORED PROCEDUREs" New topic
Author

WITHOUT STORED PROCEDUREs

Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
Hi,

I am using a stored Procedure in SQL server. Area is a Table. It has two coloumns Area_Name and Area_Code(Primary Key, AutoGenerated keys). I am inserting "name of the Area" as . If the Similar Area name is pre existing in the table the value will never get inserted and the Store Procedure will return 1, else the Area Name will get Inserted and the Procedure will return 0.

I handle these data returned data and Put the validation codes in the Front End.

But I will use SELECT SQL STATEMENTs as I am migrating the server form SQL server to MS ACCESS. How should I implement similar logic in SELECT SQL statements.

The stored Procedure is in SQL SERVER.


Thanks & Regards

Prithiraj Sen Gupta
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


But I will use SELECT SQL STATEMENTs as I am migrating the server form SQL server to MS ACCESS.

My sympathies.

Your logic looks pretty simple. I'd suggest just moving it into you application itself. You can use a select statement to find out if your area_name is already there, and a simple conditional to control what happens thereafter.

One thing that springs to mind is this procedure looks like it is manually enforcing a unique constraint. If your data model requires this, why not just define a unique constraint on area_name?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Prithiraj Sen Gupta
Ranch Hand

Joined: Sep 13, 2006
Posts: 92
Thanks Paul,

I am successful in connecting my application with Access Database and translated all the stored procedure in ad-hoc way. That was a very easy way. But one thing I wanted to share that, in stored procedure of SQL server I have used "INNER JOIN" but in ad-hoc I used "JOIN". The SQL server did the same for both the type of statements. I hope my-sql and Oracle will do the same. But in MS Access The "JOIN" statements do not work as it shows ERROR in FROM Clause. But it worked well with INNER JOIN. Not only this Access have a different way of joining three tables.


Thanks & Regards
Prithiraj Sen Gupta
[ May 21, 2007: Message edited by: Prithiraj Sen Gupta ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WITHOUT STORED PROCEDUREs