Langsung ke konten utama

Postingan

Menampilkan postingan dengan label query

Use X++ wildcard (LIKE and NOT LIKE) in X++ select statement

For x++ select statements:  select firstOnly batchHistory      where batchHistory.Caption  LIKE  "*Test*"  For x++ queries:  queryBuildRange.value(*Test*); Note the LIKE instead of a '==' and the wildcards inside of the quotations. All other combinations of wildcard usage will work here. This is the same functionality as what the users would put in the grid filtering(eg. '*TEST*' in the caption field filter on the batch tasks form).  However, if you want to find all Captions that do not have the word Test in them (NOT LIKE, !LIKE), you will have to modify the above example slightly.  For x++ select statements:  select firstOnly batchHistory      where  !( batchHistory.Caption LIKE "*TEST*" ) ;  For x++ queries:  queryBuildRange.value(!*Test*);

Query with aggregate function

Query in SQL = Select  AccountNum, sum(AmountCur), sum(AmountMST) from CustTrans group by AccountNum where CustTrans.AccountNum == 'US-018' ;

ForceLiterals & ForcePlaceholders AX

ForceLiterals & ForcePlaceholders When you use forceliterals keywords in Axapta, Axapta will issue SQL statements directly to the database as text string. SELECT forceLiterals * FROM purchTable       WHERE purchId == ‘EN00009’ ; In SQL server, it will be: SELECT A.VALUE, A.MODIFIEDTIME, A.CREATEDTIME, A.RECID FROM HINTTABLE A(NOLOCK) WHERE (PURCHID="EN00009") OPTION(FAST 47) Conversely, using ForcePlaceHolders in Axapta, Axapta will issue SQL statements to the database, and a temporary stored procedure being created for this statement. This stored procedure then remains within the database for as long as the connection that was used when issuing the statement remains. SELECT forcePlaceHolders * FROM purchTable       WHERE purchId == ‘EN00009’ ; In SQL server, it will be:   SELECT A.VALUE, A.MODIFIEDTIME, A.CREATEDTIME, A.RECID FROM HINTTABLE A(NOLOCK) WHERE (PURCHID=" @P1") OPTION(FAST 47) Using forcePlaceHol...

SQL AUTO INCREMENT Field

AUTO INCREMENT Field Auto-increment allows a unique number to be generated automatically when a new record is inserted into a table. Often this is the primary key field that we would like to be created automatically every time a new record is inserted. Syntax for MySQL CREATE   TABLE  Persons (       ID int  NOT   NULL  AUTO_INCREMENT,     LastName varchar( 255 )  NOT   NULL ,     FirstName varchar( 255 ),     Age int,      PRIMARY   KEY  (ID) ); Syntax for SQL Server CREATE   TABLE  Persons (       ID int  IDENTITY ( 1 , 1 )  PRIMARY   KEY ,     LastName varchar( 255 )  NOT   NULL ,     FirstName varchar( 255 ),     Age int ); for Select Query SQL SERVER SELECT ROW_NUMBER () OVER ( ORDER BY FirstName, La...