Recent Comments

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

2014年1月21日 星期二

wwDBLookupCombo動態設定打開下拉選單時要顯示的內容

一般來說可以直接在屬性欄位中的selected中就可以設定要顯示的欄位內容
但因為在不同的資料表共用一個元件時,會因為不同的資料表欄位
而造成要動態去設定要顯示的內容,在切換時先clear,把之前的設定清除
然後用append或add去把後面的字串加入
lcn是欄位名稱
10是要顯示的欄位寬

以下的設定中有很多的\t \r \n這些,目前主要是直接看在屬性欄位設定好後所抓出的字串
wwDBLookupCombo->Selected->Clear();
wwDBLookupCombo->Selected->Append("lcn\t10\tlcn\t\t\r\n");
wwDBLookupCombo->Selected->Append("road_name\t40\troad_name\t\t\r\n");


實際測試最少要在欄位名稱和欄位寬的中間加入\t即可
wwDBLookupComboAddEquipmentLcn->Selected->Clear();
wwDBLookupComboAddEquipmentLcn->Selected->Append("lcn\t10\tlcn");
wwDBLookupComboAddEquipmentLcn->Selected->Append("road_name\t40\tnroad_name");




2014年1月16日 星期四

[BCB]找出同一層內的Component

找出同一層內的Component
於function可以再定義要找的Component type

this->test(this->GroupBox1);
======================================================
void TForm1::test(TWinControl* pObj)
{
    for (unsigned short int i=0 ; iControlCount ; i++)
    {
            if (String(pObj->Controls[i]->ClassName())==”TEdit”)
            {
                ((TEdit *)pObj->Controls[i])->Text = “get it”;
            }
            if (String(pObj->Controls[i]->ClassName())==”TLabel”)
            {
                ((TEdit *)pObj->Controls[i])->Text = “get it”;
            }
    }
}

2014年1月14日 星期二

MSSQL 防止儲存需要資料表重建的變更

當修改MSSQL資料表的資料型態或是否null時出現『防止儲存需要資料表重建的變更』
主要是因為某些設定會造成格式不符資料流失所出現的提醒,但在開發建立時會時常修改
可以在
『SQL Server Management Studio(SSMS) ->工具->選項->設計師->資料表和資料庫設計工具』
頁面中的『防止儲存需要資料表重建的變更』取消勾選後點選『確定』即可。




2013年12月25日 星期三

unknown picture file extension (.png)

fcImager1->Picture->LoadFromFile(progPath+"bibibi.png");

當動態找入png圖檔時出現『unknown picture file extension (.png)』

在該cpp檔案前加入
#pragma link "pngimage"

建議先clean project後再重編一次。


若要找入jpg圖檔include jpeg.hpp
#include

2013年12月24日 星期二

ORA-00059: maximum number of DB_FILES exceeded

alter system set db_files=300 scope=spfile;
shutdown immediate
startup


SQL> show parameter db_files

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_files     integer 200
SQL> alter system set db_files=300 scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  570425344 bytes
Fixed Size    2097888 bytes
Variable Size  205524256 bytes
Database Buffers  356515840 bytes
Redo Buffers    6287360 bytes
Database mounted.
Database opened.
SQL> show parameter db_files

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_files     integer 300

2013年12月20日 星期五

PostgreSQL 安裝 pldebugger USE_PGSX

PostgreSQL 安裝 pldebugger USE_PGSX

使用 USE_PGSX=1 make,在pldebugger編好後就會直接把編好的plugin_debugger.so和pldbgapi--1.0.sql放到/usr/pgsql-9.3相對應的位置。

yum install git readline-devel zlib-devel openssl-devel

cd /opt
tar xvzf postgresql-9.3.2.tar.gz

cd /opt/postgresql-9.3.2
USE_PGXS=1 ./configure
USE_PGXS=1 make

cd /opt/postgresql-9.3.2/contrib/
git clone git://git.postgresql.org/git/pldebugger.git
make 

cd /opt/postgresql-9.3.2/contrib/pldebugger
USE_PGXS=1 make
USE_PGXS=1 make install

[root@localhost pldebugger]# USE_PGXS=1 make install                                                                                                         gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/include/et -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -shared -o plugin_debugger.so plpgsql_debugger.o plugin_debugger.o dbgcomm.o pldbgapi.o -L/usr/pgsql-9.3/lib -L/usr/lib64 -Wl,--as-needed
/bin/mkdir -p '/usr/pgsql-9.3/lib'
/bin/mkdir -p '/usr/pgsql-9.3/share/extension'
/bin/mkdir -p '/usr/pgsql-9.3/share/extension'
/bin/mkdir -p '/usr/share/doc/pgsql/extension'
/usr/bin/install -c -m 755  plugin_debugger.so '/usr/pgsql-9.3/lib/plugin_debugger.so'
/usr/bin/install -c -m 644 ./pldbgapi.control '/usr/pgsql-9.3/share/extension/'
/usr/bin/install -c -m 644 ./pldbgapi--1.0.sql ./pldbgapi--unpackaged--1.0.sql  '/usr/pgsql-9.3/share/extension/'
/usr/bin/install -c -m 644 ./README.pldebugger '/usr/share/doc/pgsql/extension/'


vim /var/lib/pgsql/9.3/data/postgresql.conf
加入下面的設定
shared_preload_libraries = '$libdir/plugin_debugger'

重新啟動
service postgresql-9.3 restart

安裝pldbgapi
su - postgres
psql
CREATE EXTENSION pldbgapi;
\dx

