473,385 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing Parameters to SQL Stored Procedures

I am calling a SQL Stored Procedure, which has 10 parameters.
The SP has defaults set on the last 9 of these params.
The 1st one is an output param.

I want to get the result for the output param. I am able to do this without a problem.

I only need to pass in 2 values. The 4th and the 7th parameter. The rest I want to use the defaults defined in the stored procedure.

I can do this in SQL analyzer and in vb 6.0.
How can I do this in Java, using JDBC driver - default for SQL 2005.

Any help is appreciated.
Sep 8 '06 #1
4 6462
I am calling a SQL Stored Procedure, which has 10 parameters.
The SP has defaults set on the last 9 of these params.
The 1st one is an output param.

I want to get the result for the output param. I am able to do this without a problem.

I only need to pass in 2 values. The 4th and the 7th parameter. The rest I want to use the defaults defined in the stored procedure.

I can do this in SQL analyzer and in vb 6.0.
How can I do this in Java, using JDBC driver - default for SQL 2005.

Any help is appreciated.
You can find on the internet. Many article...
Sep 9 '06 #2
Firstly pass a space if the parameter is a string and a 0 if the parameter is a integer/float for all the other parameters except the 4th and 7th ones.
Secondly you will have to register the out parameter first, only then you will be able to retrieve a value out of it when the procedure completes its process.
Sep 11 '06 #3
You can find on the internet. Many article...

Thank you for the response.
Unfortuntately, the only info I could find on the internet indicated that default values for the parameters could not be acheived easily.
One site indicated that it could be done by creating another stored procedure that I could use to return the default params of the stored procedure I wanted to call, and use the default values returned in that stored proc. This sounded senseless to me. Other sites stated that it wasn't possible to do directly.

However, a coworker was able to demonstrate that I could, indeed, use default params using the CallableStatement method.

Where you would normally use "?" in the param decl, you use the same syntax that T-SQL would use - which is the keyword "default". Also, you must use the index to denote the parameters instead of using the actual name of the param.

Thanks again!
Sep 19 '06 #4
Firstly pass a space if the parameter is a string and a 0 if the parameter is a integer/float for all the other parameters except the 4th and 7th ones.
Secondly you will have to register the out parameter first, only then you will be able to retrieve a value out of it when the procedure completes its process.

Thanks for your response. I appreciated the help.

I found an alternative method to do what I needed to do prior to this posting.
I am going to try your method - it can never hurt to have multiple ways to accomplish a task.

Using the callablestatement method, jdbc driver:

Where you would normally use "?" in the param decl, you use the same syntax that T-SQL would use - which is the keyword "default". Also, you must use the index to denote the parameters instead of using the actual name of the param.

Thanks again for your help.
Sep 19 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Hursh | last post by:
Hi, I have written some stored procedures in SQL and these procedures return some value. I want these values to be captured by the ASP code. I am able to access the tables using ADO(...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
1
by: zlatko | last post by:
I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are stored procedures with input parameters by which they filter...
2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
1
by: tdlogger | last post by:
Help! I’m running ado.net using sql7 with service pack 4. I’m trying to use stored procedures. When I try passing varchar type parameters it comes back with 0 transactions. If I pass int...
1
by: Roman Prigozhin | last post by:
Hi all, I have one stored procedure where I defined 3 temporary tables, which i return back to java. I want to have 3 separate sub procedures which would go after the data and fill out these...
6
by: dharmadam | last post by:
Is it possible to pass a column name or the order of the column name in the DB2 table table function. For example, I want to update the address of a person by passing one of the address column name...
3
by: Zlatko | last post by:
A question concerning Access Project with SQL Server: I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are...
9
by: laurenq uantrell | last post by:
I've gotten sort of fed up with dealing with regional date settings on the client side and am considering the following scheme - just wondering if anyone has a negative view of it or not: ...
9
by: anilcool | last post by:
Hi all, Another novice question. I want to insert multiple records into my DB2 database using stored procedure but I do not know how many I would like to insert at any given time. Each record...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.