Note that there are some explanatory texts on larger screens.

plurals
  1. POEmbedded SQL in OO languages like Java
    primarykey
    data
    text
    <p>One of the things that annoys me working with SQL in OO languages is having to define SQL statements in strings.</p> <p>When I used to work on IBM mainframes, the languages used an SQL preprocessor to parse SQL statements out of the native code, so the statements could be written in cleartext SQL without the obfuscation of strings, for instance in Cobol there is a <em>EXEC SQL .... END-EXEC</em> syntax construct that allows <strong>pure SQL statements</strong> to be <strong>embedded</strong> in the Cobol code.</p> <pre><code>&lt;pure cobol code, including assignment of value to local variable HOSTVARIABLE&gt; EXEC SQL SELECT COL_A, COL_B, COL_C INTO :COLA, :COLB, :COLC FROM TAB_A WHERE COL_D = :HOSTVARIABLE END_EXEC &lt;more cobol code, variables COLA, COLB, COLC have been set&gt; </code></pre> <p>...this makes the SQL statement really easy to read &amp; check for errors. Between the <em>EXEC SQL .... END-EXEC</em> tokens there are no constraints on indentation, linebreaking etc., so you can format the SQL statement according to taste.</p> <p>Note that this example is for a single-row select, when a multiple-row resultset is expected, the coding is different (but still v. easy to read).</p> <p>So, taking Java as an example</p> <ol> <li><p>What made the <em>"old COBOL"</em> approach undesirable ? Not only SQL, but system calls could be made much more readable with that approach. Let's call it the <em>embedded foreign language preprocessor</em> approach. </p></li> <li><p>Would an <em>embedded foreign language preprocessor</em> for SQL be useful to implement ? Would you see a benefit in being able to write native SQL statements inside java code ?</p></li> </ol> <h2>Edit</h2> <p>I'm really asking if you think SQL in OO languages is a throwback, and if not then what could be done to make it better.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload