Skip to content

Instantly share code, notes, and snippets.

View PhilippSalvisberg's full-sized avatar

Philipp Salvisberg PhilippSalvisberg

View GitHub Profile
-- --------------------------------------------------------------------------------------------------------------------
-- Minimal Arbori program (expected by the formatter, also expected: "order_by_clause___0").
-- --------------------------------------------------------------------------------------------------------------------
include "std.arbori"
dummy: :indentConditions & [node) identifier;
skipWhiteSpaceBeforeNode: runOnce -> { var doNotCallCallbackFunction;}
dontFormatNode: [node) numeric_literal | [node) path ->;
-- --------------------------------------------------------------------------------------------------------------------
-- Keep existing whitespace.
@PhilippSalvisberg
PhilippSalvisberg / diy_any_value.sql
Last active June 6, 2022 12:50
Do-it-yourself implementation of any_value
-- ------------------------------------------------------------------------------------------------
-- do-it-yourself implementation of any_value for strings
-- based on http://db-oriented.com/2021/02/20/diy-any_value/
-- use Oracle Database 9i or higher, connected as HR user.
-- ------------------------------------------------------------------------------------------------
create or replace type any_value_string_t as object
(
v_value varchar2(4000),
static function odciaggregateinitialize(sctx in out any_value_string_t) return number,
[
{
"name":"com.trivadis.plsql.formatter.TvdFormat",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]}
,
{
"name":"java.lang.ClassLoader",
"methods":[
{"name":"getPlatformClassLoader","parameterTypes":[] },
{"name":"loadClass","parameterTypes":["java.lang.String"] }
@PhilippSalvisberg
PhilippSalvisberg / Demo.java
Last active July 31, 2021 14:00
GraalVM native image example to reproduce Exception in thread "main" javax.script.ScriptException: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (collect) on java.util.stream.ReferencePipeline$Head@4c320659 failed due to: Unknown identifier: collect
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
import org.graalvm.polyglot.Context;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import java.util.HashMap;
public class Demo {
public static void main(String[] args) throws ScriptException {
@PhilippSalvisberg
PhilippSalvisberg / om_tapigen.sql
Last active May 2, 2020 12:22
Issue 4 in Trivadis/plsql-cop-sqldev
CREATE OR REPLACE PACKAGE BODY om_tapigen IS
-----------------------------------------------------------------------------
-- private global constants (c_*)
-----------------------------------------------------------------------------
c_generator_error_number CONSTANT PLS_INTEGER := -20000;
c_lf CONSTANT VARCHAR2(2 CHAR) := chr(10);
c_lflf CONSTANT VARCHAR2(3 CHAR) := chr(10) || chr(10);
c_list_delimiter CONSTANT VARCHAR2(3 CHAR) := ',' || c_lf;
c_custom_defaults_present_msg CONSTANT VARCHAR2(30) := 'SEE_END_OF_API_PACKAGE_SPEC';
@PhilippSalvisberg
PhilippSalvisberg / procedure_accessors.sql
Last active May 4, 2018 08:15
White Listed PL/SQL Programs in Oracle Database 18c
/*
* Copyright 2018 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@PhilippSalvisberg
PhilippSalvisberg / Install_demo_apps.sql
Last active August 7, 2020 03:10
Check if an Oracle user is ready to be used by the connection pool of the middle tier for applications guarding data behind a hard shell PL/SQL API as defined by Bryn Llewellyn. See also https://www.salvis.com/blog/2017/12/17/how-to-prove-that-your-smartdb-app-is-secured-against-sql-injection-attacks/
/*
* Copyright 2017 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@PhilippSalvisberg
PhilippSalvisberg / 01_insert_sql.sql
Last active June 30, 2016 10:14
Parse simple insert statement via PL/SQL Analyzer, preserve order of insert and select columns (to answer question via LinkedIn Messaging)
INSERT
INTO tvd_captured_sql_t (
cap_id,
cap_source
)
VALUES (
tvd_captured_sql_seq.nextval,
q'[
insert into tab1 (x,y,z) select a,b,c from tab2 where tab2.n = 'N';
]'
@PhilippSalvisberg
PhilippSalvisberg / issue_26a.sql
Last active June 25, 2016 15:59
Issue oddgen/oddgen#26 - workaround for missing object_name children in navigator tree
/*
* Copyright 2016 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@PhilippSalvisberg
PhilippSalvisberg / wrap_schema.sql
Last active July 16, 2020 22:08
Wrap PL/SQL code in the current user of an Oracle database 10g or higher
/*
* Copyright 2016 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software