0

I was give an query, pulled from our ERP system, with curly braces {} in the FROM clause and was asked to put in another program but I have never see curly braces used in a FROM clause and don't understand how it works. I have never seen a FROM clause that has multiple tables joined with just a comma. Looking for a reference or answer that will help me understand this.

 FROM   { oj bin
   LEFT OUTER JOIN bin_replenishment ON bin.bin_uid = bin_replenishment.bin_uid },
   inv_bin inv_bin_a,
   inv_mast,
   inv_loc,
   inv_bin inv_bin_b

If it helps here is the full query

 SELECT
   inv_mast.item_id AS 'Item #',
   inv_loc.primary_bin AS 'Primary Bin',
   inv_loc.location_id,
    inv_bin_a.location_id,
   inv_bin_b.quantity AS 'Qty in Primary',
   inv_bin_b.qty_allocated AS 'Primary Bin Allocated',
   inv_bin_a.bin AS '2nd  Bin',
   inv_bin_a.quantity AS '2nd Bin Qty',
   inv_bin_a.qty_allocated AS '2nd Bin Allocated',
   inv_loc.qty_allocated AS 'Total Allocated',
   inv_mast.item_desc AS 'Item Description'
FROM
   { oj bin
   LEFT OUTER JOIN bin_replenishment ON bin.bin_uid = bin_replenishment.bin_uid },
   inv_bin inv_bin_a,
   inv_mast,
   inv_loc,
   inv_bin inv_bin_b
Kram_Koorbse
  • 442
  • 5
  • 19
  • 2
    Joining tables with commas is an old style which [should be avoided](https://sqlblog.org/2009/10/08/bad-habits-to-kick-using-old-style-joins). For the curly braces I have never seen them with TSQL either and therefore can only guess - probably your ERP does some processing with this statement which removes the braces before it actually is sent to the RDBMS. – Bill Tür stands with Ukraine Feb 08 '21 at 13:37
  • Tagging your ERP technology might help to attract the right people that can answer your question. – Sander Feb 08 '21 at 13:58

1 Answers1

2

Curly braces are used to show ODBC escape sequences which are used within an SQL statement to tell the driver that the escaped part of the SQL string should be handled differently.

Here are some links with more info...

Curly braces in T-SQL

Understanding the use of curly braces and "OJ" in a SQL query

https://learn.microsoft.com/en-us/sql/connect/jdbc/using-sql-escape-sequences?view=sql-server-ver15#:~:text=Escape%20sequences%20are%20used%20within,code%20that%20SQL%20Server%20understands.

WAMLeslie
  • 1,241
  • 1
  • 5
  • 14