Re: a stored procedure ..with integer as the parameter

From: "surabhi(dot)ahuja" <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in>
To: "Stephan Szabo" <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: a stored procedure ..with integer as the parameter
Date: 2005-10-24 08:04:30
Message-ID: 967CFC4343BF2A4DAFACD026D33DC85118EC81@jal.iiitb.ac.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

from the client i receive a vector of strings ...which i have to pass as arguments to the stored procedure.

That stored procedure has valid arguments data types

for instance
i have a stored procedure as follows:

insert(integer, varchar(256), smallint)

from the client I get : "200", "surabhi", "10"

now i have to make a call to the stored procedure using the above received strings.

will not the "200" be converted to a valid integer before saving into the database ..and same with the smallint values.

thanks,
regards
Surabhi

________________________________

From: Stephan Szabo [mailto:sszabo(at)megazone(dot)bigpanda(dot)com]
Sent: Fri 10/21/2005 12:11 PM
To: surabhi.ahuja
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] a stored procedure ..with integer as the parameter

***********************
Your mail has been scanned by InterScan VirusWall.
***********-***********

On Fri, 21 Oct 2005, surabhi.ahuja wrote:

> i have a stored procedure
>
> insert_table(integer)
> which does "insert into table (x) value ($1)";
>
> now in my client i call the stored procedure as
>
> select insert_table("3");
>
> it works fine and inserts 3 into the table
>
> but suppose i give
>
> select insert_table("");
>
> it gives an error ...saying " invalid input syntax for integer: "
>
> please suggest a solution to this problem

Don't try to use an empty string as an integer?

Seriously, you need to give information about what you want to happen,
because an empty string isn't a valid integer and can't really be
converted into one (we explicitly removed code that handled this case
because we thought it didn't make sense).

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bohdan Linda 2005-10-24 08:39:11 SHA1 authentication
Previous Message Romain Vinot 2005-10-24 08:02:10 Migration from 8.0 to 7.4...