pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
passing parameters to function
5+ messages / 3 participants
[nested] [flat]

* passing parameters to function
@ 2005-11-08 12:24  Srivats <scshekaran@riskspan.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Srivats @ 2005-11-08 12:24 UTC (permalink / raw)
  To: pgsql-jdbc

Hi All,

Suppose I have a store proc which accepts 4 input parameters
and I do a CallableStatement.setObject( 1, "..,,," );
and execute the query . 

It gives me that number of arguments need 4, but found only 1

(java.sql.SQLException:Incorrect number of arguments for PROCEDURE FHLMC.test1; expected 4, got 1)

during runtime. Should i set the other 3 input parameters to null,
even when I dont want to pass these parameters to the SP.

Thks

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* passing parameters to function
@ 2005-11-08 12:31  Srivats <scshekaran@riskspan.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Srivats @ 2005-11-08 12:31 UTC (permalink / raw)
  To: pgsql-jdbc


Hi All,

Suppose I have a store proc which accepts 4 input parameters
and I do a CallableStatement.setObject( 1, "..,,," );
and execute the query . 


 CallableStatement functionCall = dbCon_.prepareCall("{call test1( ?,?,?,?) }");  
  functionCall.setObject( "param1","A10001" );
  functionCall.setObject( "param2","19830529" );
  functionCall.execute();

Exception raised

java.sql.SQLException: No value specified for parameter 3
        at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1253)
        at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1201)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:710)
        at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:520)
 

during runtime. Should i set the other 2 input parameters to null,
even when I dont want to pass these parameters to the SP.
In this statement call test1( ?,?,?,?), should the number of parameters be the number 
of parameters which the store procedure accepts or the number of parameters that i want 
to pass.  How should this be done when my SP accepts 4 parameters and i want to pass
only any two of them

Thks

PS: Looking for an early reply

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: passing parameters to function
@ 2005-11-08 15:51  Dave Cramer <pg@fastcrypt.com>
  parent: Srivats <scshekaran@riskspan.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Dave Cramer @ 2005-11-08 15:51 UTC (permalink / raw)
  To: Srivats <scshekaran@riskspan.com>; +Cc: pgsql-jdbc

You would have to set them to NULL

Dave
On 8-Nov-05, at 7:31 AM, Srivats wrote:

>
> Hi All,
>
> Suppose I have a store proc which accepts 4 input parameters
> and I do a CallableStatement.setObject( 1, "..,,," );
> and execute the query .
>
>
>  CallableStatement functionCall = dbCon_.prepareCall("{call test1 
> ( ?,?,?,?) }");
>   functionCall.setObject( "param1","A10001" );
>   functionCall.setObject( "param2","19830529" );
>   functionCall.execute();
> Exception raised
>
> java.sql.SQLException: No value specified for parameter 3
>         at com.mysql.jdbc.PreparedStatement.fillSendPacket 
> (PreparedStatement.java:1253)
>         at com.mysql.jdbc.PreparedStatement.fillSendPacket 
> (PreparedStatement.java:1201)
>         at com.mysql.jdbc.PreparedStatement.execute 
> (PreparedStatement.java:710)
>         at com.mysql.jdbc.CallableStatement.execute 
> (CallableStatement.java:520)
>
>
> during runtime. Should i set the other 2 input parameters to null,
> even when I dont want to pass these parameters to the SP.
> In this statement call test1( ?,?,?,?), should the number of  
> parameters be the number
> of parameters which the store procedure accepts or the number of  
> parameters that i want
> to pass.  How should this be done when my SP accepts 4 parameters  
> and i want to pass
> only any two of them
>
> Thks
>
> PS: Looking for an early reply
>
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: passing parameters to function
@ 2005-11-09 03:44  Srivats <scshekaran@riskspan.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Srivats @ 2005-11-09 03:44 UTC (permalink / raw)
  To: pgsql-jdbc

Hi All, 

Is there anyway i can get the list of parameters which the store proc accepts from the java end after i make the prepareCall.

