Board index » delphi » It doesn't accept parameters null ?

It doesn't accept parameters null ?

Hi,
I have in my application a TSQLStoredProc (dbExpress) that executes a stored
procedure that inserts registrations according to the parameters that I pass
him from my application, in the following way:

mySP.Params.ParamValues [' FIELD1 '] := ' MY STRING';
mySP.Params.ParamValues [' FIELD2 '] := NULL;
msSP.ExecProc;

but my stored procedured procedure (Interbase) receives the parameters:

FIELD1----> ' MY STRING'
but:
FIELD2----> '' and non NULL!!!!

can somebody help me with this?

Thank you.

Jorge

 

Re:It doesn't accept parameters null ?


Quote
"jorge" <jm...@puertadigital.com> wrote:
>Hi,
>I have in my application a TSQLStoredProc (dbExpress) that executes a stored
>procedure that inserts registrations according to the parameters that I pass
>him from my application, in the following way:

>mySP.Params.ParamValues [' FIELD1 '] := ' MY STRING';
>mySP.Params.ParamValues [' FIELD2 '] := NULL;
>msSP.ExecProc;

>but my stored procedured procedure (Interbase) receives the parameters:

>FIELD1----> ' MY STRING'
>but:
>FIELD2----> '' and non NULL!!!!

>can somebody help me with this?

>Thank you.

>Jorge

Try this:
  mySP.Params.ParamValues ['FIELD1'] := ' MY STRING';
  mySP.ParamByName('FIELD2').Clear;
  msSP.ExecProc;

Re:It doesn't accept parameters null ?


My configuration:

- Win2000 Prof.
- Borland Delphi 6.0 UP2
- Interbase 6.0.1.6

"jorge" <jm...@puertadigital.com> escribi en el mensaje
news:3d08e659_2@dnews...

Quote
> Hi,
> I have in my application a TSQLStoredProc (dbExpress) that executes a
stored
> procedure that inserts registrations according to the parameters that I
pass
> him from my application, in the following way:

> mySP.Params.ParamValues [' FIELD1 '] := ' MY STRING';
> mySP.Params.ParamValues [' FIELD2 '] := NULL;
> msSP.ExecProc;

> but my stored procedured procedure (Interbase) receives the parameters:

> FIELD1----> ' MY STRING'
> but:
> FIELD2----> '' and non NULL!!!!

> can somebody help me with this?

> Thank you.

> Jorge

Re:It doesn't accept parameters null ?


Neither it works,
I find this very strange, has the appearance of something that I am making
bad and I don't realize.

"Igor Belitsky" <igor_belit...@manulife.com> escribi en el mensaje
news:3d08e7d2$1_2@dnews...

Quote

> "jorge" <jm...@puertadigital.com> wrote:
> >Hi,
> >I have in my application a TSQLStoredProc (dbExpress) that executes a
stored
> >procedure that inserts registrations according to the parameters that I
pass
> >him from my application, in the following way:

> >mySP.Params.ParamValues [' FIELD1 '] := ' MY STRING';
> >mySP.Params.ParamValues [' FIELD2 '] := NULL;
> >msSP.ExecProc;

> >but my stored procedured procedure (Interbase) receives the parameters:

> >FIELD1----> ' MY STRING'
> >but:
> >FIELD2----> '' and non NULL!!!!

> >can somebody help me with this?

> >Thank you.

> >Jorge

> Try this:
>   mySP.Params.ParamValues ['FIELD1'] := ' MY STRING';
>   mySP.ParamByName('FIELD2').Clear;
>   msSP.ExecProc;

Re:It doesn't accept parameters null ?


This happens when Param.DataType is [ftString ('') or ftInteger (0) or
ftDate (30/12/1899) or ftFixedChar ('')...]
When Param.DataType is ftString, I replaced it for ftFmtMemo and seemingly
it works.

Re:It doesn't accept parameters null ?


I'm sending an update for "sqlexpr.pas" (D6 UP2) in order to correct this
bug. Find this in procedure SetProcedureParams.

        ArgDesc := (PSPParamDesc(ProcParams.Items[I]))^;
        iFldType := FldTypeMap[ArgDesc.iDataType];
        if Params[I].ParamType <> ptOutput then
          DataLen := Params[I].GetDataSize
        else
          DataLen := ArgDesc.iLen;
        if DataLen > 0 then
        begin
          iInd := 0;
          RecBuffer := AllocMem(DataLen);

and replace for this:

        ArgDesc := (PSPParamDesc(ProcParams.Items[I]))^;
        iFldType := FldTypeMap[ArgDesc.iDataType];
        if Params[I].ParamType <> ptOutput then
          if VarIsEmpty(Params[I].Value) or VarIsNull(Params[I].Value) then
            DataLen  := 0
          else DataLen := Params[I].GetDataSize
        else
          DataLen := ArgDesc.iLen;
        if DataLen > 0 then
        begin
          iInd := 0;
          RecBuffer := AllocMem(DataLen);

Jorge

Other Threads