Changing default serving port in Angular

You can change your application port by entering the following command,

ng serve –port 1453

Also, you can change the port by editing anglular-cli.json file:

“defaults”: {
   “serve”: {
      “host”: “localhost”,
      “port”: 1453
   }
}
You can see, serve options in this link.
Advertisements
By eneskoroglu Posted in Angular

Delphi – cxLookupCombobox’a buton ekleme

Aşağıdaki kodla MRUEdit gibi cxLookupCombobox’a button ekleyip, butonlara da kendi yazdığınız ya da herhangi bir OnButtonClick event’ini bağlayabilirsiniz.

Event’de AbuttonIndex kontrolü yapmazsanız LookupCombobox’ın standart butonu içinde –Liste açıkken tıklarsanız- yazacağınız kod çalışıyor. –Başka bir amaç için ihtiyacaç olabilir-

type
TcxCustomEditPropertiesAccess = class(TcxCustomEditProperties);

TcxCustomEditPropertiesAccess(cmb_Park_Group.Properties).OnButtonClick := myPropertiesButtonClick; //event bağla

with TcxCustomEditPropertiesAccess(cmb_Park_Group.Properties).Buttons.Add do
begin
Kind := bkEllipsis;
LeftAlignment := True; //Butonları sol tarafa alır
end;

procedure TForm1.myPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
if AButtonIndex = 1 then
begin
ShowMessage(‘TEST’);
end;

Screen Shot 01-08-16 at 04.56 PM

Screen Shot 01-08-16 at 04.57 PM

 

$REGION

The IDE supports since Delphi 2005 code folding of marked regions.
{$REGION ‘Hidden Code’}
Beep;
Beep;
Beep;
{$ENDREGION}
folds down to just
Hidden Code
in the IDE editor window.
Source: http://www.tindex.net/Language/$REGION.html
Kodlarınızda aşağıdaki gibi REGION tanımlarınızı yaptığınızdaki o kodu açtığınızda ikince resimdeki gibi yaptığınız tanımlar gözükecek istediğin iz kodu açıp inceleyebilirsiniz bu şekilde daha temiz bir görüntü elde etmiş olacaksınız. İkinci resimdeki görüntü geçen gün gönderdiğim More Coding in Delphi kitabında bahsedilen Spring framework’ünün sourcelarından alınmıştır.
Screen Shot 10-02-15 at 09.19 AM
Screen Shot 10-02-15 at 09.20 AM

Delphi – Event Override via Interceptor Class

