Skip to content

Instantly share code, notes, and snippets.

View phpdave's full-sized avatar

UseTheForceDave phpdave

View GitHub Profile
<?
$javaProgramFileName="selenium-server-standalone";
$isSeleniumAlreadyRunning=false;
exec("wmic process where name=\"java.exe\" get commandline",$output);
foreach($output as $line)
{
if(strpos($line, $javaProgramFileName) !== FALSE)
{
$isSeleniumAlreadyRunning=true;
break;
/* Altering table MYLIB.CUSTMASPF */
ALTER TABLE MYLIB.CUSTMASPF
ADD COLUMN CUSTOMERNAME FOR CUSTNAME VARCHAR (100) NOT HIDDEN
ADD COLUMN CUSTOMERADDRESS FOR CUSTADDR VARCHAR (100) NOT HIDDEN;
/* Setting column labels for MYLIB.CUSTMASPF */
LABEL ON COLUMN MYLIB.CUSTMASPF (
CUSTOMERNAME TEXT IS 'Customer Name' ,
CUSTOMERADDRESS TEXT IS 'Customer Address' );
//return only 10 records, start on record 11 (OFFSET 10), records 11-20 are returned.
$sql = "SELECT * FROM CUSTOMERS LIMIT 10 OFFSET 10";
--View Object Locks
SELECT * FROM QSYS2.OBJECT_LOCK_INFO
WHERE SYSTEM_OBJECT_NAME = 'CUSTOMER';
--View Record Locks
SELECT JOB_NAME, COUNT(*) AS ROWS_UPDATING
FROM QSYS2.RECORD_LOCK_INFO
WHERE FILE_NAME = 'CUSTOMER' AND
LIBRARY_NAME = 'PRODUCTION' AND
LOCK_STATE = 'UPDATE'
GROUP BY JOB_NAME
@phpdave
phpdave / code-completion-examples.sql
Last active October 9, 2015 14:22
SQL Code-Completion examples for an enhancement to RUN SQL in IBM ACS
--Press CTRL+SPACE and it'll show a dop down of valid SQL (i.e. SELECT, GRANT, DROP, CREATE, etc...)
_
--Press CTRL+SPACE and it'll show a dop down of all libraries, and then all tables in the default library
SELECT * FROM _
--Press CTRL+SPACE and it'll show a dop down of all tables in MYLIB
SELECT * FROM MYLIB._
--Press CTRL+SPACE and it'll show a dop down of all columns in MYLIB.MYTABLE
@phpdave
phpdave / GenerateSQLForTable.sql
Last active July 17, 2017 21:33
Generate SQL for Table in DB2 For i
CALL QSYS2.GENERATE_SQL('MYTABLE', 'MYLIBRARY', 'TABLE', REPLACE_OPTION => '0');
--More info:
--https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/IBM%20i%20Technology%20Updates/page/QSYS2.GENERATE_SQL%28%29%20procedure
CALL QSYS2.GENERATE_SQL('%', 'MYLIB', 'PROCEDURE', REPLACE_OPTION => '1',CREATE_OR_REPLACE_OPTION => '1',PRIVILEGES_OPTION=>'1',SYSTEM_NAME_OPTION=>'1',LABEL_OPTION=>'1',COMMENT_OPTION=>'1'
-- ,
-- DATABASE_SOURCE_FILE_NAME=>'GENSQLSRC',
-- DATABASE_SOURCE_FILE_LIBRARY_NAME=>'MYLIB',
@phpdave
phpdave / .aliases
Last active February 24, 2023 11:06
Files to put in your /home/USER/ directory on IBM i to enable cool things in Bash
# .aliases
# vim:syntax=shexit
# Reload bash aliases
alias reload="source ~/.bash_profile"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
alias db2='function _db2(){ echo "Running $1"; system -i "call QSYS/QZDFMDB2 parm('\''$1'\'')"; };_db2'
db2 "SELECT * FROM MYLIB.MYTABLE"
#Get fancy and search the data
db2 "SELECT * FROM MYLIB.MYTABLE" | grep "Smith"
#Alternatively you can run it through qsh - https://kadler.github.io/2018/05/29/calling-qsh-utilities-from-pase.html
@phpdave
phpdave / alias.sh
Last active October 29, 2015 02:46
# IBMi aliases
alias db2='function _db2(){ echo "Running $1"; system -i "call QSYS/QZDFMDB2 parm('\''$1'\'')"; };_db2'
alias wrkactjob='function _wrkactjob(){ system WRKACTJOB; };_wrkactjob'
alias zendjobs='function _zendjobs(){ ps -ef | grep -i zend; };_zendjobs'
alias qccsid='function _qccsid(){ system "DSPSYSVAL SYSVAL(QCCSID)"; };_qccsid'
alias dsplibl='function _dsplibl(){ qsh -c '\''/QSYS.LIB/QSHELL.LIB/SYSTEM.PGM dsplibl'\''; system -i "DSPLIBL"; };_dsplibl'
# IBMi PHP
alias startzendserver='function _StartZendServer(){ system "STRTCPSVR SERVER(*HTTP) HTTPSVR(ZENDSVR)"; };_StartZendServer'
alias endzendserver='function _EndZendServer(){ system "ENDTCPSVR SERVER(*HTTP) HTTPSVR(ZENDSVR)"; };_EndZendServer'
@phpdave
phpdave / CopyTableToRemoteSys.sh
Last active November 12, 2015 22:10
Pseudo code for CopyTableToRemoteSys
#CopyTablesToRemoteSys $1 $2
#$1 Library
#$2 Table
function copytablestoremotesys()
{
#Clear our local temporary library
system "CLRLIB LIB(MYLIB.TEMP)";
#Copy our local file a from a real library to a temporary library
system "CPYF FROMFILE($1/$2) TOFILE(MYLIB.TEMP/$2) MBROPT(*REPLACE) CRTFILE(*YES)";
#Save all our objects in temporary location to a save file