--oracle:declare n_count int;begin Select Count (*) into N_count from from m_test where entitylsh = 1; Dbms_output.put_line (N_count); End --sql server:declare @is_exist_alert3 int; Select @is_exist_alert3 =count (*) from m_test where Entitylsh = 1;print (@is_exist_alert3);
The above single change from the expression of meaning, there are other differences
Differences encountered when using in triggers
--oraclecreate OR REPLACE TRIGGER tr_inst_alarm before INSERT on m_alarm for each rowbegin select Entity_ SEQ. Nextval into:new. Entitylsh from dual; Select ' A_ ' | | Trim (To_char (: New. Entitylsh, ' 00000000 ')) into : New. Alarmindex from dual; End;--entity_seq. Nextval take sequence next--the first SELECT statement means that the next value of the sequence is assigned to the Entitylsh field in the system table (new)--The second SELECT statement means to modify the system table (new) The Entitylsh field in the method of labeling and inserting--new is equivalent to inserting a table, which is maintained by the system as the table structure in the INSERT statement you trigger this trigger--sql servercreate TRIGGER Tr_inst_alarmon m_ Alarminstead of insertasbegindeclare @index varchar, @Orderindex varchar; Select @index =next value for Entity_seq ; Select @Orderindex = ' A_ ' +rtrim (LTrim (Right (cast (' 00000000 ' +rtrim (CAST (@index as int) as varchar)), INSERT Into M_alarm select @index , @Orderindex , Alarmdepartment , Typemethodindex , Alarmphenomenon , ENTITYTYPE from Inserted; end;--meaning as above,--insert is similar to new in Oracle
Oracle Select into is replaced with SQL Server