Aşağıdaki şekilde mevcut bir type’ın bir özelliğini (event) override edebilirsiniz. Örnekte TButton’ın click event’ının procedure’ü override ediliyor. Bu işlemi ya etkilenmesini istediğini formda yapmanız gerekiyor ya da başka bir form/unit’de yaptıysanız override işlemini yaptığınız bileşenin uses’ını ilgili bileşene ait olan uses’dan sonra yazmalısınız (bu örnek için bu kodu Global_Unit diye bir dosyada yaptıysanız uses’da Global_Unit’i en sonda ya da en azından Vcl.StdCtrls -bileşenin uses dosyası- ndan sonra eklemelisiniz.

Most importantly, add the “button_interceptor” unit in the uses list as the last unit listed, or at least after the “stdctrls” unit!

type

TButton = class(Vcl.StdCtrls.TButton)

public

procedure Click; override;

end;

Kaynak: http://delphi.about.com/od/delphitips2009/qt/interceptor.htm

Oracle/PLSQL: To_Date Function

In Oracle/PLSQL, the to_date function converts a string to a date.

The syntax for the to_date function is:

to_date( string1, [ format_mask ], [ nls_language ] )

string1 is the string that will be converted to a date.

format_mask is optional. This is the format that will be used to convert string1 to a date.

nls_language is optional. This is the nls language used to convert string1 to a date.

 

The following is a list of options for the format_mask parameter. These parameters can be used in many combinations.

Parameter

Explanation

YEAR Year, spelled out
YYYY 4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY 4-digit year based on the ISO standard
RRRR Accepts a 2-digit year and returns a 4-digit year.
A value between 0-49 will return a 20xx year.
A value between 50-99 will return a 19xx year.
Q Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
MM Month (01-12; JAN = 01).
MON Abbreviated name of month.
MONTH Name of month, padded with blanks to length of 9 characters.
RM Roman numeral month (I-XII; JAN = I).
WW Week of year (1-53) where week 1 starts on the first day of the   year and continues to the seventh day of the year.
W Week of month (1-5) where week 1 starts on the first day of the   month and ends on the seventh.
IW Week of year (1-52 or 1-53) based on the ISO standard.
D Day of week (1-7).
DAY Name of day.
DD Day of month (1-31).
DDD Day of year (1-366).
DY Abbreviated name of day.
J Julian day; the number of days since January 1, 4712 BC.
HH Hour of day (1-12).
HH12 Hour of day (1-12).
HH24 Hour of day (0-23).
MI Minute (0-59).
SS Second (0-59).
SSSSS Seconds past midnight (0-86399).
FF Fractional seconds. Use a value from 1 to 9 after FF to indicate   the number of digits in the fractional seconds. For example, ‘FF4’.
AM, A.M., PM, or P.M. Meridian indicator
AD or A.D AD indicator
BC or B.C. BC indicator
TZD Daylight savings information. For example, ‘PST’
TZH Time zone hour.
TZM Time zone minute.
TZR Time zone region.

Applies To:

Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

For example:

to_date(‘2003/07/09’, ‘yyyy/mm/dd’)

would return a date value of July 9, 2003.

to_date(‘070903’, ‘MMDDYY’)

would return a date value of July 9, 2003.

to_date(‘20020315’, ‘yyyymmdd’)

would return a date value of Mar 15, 2002.

Kaynak: http://www.techonthenet.com/oracle/functions/to_date.php

Temel Oracle Fonksiyonları

Oracle’da en çok kullanacağınız temel oracle fonksiyonlarını aşağıda açıklama ve örnekleri ile bulabilrsiniz. Umarım işinize yarar;

PLSQL

Numeric Functions

ROUND(N , x) : Return the number N rounded to x decimal places. If x <0 it rounds N to x places to the left.

Example: ROUND(1234.468,2)  returns 1234.5      ROUND(1234.468,-2)  returns 1200
Example: TRUNC(123.456,2) returns 123.45
                TRUNC(123.456,-2) returns 100
Example:  SIGN(-234) returns -1
      SIGN(452) returns 1
Example: ABS(-541) returns 541.
Example: MOD(10,4) returns 2. MOD(5,2) returns 1
Example: CEIL(123.456) returns 124. CEIL(-123.456) returns -123
Example: FLOOR (123.456) returns 123. FLOOR (-123.456) returns -124

TRUNC(N , x): Return the number with the specified x decimal places. If x<0 it zeroed the number at X positions to the left.

SIGN (N): Return 1 if N is positive, 0 if N is 0 and -1 if N is negative.

ABS(N): Returns the absolute value of number N. It basically removes the sign from the number and return the positive number.

GREATEST(V1,V2,V3,…Vn): Return the largest of the n values in the list. Not to be confuse with MAX witch return the largest values of a set of rows

LEAST(V1,V2,V3,…Vn): Return the smallest of the n values in the list. Not to be confuse with MIN witch return the smallest values of a set of rows

MOD (N, x): Return the remainder of N divided by x.

CEIL(N): Returns the smallest integer greater than or equal to N.

FLOOR(N): returns largest integer that is less than or equal to N.

PLSQL

String Functions

SUBSTR(S,x,n): Return a portion of string S starting at position x of n characters. If x=0 it will be consider 1 as Oracle consider the first character to be at position 1. if x <0 the count will begin at the end of the string S.
Example: SUBSTR(‘abcdefg’,3,3) will return ‘cde’. SUBSTR(‘abcdefg’,-3,3) will return ‘efg’

LOWER(S): Returns the string S converted to all lowercase characters.
Example: LOWER(‘AbcDefg’) returns ‘abcdefg’

UPPER(S): Returns the string S converted to all uppercase characters.
Example: UPPER(‘AbcDefg’) returns ‘ABCDEFG’

CONCAT(S1,S2): Returns a concatenated string value of S1, S2. could be replace by S1||S2.
Example: CONCAT(‘Abc’,’DeF’) returns ‘AbcDeF’

INITCAP(S): Return the string S converted to the initial capital letters.
Example:

LENGTH(S): Return the number of characters in string S.
Example: LENGTH(‘abcdefg’) returns 7.

LPAD(S,N,X):  Returns the string S concatenate to the left by characters X to the total size of N.
Example: LPAD(‘MyChar’, 10, ‘O’) returns ‘OOOOMyChar’

RPAD(S,N,X):  Returns the string S concatenate to the rigth by characters X to the total size of N.
Example: RPAD(‘MyChar’, 10, ‘O’) returns ‘MyCharOOOO’

LTRIM(S): Returns the string S after cleaning all empty character to the left.
Example: LTRIM(‘      MyChar     ’) returns  ‘MyChar     ’

RTRIM(S): Returns the string S after cleaning all empty character to the Rigth.
Example: RTRIM(‘      MyChar     ’) returns  ‘      MyChar’

TRIM(S): Returns the string S after cleaning all empty character to the Rigth and Left.
Example: TRIM(‘      MyChar     ’) returns  ‘MyChar’

REPLACE(S,S1,S2): Return string S with all occurrences of string S1 replaced by S2.
Example: REPLACE(‘abcdefabcdefabcdef’,’de’,’A’) returns ‘abcAfabcAfabcAf’

PLSQL

Date Functions

ADD_MONTHS(D, m): Return the date D added with the specified number of months. If m<0 Oracle subtract the number of month by m.
Example: ADD_MONTHS(‘12-JAN-2002’,9) returns ‘12-OCT-2002’.
ADD_MONTHS(‘12-JAN-2002’,-1) returns ‘12-DEC-2001’.

LAST_DAY(D): Return the last day of the month for the date D.
Example: LAST_DAY(‘12-DEC-2001’) returns ‘31-DEC-2001’

MONTHS_BETWEEN(D1,D2): Return the fractional difference in months between date D1 and date D2, if D1<D2 the difference is negative. This function takes in account days and hours.

NEXT_DAY(D,DayName): Return the date of the very next day of DayName specified, after the date D.
Example: NEXT_DAY(‘12-DEC-2005’,’SUNDAY’) returns ‘18-DEC-2005’

TRUNC(D): Return date D without its time component.

ROUND (D, format): Return the date D rounded to the unit specified by the format, if no format if specified the date D is return rounded to the nearest day.
Example: ROUND(‘12-DEC-2004’,’YEAR‘) returns ‘1-JAN-2005’

SYSDATE: Return the database server’s current datetime.

 

PLSQL

Grouping Functions

MIN(E): Return the smallest value of expression E from a set of rows.

MAX(E): Return the largest  value of expression E from a set of rows.

SUM(E): Return the summed value of expression E from a set of rows.

AVG(E): Returns the average value of expression E from a set of rows.

COUNT(E): Return the number of row from the set with the value of E not null. If E=* the function will simply return the number of rows in the set.

PLSQL

Conversion Functions

TO_DATE(S,format): Return a Date from the conversion of string S, in the format specify, to date time.
The standard of date time format in Oracle is ‘DD-MON-YYYY’

TO_CHAR(N,format): Return a string from the conversion of number N, in the format specify, to string.

TO_CHAR(D,format): Return a string from the conversion of date D, in the format specify, to string.

TO_NUMBER(S, format): Return a number from the conversion of string S, in the format specify, to number.

Kaynak: http://www.samplecodepool.com/Forms/Oracle/BasicFunctionsOra.aspx

Oracle’da Türkçe Upper Komutu

Oracle’ın büyük harfe çevir (upper), küçük harfe çevir (lower), ilk harfleri büyük yap (initcap) fonksiyonları bildiğiniz ya da deneyip görebileceğiniz gibi İngilizce kurallarına göre çalışmaktadır. Örneğin elinizde “ismail” ismi, “bilir” soyadı olsun. Bu değerleri ismi initcap, soyadı ise upper ile çevirirseniz aşağıdaki sonuçla karşılaşırsınız:

select initcap(‘ismail’) || ‘ ‘ || upper(‘bilir’) “Ad Soyad”from dual;

Ad Soyad
————
Ismail BILIR
1 row selected.

Elde ettiğimiz çıktı “Ismail BILIR” oldu. Bizim istediğimiz çıktı ise “İsmail BİLİR” olacaktı. Bu durumda oracle’ın nls_ ile başlayan functionları devreye giriyor:

select nls_lower(‘İSİM: ‘, ‘NLS_SORT = XTURKISH’) || nls_initcap(‘ismail’, ‘NLS_SORT = XTURKISH’) || ‘ ‘ || nls_upper(‘bilir’, ‘NLS_SORT = XTURKISH’) “Ad Soyad”from dual;

Ad Soyad
——————
isim: İsmail BİLİR
1 row selected.

Göreceğiniz gibi istediğimiz şekilde türkçe dil kurallarına uygun olarak dönüşüm işlemlerimizi gerçekleştirebildik. nls_sort parametresi için kullanabileceğiniz değerleri aşağıdaki tablonun extended name kısmında karşılık gelen değerlerden görebilirsiniz:

Basic Name  Extended Name  Special Cases 
CATALAN XCATALAN æ, AE, ß
CROATIAN XCROATIAN D, L, N, d, l, n, ß
CZECH XCZECH ch, CH, Ch, ß
DANISH XDANISH A, ß, Å , å
DUTCH XDUTCH ij, IJ
FRENCH XFRENCH
GERMAN XGERMAN ß
GERMAN_DIN XGERMAN_DIN ß, ä, ö, ü, Ä, Ö, Ü
HUNGARIAN XHUNGARIAN cs, gy, ny, sz, ty, zs, ß, CS, Cs, GY, Gy, NY, Ny, SZ, Sz, TY, Ty, ZS, Zs
PUNCTUATION XPUNCTUATION
SLOVAK XSLOVAK dz, DZ, Dz, ß (caron)
SLOVENIAN XSLOVENIAN ß
SPANISH XSPANISH ch, ll, CH, Ch, LL, Ll
SWISS XSWISS ß
TURKISH XTURKISH æ, AE, ß
WEST_EUROPEAN XWEST_EUROPEAN ß

Kaynak: http://www.csee.umbc.edu/portal/help/oracle8/server.815/a67789/appa.htm#958510

Generating random numbers and strings in Oracle

Do you know how to auto generate random numbers or strings in Oracle? Generating random numbers is required when there is a need to create a lot of data for testing purposes, or when we simply need to use a number to temporarily tag a process. It may also be necessary to generate random password strings of a fixed size–a very common requirement for websites that create and maintain logins for users.

Whatever the need, the fact is that Oracle provides us with a random number generator. This option is faster than writing your own random generation logic in PL/SQL as Oracle’s internal processing logic is used. In addition, it can also be used to generate both character and alphanumeric strings.

DBMS_RANDOM package

The DBMS_RANDOM package will generate random data in character, numeric or alphanumeric formats. The size and the range from which to pickup the random values can also be specified. This package is created by the script dbmsrand.sql available in the <ORACLE_HOME>/rdbms/admin directory.
The following functions present in the package can be used to serve the purpose of generating random numbers and strings. RANDOM – generate random numbers.
VALUE – generate random numbers from the range provided. The range will be taken as 0-1 if none is provided.
STRING – generate strings in upper case, lower case or alphanumeric format.

  • The first parameter takes the string type to be generated, the following values can be provided in upper or lower case.
  • U – Upper case
  • L – Lower case
  • A – Alphanumeric
  • X – Alphanumeric with upper case alphabets.
  • P – Printable characters only. Providing any other character will return the output in upper case only.
    The size of the string should also be provided as the second parameter.

Oracle documentation says that it is necessary to initialize the package before using the random number generator. Oracle by default initializes the package with the seed value as the current user name, current time down to the second and the current session id.
INITIALIZE – Initialize the package to proceed with the number generation.
Provide a number (seed) as input to the routine.
SEED – Used to change the seed value. It is used in the internal algorithm to generate values. Setting this will
generate the random numbers in an order that will be similar in multiple sessions. Refer to the example below.
TERMINATE – Close the process of random number generation.

Examples:

Below are some examples of using the package.
E.g.: Generating a random number (positive or negative)

SQL> select dbms_random.random from dual;

       RANDOM
_____________
   1393936551

E.g.: Generating a random number between 0 and 1.

SQL> select dbms_random.value from dual;

        VALUE
_____________
            1

E.g.: Generating a random number from a range, between 1 to 1000.

SQL> select dbms_random.value(1,1000) num from dual;

          NUM
_____________
          611

E.g.: Generating a 12 digit random number.

SQL> select dbms_random.value(100000000000, 999999999999) num from dual;

          NUM
_____________
 175055628780

E.g.: Generating an upper case string of 20 characters

SQL> select dbms_random.string('U', 20) str from dual;

STR
_______________________
VUOQOSTLHCKIPIADIZTD

E.g.: Generating a lower case string of 20 characters

SQL> select dbms_random.string('L', 20) str from dual;

STR
____________________
xpoovuspmehvcptdtzcz

E.g.: Generating an alphanumeric string of 20 characters. There is a bug in Oracle 8i that results in special (non-alphanumeric) characters such as ‘]’ in the string. This is resolved in Oracle 9i.