Thks

  ----- Original Message ----- 
  From: Dave Cramer 
  To: Srivats 
  Cc: pgsql-jdbc@postgresql.org 
  Sent: Tuesday, November 08, 2005 9:21 PM
  Subject: Re: [JDBC] passing parameters to function 


  You would have to set them to NULL


  Dave

  On 8-Nov-05, at 7:31 AM, Srivats wrote:



    Hi All,

    Suppose I have a store proc which accepts 4 input parameters
    and I do a CallableStatement.setObject( 1, "..,,," );
    and execute the query .


     CallableStatement functionCall = dbCon_.prepareCall("{call test1( ?,?,?,?) }");  
      functionCall.setObject( "param1","A10001" );
      functionCall.setObject( "param2","19830529" );
      functionCall.execute();

    Exception raised

    java.sql.SQLException: No value specified for parameter 3
            at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1253)
            at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1201)
            at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:710)
            at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:520)
     

    during runtime. Should i set the other 2 input parameters to null,
    even when I dont want to pass these parameters to the SP.
    In this statement call test1( ?,?,?,?), should the number of parameters be the number
    of parameters which the store procedure accepts or the number of parameters that i want
    to pass.  How should this be done when my SP accepts 4 parameters and i want to pass
    only any two of them

    Thks

    PS: Looking for an early reply

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: passing parameters to function
@ 2005-11-09 07:52  Achilleus Mantzios <achill@matrix.gatewaynet.com>
  parent: Srivats <scshekaran@riskspan.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Achilleus Mantzios @ 2005-11-09 07:52 UTC (permalink / raw)
  To: Srivats <scshekaran@riskspan.com>; +Cc: pgsql-jdbc

O Srivats Ýãñáøå óôéò Nov 9, 2005 :

> Hi All, 
> 
> Is there anyway i can get the list of parameters which the store proc accepts from the java end after i make the prepareCall.

You might want to look at 
DatabaseMetaData dbmd = con.getMetaData();
ResultSet your_funk_args = dbmd.getProcedureColumns(...);
I dont know (or looked) if it is supported by the current 
7.4 pgsql jdbc.

> 
> Thks
> 
>   ----- Original Message ----- 
>   From: Dave Cramer 
>   To: Srivats 
>   Cc: pgsql-jdbc@postgresql.org 
>   Sent: Tuesday, November 08, 2005 9:21 PM
>   Subject: Re: [JDBC] passing parameters to function 
> 
> 
>   You would have to set them to NULL
> 
> 
>   Dave
> 
>   On 8-Nov-05, at 7:31 AM, Srivats wrote:
> 
> 
> 
>     Hi All,
> 
>     Suppose I have a store proc which accepts 4 input parameters
>     and I do a CallableStatement.setObject( 1, "..,,," );
>     and execute the query .
> 
> 
>      CallableStatement functionCall = dbCon_.prepareCall("{call test1( ?,?,?,?) }");  
>       functionCall.setObject( "param1","A10001" );
>       functionCall.setObject( "param2","19830529" );
>       functionCall.execute();
> 
>     Exception raised
> 
>     java.sql.SQLException: No value specified for parameter 3
>             at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1253)
>             at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1201)
>             at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:710)
>             at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:520)
>      
> 
>     during runtime. Should i set the other 2 input parameters to null,
>     even when I dont want to pass these parameters to the SP.
>     In this statement call test1( ?,?,?,?), should the number of parameters be the number
>     of parameters which the store procedure accepts or the number of parameters that i want
>     to pass.  How should this be done when my SP accepts 4 parameters and i want to pass
>     only any two of them
> 
>     Thks
> 
>     PS: Looking for an early reply
> 
> 
> 
> 
> 
> 
> 
> 
> 

-- 
-Achilleus




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2005-11-09 07:52 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-08 12:24 passing parameters to function Srivats <scshekaran@riskspan.com>
2005-11-08 12:31 passing parameters to function Srivats <scshekaran@riskspan.com>
2005-11-08 15:51 ` Dave Cramer <pg@fastcrypt.com>
2005-11-09 03:44   ` Srivats <scshekaran@riskspan.com>
2005-11-09 07:52     ` Achilleus Mantzios <achill@matrix.gatewaynet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox