Skip to content

Instantly share code, notes, and snippets.

-- run as SYS or a user with APEX_ADMINISTRATOR_ROLE
begin
-- note: this does not work, as the REMOTE_ADDR variable will be 127.0.0.1 when using Apache as proxy
--apex_instance_admin.set_parameter ('RESTRICT_IP_RANGE', '1.2.3.4');
-- this solution requires this header to be set in Apache VirtualHost, based on whether the client IP is trusted or not
apex_instance_admin.set_parameter ('RESTRICT_DEV_HEADER', 'X-MyCompany-Public-Client');
commit;
end;
<VirtualHost *:443>
<Location "/ords">
# to use IP filtering with the RESTRICT_DEV_HEADER instance setting in APEX
<If "-R '1.2.3.4'">
# this is a trusted IP address
RequestHeader unset X-MyCompany-Public-Client
</If>
<Else>
@mortenbra
mortenbra / vscode_tasks_v2.json
Created May 20, 2021 08:28
Visual Studio Code build task for PL/SQL, with error/problem output
{
"version": "2.0.0",
// Run sqlplus via a batch file
"windows": {
"command": "./_run_sqlplus.bat"
},
"osx": {
"command": "./_run_sqlplus.sh"
},
@mortenbra
mortenbra / vscode_plsql_snippets.json
Created March 14, 2018 19:46
Visual Studio Code PL/SQL snippets
{
/*
// Place your snippets for PLSQL here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
@mortenbra
mortenbra / vscode_keybindings.json
Created March 14, 2018 19:44
Visual Studio Code custom keybindings
// Place your key bindings in this file to overwrite the defaults
[
{"key": "ctrl+shift+d", "command": "editor.action.copyLinesDownAction" }
,
{"key": "ctrl+r", "command": "workbench.action.gotoSymbol" }
,
{"key": "ctrl+shift+up", "command": "editor.action.moveLinesUpAction" }
,
{"key": "ctrl+shift+down", "command": "editor.action.moveLinesDownAction" }
-- generate a GUID in Oracle
select sys_guid()
from dual;
-- 50C2D6992A3481B5E0532637548C8476
-- convert it to a number
-- see https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7041297073738
@mortenbra
mortenbra / sqlplus_login.sql
Created March 20, 2017 17:33
login.sql file for sqlplus
-- enable compiler warnings
alter session set plsql_warnings = 'enable:all';
@mortenbra
mortenbra / vscode_run_sqlplus.sh
Created March 19, 2017 19:09
Bash script to run sqlplus from VS Code for Mac/Linux
#!/bin/sh
# make sure script uses correct environment settings for sqlplus
source ~/.profile
# run sqlplus, execute the script, then get the error list and exit
sqlplus $1 << EOF
$2
@_show_errors.sql
exit;
@mortenbra
mortenbra / vscode_tasks.json
Last active February 6, 2020 08:48
VS Code task runner configuration for PL/SQL
{
"version": "0.1.0",
// The command is a shell script
"isShellCommand": true,
// Run sqlplus via a batch file
"windows": {
"command": "_run_sqlplus.bat"
},
@mortenbra
mortenbra / vscode_show_errors.sql
Created March 18, 2017 14:18
Show errors from user_errors, formatted for easy parsing
set pagesize 9999
set linesize 9999
set heading off
set trim on
select lower(attribute) -- error or warning
|| ' '
|| line || '/' || position -- line and column
|| ' '
|| lower(name) -- file name