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.

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;

PostgreSQL 安裝 pldebugger

yum install git readline-devel zlib-devel

cd /opt
tar xvzf postgresql-9.3.2.tar.gz
cd /opt/postgresql-9.3.2/contrib/
git clone git://git.postgresql.org/git/pldebugger.git

cd /opt/postgresql-9.3.2
./configure
make

cd /opt/postgresql-9.3.2/contrib/pldebugger
make
make install

/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/share/doc//extension'
/usr/bin/install -c -m 755  plugin_debugger.so '/usr/local/pgsql/lib/plugin_debugger.so'
/usr/bin/install -c -m 644 ./pldbgapi.control '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./pldbgapi--1.0.sql ./pldbgapi--unpackaged--1.0.sql  '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 ./README.pldebugger '/usr/local/pgsql/share/doc//extension/'

cp /usr/local/pgsql/lib/plugin_debugger.so /usr/pgsql-9.3/lib/  
cp /usr/local/pgsql/share/extension/pldbgapi--1.0.sql /usr/pgsql-9.3/share/extension/  
cp /usr/local/pgsql/share/extension/pldbgapi--unpackaged--1.0.sql /usr/pgsql-9.3/share/extension/
cp /usr/local/pgsql/share/extension/pldbgapi.control /usr/pgsql-9.3/share/extension/

vim /var/lib/pgsql/9.3/data/postgresql.conf
加入
shared_preload_libraries = '$libdir/plugin_debugger'

service postgresql-9.3 restart

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)

postgres=#