Board index » delphi » Stored Procedure compiles fine in SQL Server 7 but blows up in Delphi4

Stored Procedure compiles fine in SQL Server 7 but blows up in Delphi4

Hi
I am using Delphi4 and SQL server 7.0. Well some of my stored procedures
have temporary tables where I insert null values into some of the fields in
the temporary field.The stored procedures seems to run fne when run from SQL
server7 but when i call the same procedure from within Delphi my application
just freezes and does not report anything. I found out by using SQL monitor
in Delphi that it was blowing up giving an error message like "cannot insert
null". Well my question is there any way that we could know or be warned
while compiling the stored procedure from the SQL server side?? Is there any
kind of setting that I might have to do ???

Thanks
Sujas

 

Re:Stored Procedure compiles fine in SQL Server 7 but blows up in Delphi4


You can give those Store Procedures default values for it's parameters
when you are creating your Store Procedure.

Just put (= null) after each parameter declaration like:

CREATE PROC StoreProcName
        @Param1 varchar(30) = null, @Param2 varchar(30) = null,
        @Param3 varchar(30) = null, @Param4 varchar(30) = null,
        @Param5 int = null
AS
//The content of the Procedure would come next. Also there would be code
to handle every combination of Parameters.

Then from your Delphi program only put values in those parameters that
you want to use in that moment.

Like:

with stpNameOfStoreProcedure do
    try
        Params[1].AsString := strOneSting;
        Params[3].AsString := strSomeOtherString;

        Open();
        //use the result.
    except
        on e: exception do      
                //some errorhandling
    end;

In article <7uno34$8...@forums.borland.com>, sdasgu...@maccnet.com
says...

Quote
> Hi
> I am using Delphi4 and SQL server 7.0. Well some of my stored procedures
> have temporary tables where I insert null values into some of the fields in
> the temporary field.The stored procedures seems to run fne when run from SQL
> server7 but when i call the same procedure from within Delphi my application
> just freezes and does not report anything. I found out by using SQL monitor
> in Delphi that it was blowing up giving an error message like "cannot insert
> null". Well my question is there any way that we could know or be warned
> while compiling the stored procedure from the SQL server side?? Is there any
> kind of setting that I might have to do ???

> Thanks
> Sujas

Other Threads