declare @c string;
declare @t cursor;
open @t as select * from system.tables
and not name in (select parent from system.columns where name = 'lastupdate');
while fetch @t do
@c = 'alter table '+ @t.name +' ADD COLUMN lastupdate modtime';
execute immediate @c;
end;
close @t;
declare @c string;
declare @t cursor;
open @t as select * from system.tables;
while fetch @t do
@c = 'try alter table '+ @t.name +' ADD COLUMN lastupdate modtime; catch all end try;';
execute immediate @c;
end;
close @t;
Gruß Marcus
Den Kopf in den Sand zu stecken verbessert die Welt auch nicht.
if exists (select * from system.columns where name='F1' and Parent = 'TabelleC') then
select true from system.iota;
else
select false from system.iota;
end if;
ok,
noch ein Problem, wie erweitert man den Befehl wenn man den Default Wert auf
DToC(Date()) + " " Time()
setzen will? Irgendwie klappt das bei mir nicht.
hallo Manfred,
wenn ich die genaue Syntax suche, erweitere ich das Feld im ARC und exportiere die Tabelle nach SQL (rechte Maustaste im ADD-Baum, dann Generate SQL Script).
declare @c string;
declare @t cursor;
open @t as select * from system.tables
and name in (select parent from system.columns where name = 'feld');
while fetch @t do
@c = 'EXECUTE PROCEDURE sp_ModifyFieldProperty ( '''+ @t.name +'''',
''feld'', ''Field_Default_Value'',
''DToC(Date()) + ''' '''+ Time()'', ''NO_VALIDATE'', NULL )';
execute immediate @c;
end;
close @t;
Zuletzt geändert von Marcus Herz am Mi, 14. Sep 2022 12:27, insgesamt 1-mal geändert.
Gruß Marcus
Den Kopf in den Sand zu stecken verbessert die Welt auch nicht.
declare @c string;
declare @t cursor;
open @t as select * from system.tables
and not name in (select parent from system.columns where name = 'lastupdate');
while fetch @t do
@c = 'alter table '+ @t.name +' ADD COLUMN lastupdate modtime default ''now()''' ;
execute immediate @c;
end;
close @t;
Gruß Marcus
Den Kopf in den Sand zu stecken verbessert die Welt auch nicht.
ALTER TABLE demo10
ADD COLUMN test char(20)
DEFAULT ‘abcde’
CONSTRAINT MINIMUM ‘A’
CONSTRAINT MAXIMUM ‘z’
CONSTRAINT NOT NULL
CONSTRAINT error message ‘A bad value was input for the column named test’
hier statt eines Wertes die Funktionen eintragen.
EDIT: Hier geht nur String-Literal, also bleibst bei MODIFY wie oben.
declare @c string;
declare @t cursor;
open @t as select * from system.tables
and not name in (select parent from system.columns where name = 'tarifcode');
while fetch @t do
@c = 'alter table '+ @t.name + ' ADD COLUMN tarifcode Char(3)';
execute immediate @c;
end;
close @t;
bei and not name
diese fehlermeldung im Architekten kommt
poQuery: Error 7200: AQE Error: State = 42000; NativeError = 2117; [SAP][Advantage SQL Engine]Unexpected token: and -- Expecting semicolon. -- Location of error in the SQL statement is: 79 (line: 5 column: 1)