SQL> select dbms_random.string('A', 20) str from dual;

STR
__________________
sTjERojjL^OlTaIc]PLB

E.g.: Generating an upper case alphanumeric string of 20 characters

SQL> select dbms_random.string('X', 20) str from dual;

STR
________________________
SQ3E3B3NRBIP:GOGAKSC

E.g.: Generating a string of printable 20 characters. This will output a string of all characters that could possibly be printed.

SQL> select dbms_random.string('P', 20) str from dual;

STR
___________________
*Yw>IKzsj\uI8K[IQPag

E.g.: Example for calling the dbms_random package and setting the seed for generating the same set of random numbers in different sessions. Please note that the same random numbers are generated in different sessions. Though I have found this to work on most accounts, in some cases, the first number generated was different in different sessions and the remaining were same. I recommend not using this option in any of production code until it is properly document by Oracle.

jaJA>declare
  2     l_num    number;
  3  begin
  4    l_num := dbms_random.random;
  5    dbms_output.put_line(l_num);
  6    dbms_random.seed('amar testing 67890');
  7    l_num := dbms_random.random;
  8    dbms_output.put_line(l_num);
  9  end;
 10  /
483791552
478774329

PL/SQL procedure successfully completed.

Conclusion

DBMS_RANDOM is a good utility and will find its way into lot of development projects, especially web based ones. However, this Package is not exhaustively documented. One should not use it just for the sake of it being there. Make sure that there is a true requirement or a necessity of random values before making use of this package. If you already have a custom code meant for the same purpose, check out the benefits that are available when using this package compared to your application.


Referance: http://www.dbasupport.com/oracle/ora9i/random_numbers.shtml (Amar Kumar Padhi)

Oracle’da sleep komutu

Bir programda örneğin bir işi bir kaç defa belli bir süre aralığıyla tekrar denemek isteyebilirsiniz. Örneğin mail gönderme işleminiz başarısız olursa toplamda 3 defa 10 sn. aralıkla bu işi tekrar yapmayı deneyebilirsiniz, geçici network problemleri ya da anlık problem bu süre zarfında düzelirse işleminiz başarılı bir şekilde gerçekleşmiş olur. Çoğu dilde bu işi yapan ve süreyi genelde milisaniye cinsinden belirtebildiğimiz sleep komutu vardır. Oracle’ın PL/SQL dilinde bunun karşılığı dbms_lock.sleep procedure’üdür ve süre saniye cinsinden verilir. Örnek kullanım aşağıdaki gibidir.

declare
l_date_1    timestamp;
l_date_2    timestamp;
begin
l_date_1 := systimestamp;
dbms_lock.sleep(1);//1 sn. uyu. (1 ms. değil dikkatli olun!)
   l_date_2 := systimestamp;
   dbms_output.put_line( to_char(l_date_2 – l_date_1, ‘ss’) );
end; 

Sleep içine 0.1 (10 salise), ya da 0.01 (1 salise) yazabilirsiniz (tam sayı vermek zorunda değilsiniz)