Subject | Re: [ib-support] Default value on insert in stored procedure |
---|---|
Author | Steve Landrum |
Post date | 2002-07-31T15:31:29Z |
Henry FRANQUET wrote:
if (field1 = 'DEFAULT) then
field1 = NULL;
if (field2 = 'DEFAULT') then
field2 = NULL;
insert into table(field1, field2)
values(:field1, :field2);
>>>I want to insert record in a table from a stored procedure. Field'sYou could try something like this.
>>>values are variables (declare variable or parameter).
>>>I want to use field's default values of the table.
>>>
>>>
>>If you know when to use DEFAULT, why not simply leave the column
>>out of the INSERT?
>>
>>
>
>when I call the procedure, I don't know which field is null, may be none, one
>or more, its depends of the parameter's value. Default value is given by the
>string DEFAULT on a parameter : exemple
> execute procedure InsertProc ('"value1"', '"value2"', 'DEFAULT')
>
>
> I can use a statement like
> if (field1 = 'DEFAULT') then
> insert (field2, field3) values (:param2, :param3);
> else if (field2 = 'DEFAULT') then
> insert ( field1, field3) values (:param1, :param3);
> else if (field3 = 'DEFAULT') then
> ..... and so on
>
> but I can have only ONE value to DEFAULT with such a method !
>
>
if (field1 = 'DEFAULT) then
field1 = NULL;
if (field2 = 'DEFAULT') then
field2 = NULL;
insert into table(field1, field2)
values(:field1, :field2);