Better HN
topnewbestaskshowjobs
Log inSign up

bchammer

3 karma · joined May 8, 2015 (11y ago) · 13 submissions

Submissions

comment 1y ago · link · parent

Oracle Database can do that with a feature called 'SQL Macros'

https://docs.oracle.com/en/database/oracle/oracle-database/2...

SQL> create table test_pallets (pallet_id number);

Table created.

SQL> insert into test_pallets values (1),(2),(3),(4);

4 rows created.

SQL> create table test_boxes (pallet_id number, mass decimal);

Table created.

SQL> insert into test_boxes values (1,10),(1,20),(2, 5),(4, 5),(4, 50);

5 rows created.

SQL> create function pallet_payload_mass( 2 p dbms_tf.table_t, 3 b dbms_tf.table_t 4 ) return clob SQL_Macro as 5 begin 6 return q'{ 7 select 8 p.pallet_id, 9 coalesce(sum(b.mass), 0) as payload_mass 10 from 11 p 12 left outer join 13 b on b.pallet_id = p.pallet_id 14 group by 15 p.pallet_id 16 }'; 17 end; 18 /

Function created.

SQL> select payload_mass, pallet_id 2 from pallet_payload_mass(test_pallets, test_boxes) 3 order by payload_mass;

PAYLOAD_MASS PALLET_ID ------------ ---------- 0 3 5 2 30 1 55 4

comment 3y ago · link · parent

Oracle is now the leading JSON database, not only with a binary JSON datatype (allowing true piece-wise updates on disk and fast 'jump-navigation for super fast queries), but also JSON Schema support (for schema enforcement, type casting, to describe database objects and auto-generate relational views over JSON) and with JSON Duality it's possible to access (read/write) the same data as table as well as as (MongoDB compatible) collections.

comment 4y ago · link · parent

This looks like a turing-complete language if you add function. One benefit or current SQL is that it can (and is) often rewritten to be executed more efficiently. This requires a simpler and declarative model - far from a programming language.

If you want simple 'forward declaration' take a look at the SQL WITH clause.

4.

Oracle Database API for MongoDB(blogs.oracle.com ↗)

3 points · by bchammer · 4y ago · discuss

comment 5y ago · link · parent

also possible with Oracle

https://blogs.oracle.com/database/post/introducing-oracle-da...

comment 5y ago · link · parent

https://twitter.com/bch_t/status/1446693597093384193

7.

Oracle Database API for MongoDB(asktom.oracle.com ↗)

1 points · by bchammer · 5y ago · 1 comment

8.

Retire your tables – it's all JSON now (is it?)(youtube.com ↗)

2 points · by bchammer · 5y ago · discuss

9.

Data model comparison: JSON (embedding) versus relational (linking)(youtube.com ↗)

5 points · by bchammer · 5y ago · 1 comment

10.

JSON or Tables as application persistence model(youtube.com ↗)

3 points · by bchammer · 5y ago · 1 comment

11.

Native JSON data type added to SQL and JDBC(blogs.oracle.com ↗)

9 points · by bchammer · 5y ago · discuss