-bash-4.1$ psql
psql (9.3.2)
Type "help" for help.

postgres=# CREATE EXTENSION pldbgapi;
CREATE EXTENSION
postgres=# \dx
                              List of installed extensions
   Name    | Version |   Schema   |                     Description
-----------+---------+------------+------------------------------------------------------
adminpack | 1.0     | pg_catalog | administrative functions for PostgreSQL
pldbgapi  | 1.0     | public     | server-side support for debugging PL/pgSQL functions
plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
(3 rows)

================================================================
當pldebugger在USE_PGXS=1 make時出現下面的錯誤要安裝 openssl-devel套件,安裝好後再重新執行USE_PGXS=1 make

[root@localhost pldebugger]# USE_PGXS=1 make
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I/usr/include/et -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fpic -I. -I. -I/usr/pgsql-9.3/include/server -I/usr/pgsql-9.3/include/internal -I/usr/include/et -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include  -c -o pldbgapi.o pldbgapi.c
In file included from pldbgapi.c:98:
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:25:25: error: openssl/ssl.h: No such file or directory
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:26:25: error: openssl/err.h: No such file or directory
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:36:27: error: gssapi/gssapi.h: No such file or directory
In file included from pldbgapi.c:98:
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:86: error: expected specifier-qualifier-list before ‘gss_buffer_desc’
/usr/pgsql-9.3/include/server/libpq/libpq-be.h:176: error: expected specifier-qualifier-list before ‘SSL’
make: *** [pldbgapi.o] Error 1

PL/SQL 和 PL/pgSQL 旅行時間TRIGGER

以下TRIGGER內容主要是當區段旅行時間比對成功後,在INSERT AVI_SECTION_TRAVEL資料表後會執行下面的TRIGGER,將新的旅行時間更新到XML_AVI_VALUE表中,因為資料的時間需要是每五分鐘的顯示,如5分、10分,N_MIN_FIND就是找出現在旅行時間是在那個五分鐘區間中,如旅行時間是20131221 12:12:30,則 N_MIN_FIND會是20131221 12:15:00

以下是ORACLE和POSTGRESQL的寫法,主要差異在N_MIN_MOD和N_MIN_FIND兩個變數

ORACLE
=====================================================================
DECLARE
C_MIN_LOG_RANGE CONSTANT INTEGER := 5; --統計分鐘數
  N_MIN_MOD INTEGER;       --取餘數
  N_MIN_ADD INTEGER;       --以旅行時間要加的分鐘數 (統計分鐘數 - N_MIN_MOD)
  N_MIN_FIND TIMESTAMP;    --找volume記錄時間  = 旅行時間 + N_MIN_ADD
N_RECORD_COUNT INTEGER;
BEGIN
N_MIN_MOD := MOD(TO_CHAR(:NEW.DATETIME,'MI'),C_MIN_LOG_RANGE);
  N_MIN_ADD := C_MIN_LOG_RANGE-N_MIN_MOD;
  N_MIN_FIND := TO_TIMESTAMP(TO_CHAR(:NEW.DATETIME+(N_MIN_ADD/1440),'YYYY-MM-DD HH24:MI'),'YYYY-MM-DD HH24:MI');

SELECT COUNT(SECTION_ID) INTO N_RECORD_COUNT FROM XML_AVI_VALUE WHERE SECTION_ID=:NEW.SECTION_ID;

IF N_RECORD_COUNT>0 THEN
UPDATE XML_AVI_VALUE SET TRAVELTIME=:NEW.TRAVEL_SMOOTH,DATACOLLECTTIME=N_MIN_FIND  WHERE SECTION_ID=:NEW.SECTION_ID;
END IF;
END;


POSTGRESQL
=====================================================================
DECLARE
C_MIN_LOG_RANGE CONSTANT INTEGER := 5; --統計分鐘數
N_MIN_MOD INTEGER;       --取餘數
N_MIN_ADD INTEGER;       --以旅行時間要加的分鐘數 (統計分鐘數 - N_MIN_MOD)
N_MIN_FIND TIMESTAMP;     --找volume記錄時間  = 旅行時間 + N_MIN_ADD
N_RECORD_COUNT INTEGER; --找出XML_AVI_VALUE資料表中是否有該SECTION_ID的資料
BEGIN--

--insert avi_xml_value
        N_MIN_MOD := MOD(to_number(TO_CHAR(NEW.datetime,'MI'),'99'),C_MIN_LOG_RANGE);
        IF N_MIN_MOD=0 THEN
   N_MIN_ADD := 0;
ELSE
   N_MIN_ADD := C_MIN_LOG_RANGE-N_MIN_MOD;
END IF;

N_MIN_FIND := TO_TIMESTAMP(TO_CHAR(NEW.datetime,'YYYY-MM-DD HH24:MI'),'YYYY-MM-DD HH24:MI')+(TO_TIMESTAMP(TO_CHAR(N_MIN_ADD,'99'),'MI')-TO_TIMESTAMP(TO_CHAR(0,'99'),'MI'));

SELECT COUNT(SECTION_ID) INTO N_RECORD_COUNT FROM XML_AVI_VALUE WHERE SECTION_ID=NEW.SECTION_ID;

IF N_RECORD_COUNT>0 THEN
   UPDATE XML_AVI_VALUE SET TRAVELTIME=NEW.TRAVEL_SMOOTH,DATACOLLECTTIME=N_MIN_FIND  WHERE SECTION_ID=NEW.SECTION_ID;
END IF;
END;