Re: Java Prepared Statement with multiple arguments
- From: "joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx>
- Date: 3 Aug 2005 09:42:33 -0700
Hi. Yes you have to have a '?' for every variable in both clauses. If
you make a stored procedure like:
create procedure myInsertProc int @foo, VARCHAR(30) @bar ...
AS
BEGIN
IF NOT EXIST (SELECT * FROM MyTable WHERE MyColumn = @foo
AND MYOtherColumn = @bar ) INSERT INTO
MyTable (MyColumn) VALUES (@foo, @bar)
END
then your JDBC would only need one '?' for each column:
p = c.prepareStatement("{ call myInsertProc( ?, ? ) }");
If you can create an index for your table that enforces that
each row is unique, then you don't need to do the check. If
the row already exists the insert will fail.
HTH,
Joe Weinstein at BEA
.
- Follow-Ups:
- Re: Java Prepared Statement with multiple arguments
- From: johnfofawn
- Re: Java Prepared Statement with multiple arguments
- References:
- Java Prepared Statement with multiple arguments
- From: johnfofawn
- Java Prepared Statement with multiple arguments
- Prev by Date: Differentiating between results of getSchemas()
- Next by Date: Re: Differentiating between results of getSchemas()
- Previous by thread: Java Prepared Statement with multiple arguments
- Next by thread: Re: Java Prepared Statement with multiple arguments
- Index(es):
Relevant Pages
|
|