Skip to content

Instantly share code, notes, and snippets.

--::REMOVED:: Can only use IF statement in a Stored Procedure
--If no SCRAPNEW Library create one w/ current user profile
--IF (NOT EXISTS(SELECT * FROM TABLE(SYSIBM.SCHEMAS()) AS SCHEMAS WHERE ODOBNM='SCRAPNEW')) THEN
-- CREATE SCHEMA SCRAPNEW;
--END IF;
/* Creating table SCRAPNEW.CUSTOMERS */
CREATE TABLE SCRAPNEW.CUSTOMERS (
ID BIGINT GENERATED ALWAYS AS IDENTITY (
START WITH 1, INCREMENT BY 1,
@phpdave
phpdave / gist:efe4a47e560041946d9d
Last active August 29, 2015 14:18
Nifty Linux commands
#To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
find /directory_path -mtime -1 -ls
#Send this to me in an email -- SECURITY WARNING your sending file and directory structure over insecure email
find ./ -mtime -1 -ls | mail -s subject user@gmail.com
#attempt at conditional sending
[[ -n `find ./ -mtime -1 -ls` ]] && { find ./ -mtime -1 -ls | mail -s subject user@gmail.com;}
@phpdave
phpdave / Persistent
Last active August 29, 2015 14:18
PHP/Web development to iOS Swift Development - notes about switching from PHP dev to swift development
Doctrine ~ Core Data (Database Abstration Layer)
Create Database Schema ~ New File - Core Data -> Data Model (Visual Map)
Table Name and columns ~ Entities and Attributes
mysql_connect ~ UIManagedObjectContext (adds managedObjectContext var to AppDelegate) or UIManagedDocument (allows syncing with iCloud)
DB select = NSManagedObjectContext's executeFetchReqest()
DB insert statement = NSEntityDescription.insertNewObjectForEntityForName
DB bind class variable to databse = @NSManaged var (getting and setting this var comes from the Database)
DB bind Select to UI Table = NSFetchedResultsController takes a fetchRequest and associate it with a table view and it will show
Using the filesystem
@phpdave
phpdave / A read me.txt
Last active August 29, 2015 14:20
Thinking about JSONService for IBM i
I think the main advantages are readability and simplicity (no root xml element, or closing tags).
XML vs JSON article: http://www.mashery.com/blog/api-data-exchange-xml-vs-json
@phpdave
phpdave / SQLProcedureChangeLibraryListCallExternalRPG.sql
Created May 13, 2015 19:04
Example of how you can change the library list in a SQL stored procedure before calling an external RPG program that may require that Library.
CREATE PROCEDURE MYLIB.SQLSTOREDPROCEDURE (
IN MYNUMBER DECIMAL(9, 0),
INOUT RESULT CHAR(1) )
LANGUAGE SQL
BEGIN
DECLARE CMD CHAR ( 300 ) DEFAULT ' ' ;
DECLARE CURRENTDATE CHAR ( 8 ) DEFAULT ' ' ;
--Ignore the error message that occurs if you add the library list twice
--Create a variable that has the SQLSTATE value and create a CONTINUE HANDLER for that
@phpdave
phpdave / post.js
Last active August 29, 2015 14:21
$("#table tbody").click(function(event) {
rowid = $(event.target.parentNode.childNodes[0]).html();
$.post(
"/Application/Controller/Action",
{
"ID" : rowid
},
function(response)
@phpdave
phpdave / test.php
Created June 15, 2015 15:01
Testing PHP7 Alpha 's new features in windows command line (cmd.exe)
<?
//Testing PHP7 new features in windows command line
echo PHP_EOL;
//Null Coalesce Operator
echo '#### Null Coalesce Operator ####'. PHP_EOL;
$arguments[] = $argv[0];//Script Name (c:\PHP7\scripts\test.php)
$arguments[] = $argv[1] ?? "DefaultValue";//If we don't pass 2nd argument we'll set it to zero using the new Null Coalesce Operator
var_dump($arguments);
echo PHP_EOL . PHP_EOL;
@phpdave
phpdave / Password_hash_with_random_bytes.php
Last active December 15, 2015 11:42
Testing PHP7 Alpha 's new features. Using the new random_bytes() for password_hash()
<?
//Using random_bytes as the salt for a password hash. random_bytes is a CSPRNG (cryptographically strong random number (bytes) generator)
echo '#### Password Hash ####'. PHP_EOL;
$options = [
'cost' => 11,
'salt' => random_bytes($length = 22),
];
echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options)."\n";
<?
$sql="
SELECT CURRENT CLIENT_ACCTNG AS ACCOUNTINGSTRINGSPCREG,
CURRENT CLIENT_APPLNAME AS APPLICATIONNAMESPCREG,
CURRENT CLIENT_PROGRAMID AS CLIENTPROGRAMIDSPCREG,
CURRENT CLIENT_USERID AS CLIENTUSERIDSPCREG,
CURRENT CLIENT_WRKSTNNAME AS WORKSTATIONNAMESPCREG,
CURRENT_DATE AS CURRENTDATESPCREG,
CURRENT DEBUG MODE AS DEBUGMODESPCREG,
CURRENT DECFLOAT ROUNDING MODE AS DECROUNDINGMODESPCREG,
@phpdave
phpdave / _results.txt
Created June 23, 2015 18:51
Testing Dynamic Compound statement to IBM i V7R1 TR10 on a JDBC connection via JTopen 8.5 driver in Netbeans 8.0.2. DC statements work in STRSQL and System I Navigator "Run SQL"
BEGIN
DECLARE V_ERROR BIGINT DEFAULT 0;
END
Error code -104, SQL state 42601: [SQL0104] Token <END-OF-STATEMENT> was not valid. Valid tokens: ;. Cause . . . . . : A syntax error was detected at token <END-OF-STATEMENT>. Token <END-OF-STATEMENT> is not a valid token. A partial list of valid tokens is ;. This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery . . . : Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token <END-OF-STATEMENT>. Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.
Line 1, column 1
Error code -104, SQL state 42601: [SQL0104] Token <END-OF-STATEMENT> was not valid. Valid to