How to use select into a local variable in SYBASE ASE -
i using sybase ase 15.0.3. , want use type of logic, gives me error.
begin declare @b int, @c int select @b = count(my_id) some_table (some_condition); select @c = count(my_sales) some_table (some_condition); insert my_table (new_id, new_sales) value (@b, @c); end; and use these variables insert value table.
error: "attemp insert null value "new_id", table "my_table" column doesn't allow nulls. update fails"
you may have prepare sql statement before executing doing like:
select @sql='insert my_table (new_id, new_sales) values ('+convert(varchar(10),@b)+','+convert(varchar(10),@c)+')' exec @sql
Comments
Post a Comment