nuova funzione di suggestCode ean14
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240531101351 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
|
||||
createOrUpdateFunction("f_suggestCodeEan14", "CREATE FUNCTION dbo.f_suggestCodeEan14\n" +
|
||||
"(\n" +
|
||||
" @partialcode varchar(13)\n" +
|
||||
")\n" +
|
||||
"RETURNS varchar(14)\n" +
|
||||
"AS\n" +
|
||||
"BEGIN\n" +
|
||||
" declare @ean14 varchar(14)\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" select @ean14 = cast(min(rowID) as varchar) + @partialcode\n" +
|
||||
" from (\n" +
|
||||
" select *\n" +
|
||||
" from stb_counter\n" +
|
||||
" where rowId between 1 and 9 and \n" +
|
||||
" not exists (select * from mvw_barcode where cod_barre like '%'+@partialcode+'%' and len(cod_barre) = 14 and isNumeric(left(cod_barre,1))=1 and left(cod_barre,1)=rowId) ) t\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" select @ean14 = @ean14 + cast([dbo].[getCheckDigitITF14](@ean14) as varchar)\n" +
|
||||
"\n" +
|
||||
" -- Return the result of the function\n" +
|
||||
" RETURN @ean14\n" +
|
||||
"\n" +
|
||||
"END");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user