Fiber Optic Test Results SQL Schema and Pass/Fail Query Generator
Test results kept on the test PC are hard to trend or find when a customer asks about a serial number. This generator writes a simple table for insertion loss and return loss results and the queries you need for failures, yield and operator comparison.
Fill in
Per mated pair or per assembly, from your specification
For example 50 dB for UPC singlemode, 60 dB for APC, as specified
1. Create the table
CREATE TABLE fiber_test_result ( test_id INTEGER PRIMARY KEY, serial_no VARCHAR(40) NOT NULL, work_order VARCHAR(30), part_no VARCHAR(40), fiber_no INTEGER, wavelength_nm INTEGER NOT NULL, insertion_loss_db DECIMAL(6,3), return_loss_db DECIMAL(6,2), length_m DECIMAL(10,2), operator_id VARCHAR(20), meter_serial VARCHAR(40), tested_at TIMESTAMP NOT NULL ); CREATE INDEX ix_fiber_test_result_serial ON fiber_test_result (serial_no); CREATE INDEX ix_fiber_test_result_date ON fiber_test_result (tested_at);
2. Sample insert
INSERT INTO fiber_test_result (test_id, serial_no, work_order, part_no, fiber_no, wavelength_nm, insertion_loss_db, return_loss_db, length_m, operator_id, meter_serial, tested_at) VALUES (1, 'SN-000101', 'WO-5521', 'JMP-LC-SM-2M', 1, 1310, 0.12, 54.5, 2.0, 'OP17', 'PM-3302', '2026-10-01 09:15:00');
3. Units that fail the limits
SELECT serial_no, fiber_no, wavelength_nm, insertion_loss_db, return_loss_db, tested_at FROM fiber_test_result WHERE wavelength_nm = 1310 AND tested_at >= '2026-10-01' AND tested_at < '2026-10-31' AND (insertion_loss_db > 0.30 OR return_loss_db < 50) ORDER BY tested_at;
4. First-pass yield by day
SELECT CAST(tested_at AS DATE) AS test_day,
COUNT(*) AS tests,
SUM(CASE WHEN insertion_loss_db <= 0.30 AND return_loss_db >= 50 THEN 1 ELSE 0 END) AS passed,
100.0 * SUM(CASE WHEN insertion_loss_db <= 0.30 AND return_loss_db >= 50 THEN 1 ELSE 0 END) / COUNT(*) AS pass_pct
FROM fiber_test_result
WHERE wavelength_nm = 1310
AND tested_at >= '2026-10-01' AND tested_at < '2026-10-31'
GROUP BY CAST(tested_at AS DATE)
ORDER BY test_day;5. Loss statistics by operator
SELECT operator_id,
COUNT(*) AS tests,
AVG(insertion_loss_db) AS avg_il_db,
MAX(insertion_loss_db) AS max_il_db,
MIN(return_loss_db) AS min_rl_db
FROM fiber_test_result
WHERE wavelength_nm = 1310
AND tested_at >= '2026-10-01' AND tested_at < '2026-10-31'
GROUP BY operator_id
ORDER BY avg_il_db DESC;Generic ANSI-style SQL. Adjust types, CAST and date syntax for your database (SQL Server, PostgreSQL, Oracle, MySQL). Column names are examples, not a vendor schema. Use limits from your own specification.
Test data to ERP integration
Optional: a short discussion on loading test results into your ERP or quality database.
Optional. The tool and every export work without this. No spam.
How to use the generator
Fill in a table name, your insertion loss and return loss limits, the test wavelength and the report dates. Copy the SQL into your database tool, create the table, and load results from your test software export. The queries then show failing serial numbers, daily first-pass yield and loss statistics by operator.
Why store results by serial number
Keeping every measurement keyed by serial number, work order and wavelength lets you answer customer questions in seconds and compare results over time. It also allows traceability to the meter serial, which matters when a calibration issue is found later. The schema is intentionally narrow so you can load CSV exports from most test software.
- Index on serial number for customer lookups.
- Index on date for yield reports.
- Store the meter serial to trace calibration issues.
Things to verify
Check the insertion loss limit per standard or customer: for example, TIA-568 allows up to 0.75 dB per mated connector pair in a cabling channel, but a factory-tested jumper often has a much tighter limit. Return loss is higher is better, so the fail test uses a less-than comparison. Decide how to treat multiple retests of the same serial: keep all records and query the latest, or add a retest flag.
Frequently Asked Questions
Why is return loss compared with less than?
Return loss is a positive dB value where higher is better, since it means less light is reflected. A unit fails when its value is below the minimum, so the failing condition uses a less-than comparison.
Can I use this in SQL Server or PostgreSQL?
Yes, with small changes. Replace TIMESTAMP with DATETIME2 in SQL Server, and adjust the CAST to DATE where needed. The structure and queries are standard SQL.
How do I handle retests?
Store every test with its time, then query the latest row per serial number using a window function or a subquery on the maximum tested_at. This keeps the history and gives an accurate final result.
Should I store OTDR traces here too?
Store the trace files in a file store and keep the file path or ID in this table, along with event summary values if needed. Trace data is large and better kept outside relational tables.
Netray can connect this kind of test table to your ERP serial and work order data so quality and production see the same record.
Related Tools
Fiber Optic Installation Pre-Test Checklist
Step-by-step checklist to run before Tier 1 loss and Tier 2 OTDR testing so results are valid and repeatable.
Quality & InspectionFiber Optic Assembly Process Control Assessment
Ten questions that score how well your fiber assembly and test process is controlled, with next actions by score band.
Quality & InspectionFiber Optic Jumper Final Test Batch Worksheet
Batch test sheet for patch cords and jumpers: insertion loss, return loss, limits, margin and automatic pass flag with batch yield.
Industry TemplatesFiber Optic Certification Test Acceptance Report Template
A handover report for certified fiber links: project data, test equipment, method, results table, pass criteria and customer acceptance.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator