drop function get_custom_guid;
create function get_custom_guid
return varchar2 is
l_guid varchar2(36);
begin
select substr(guid,0,8) || '-' || substr(guid, 9,4) || '-' || substr(guid, 13,4)|| '-' || substr(guid, 17,4) || '-' || substr(guid,21)<
into l_guid from (select sys_guid() as guid from dual) ;
return l_guid;
end;
select get_custom_guid() guid from dual;
My Technical Diary
Labels
- design patterns software (1)
- external ip (1)
- gmail java mail connect smtp (1)
- install (1)
- java oracle apps jdbc log base 2 (1)
- macbook pro (1)
- oci8 driver (1)
- Oracle (1)
- php (1)
- SugarCRM (1)
Tuesday, February 9, 2016
Get a custom GUID in Oracle
Get external IP of a server machine in PHP
- $externalContent = file_get_contents('http://checkip.dyndns.com/');preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent, $m);$externalIp = $m[1];//AppleConnect Configuration$sugar_config['AppleConnectIpKey'] = $externalIp;
Tuesday, September 1, 2015
Installing SugarCRM with Oracle backend on a Macbook Pro
Pre-requisites
- MAMP installation pointing to 5.4.42 or Higher version of PHP (PHP version may change in future)
- SugarCRM Codebase (we are using 7.8.RC1 as of now)
- Oracle Instant Client , SDK and SQLPlus
- If (OS Codename >= El Capitan)
- Refer to answer by Chris Ostmo in http://stackoverflow.com/questions/32590053/copying-file-under-root-got-failed-in-os-x-el-capitan-10-11
- else
- Take the plunge !!!
Steps
- Verify if OCI8 driver is already enabled on your PHP installation (mostly not)
- Start Apache from MAMP
- Click OpenWebstart page (or) launch http://localhost:8888/MAMP/?language=English
- Launch PHPInfo : http://localhost:8888/MAMP/index.php?language=English&page=phpinfo
- Verify OCI8 installation
- If not install OCI8 following the steps
- Enable PHP to connect to Oracle
- Install Oracle Client for Mac
- Download : Oracle Instant Client, SQLPlus and SDK (http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)
- Extract contents of zip files to a common folder /Library/Oracle/instantclient_11_2
- The next step is to copy the necessary files into your OS X dynamic library and bin directories. Open a terminal window and go to the directory above the one you created containing all the files you unzipped.
sudo cp /Library/Oracle/instantclient_11_2/sdk/include/*.h /usr/include
sudo cp /Library/Oracle/instantclient_11_2/sqlplus /usr/bin
sudo cp /Library/Oracle/instantclient_11_2/*.dylib /usr/lib
sudo cp /Library/Oracle/instantclient_11_2/*.dylib.* /usr/libsudo ln -s libclntsh.dylib.11.1 libclntsh.dylib
Now "cd" to the/usr/lib
directory and create the following link:sudo ln -s libclntsh.dylib.11.1 libclntsh.dylib
- Export Environment variables
export ORACLE_HOME=/Library/Oracle/instantclient_11_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
export DYLD_LIBRARY_PATH=
/Library/Oracle/instantclient_11_2
/export MAMP_PATH=/Applications/MAMP/bin/php/php5.3.29/bin
export PATH=$MAMP_PATH:$PATH:$ORACLE_HOME:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
- Install OCI8 driver as extension for PHP
- Download the source for the version of php that you are using in MAMP (e.g.: 5.4.42 in this case).
- Extract the PHP source file and move the created folder to the following location (based on PHP version): /Applications/MAMP/bin/php/php5.3.29/include/php. (The contents of the extracted folder should be in the root of ../include/php)
- navigate to include/php folder and execute ./configure
- Run sudo pecl install oci8
- When Prompted, use instantclient,
/Library/Oracle/instantclient_11_2
/ as the Oracle instant Client path.- If you faced an error for AUTOCONF not found, (you don't have it installed in your MAC)
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
- export PHP_AUTOCONF=/usr/bin/autoconf
- rerun the same command
- If you faced an error for AUTOCONF not found, (you don't have it installed in your MAC)
- If all went well, the last line of the build process should say: You should add "extension=oci8.so" to php.ini
- Open php.ini from /Applications/MAMP/bin/php/php5.3.29/conf and make the entry for extension=oci8.so at the end of the current extensions
- Open /Applications/MAMP/Library/bin/envvars and add the path to the instant client library:
DYLD_LIBRARY_PATH="
”/Library/Oracle/instantclient_11_2
/:/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH
- When Prompted, use instantclient,
- Restart MAMP
- Verify OCI8 library from phpinfo page
- Install Oracle Client for Mac
- Connecting to Oracle Instance
- PHP Connects to Oracle through OCI8 driver
- OCI8 Driver relies on using tnsnames.ora
- tnsnames.ora is expected under $TNS_ADMIN and/or /etc folder
- Populate entry for your Oracle DB in tnsnames.ora
- Note : If you maintain tnsnames.ora under both $ORACLE_HOME/network/admin and/or /etc folders ensure to keep them in Sync
- Sample :
sugarcrm1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (service_name = orcl) ) )
- PHP Connects to Oracle through OCI8 driver
- Verify Connectivity to Oracle through OCI8
- Sqlplus schemaname/password@tnsentry_name from Terminal
- You should be prompted with SQL > on successful Connection
- Verifying Connection from PHP
- create a file connect.php under docroot folder configured for MAMP Apache as below
- $conn = oci_connect('system', 'oracle', 'sugarcrm1');
- if(!$conn){
- echo " Sorry 1 no donut for you !!\n";
- $e = oci_error();
- echo "
" .htmlentities($e['message'], ENT_QUOTES)."
- Yes Got connection for you !!
08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 08-JUL_2015 10:50:09 .....
Sugar Installation with Oracle
Follow “Installation Procedure” section in Sugar Installation Guide (https://support.sugarcrm.com/04_Knowledge_Base/02Administration/100Install/Installing_Sugar_with_an_Oracle_Database/)
References
Labels:
install,
macbook pro,
oci8 driver,
Oracle,
SugarCRM
Subscribe to:
Posts (Atom)