configDTDeploymentInfoQueryDB

PURPOSE ^

CONFIGDTDEPLOYMENTINFOQUERYDB Configure the query to retrieve delayed time glider deployment information.

SYNOPSIS ^

function [sql_query, deployment_fields] = configDTDeploymentInfoQueryDB()

DESCRIPTION ^

CONFIGDTDEPLOYMENTINFOQUERYDB  Configure the query to retrieve delayed time glider deployment information.

  Syntax:
    [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGDTDEPLOYMENTINFOQUERYDB()

  Description:
    [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGDTDEPLOYMENTINFOQUERYDB() should 
    return the SQL query to retrieve the information about glider deployments
    to be processed in delayed time. String SQL_QUERY is the query to execute. 
    The mapping between deployment fields and data base table columns is given 
    by the string cell array DEPLOYMENT_FIELDS. Deployment fields are described 
    in GETDEPLOYMENTINFODB.

  Notes:
    Edit this file filling in the field mapping of your data base and the
    query that returns that fields for each deployment.

  Examples:
    [sql_query, deployment_fields] = configDTDeploymentInfoQueryDB()

  See also:
    GETDEPLOYMENTINFODB

  Authors:
    Joan Pau Beltran  <joanpau.beltran@socib.cat>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

configDTDeploymentInfoQueryDB.m

SOURCE CODE ^

0001 function [sql_query, deployment_fields] = configDTDeploymentInfoQueryDB()
0002 %CONFIGDTDEPLOYMENTINFOQUERYDB  Configure the query to retrieve delayed time glider deployment information.
0003 %
0004 %  Syntax:
0005 %    [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGDTDEPLOYMENTINFOQUERYDB()
0006 %
0007 %  Description:
0008 %    [SQL_QUERY, DEPLOYMENT_FIELDS] = CONFIGDTDEPLOYMENTINFOQUERYDB() should
0009 %    return the SQL query to retrieve the information about glider deployments
0010 %    to be processed in delayed time. String SQL_QUERY is the query to execute.
0011 %    The mapping between deployment fields and data base table columns is given
0012 %    by the string cell array DEPLOYMENT_FIELDS. Deployment fields are described
0013 %    in GETDEPLOYMENTINFODB.
0014 %
0015 %  Notes:
0016 %    Edit this file filling in the field mapping of your data base and the
0017 %    query that returns that fields for each deployment.
0018 %
0019 %  Examples:
0020 %    [sql_query, deployment_fields] = configDTDeploymentInfoQueryDB()
0021 %
0022 %  See also:
0023 %    GETDEPLOYMENTINFODB
0024 %
0025 %  Authors:
0026 %    Joan Pau Beltran  <joanpau.beltran@socib.cat>
0027 
0028 %  Copyright (C) 2013-2016
0029 %  ICTS SOCIB - Servei d'observacio i prediccio costaner de les Illes Balears
0030 %  <http://www.socib.es>
0031 %
0032 %  This program is free software: you can redistribute it and/or modify
0033 %  it under the terms of the GNU General Public License as published by
0034 %  the Free Software Foundation, either version 3 of the License, or
0035 %  (at your option) any later version.
0036 %
0037 %  This program is distributed in the hope that it will be useful,
0038 %  but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 %  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0040 %  GNU General Public License for more details.
0041 %
0042 %  You should have received a copy of the GNU General Public License
0043 %  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0044 
0045   error(nargchk(0, 0, nargin, 'struct'));
0046 
0047   % Select the identifiers of deployments to process.
0048   deployment_ids = {'1' '2'};
0049   
0050   % Select the deployment fields.
0051   % First column is deployment field
0052   % Second column is column in data base table.
0053   fields_map = {
0054     'deployment_id'          'deployment_id'
0055     'deployment_name'        'deployment_name'
0056     'deployment_start'       'deployment_initial_date'
0057     'deployment_end'         'deployment_end_date'
0058     'glider_name'            'platform_name'
0059     'glider_serial'          'instrument_serial'
0060     'glider_model'           'instrument_model'
0061   };
0062 
0063   deployment_fields = fields_map(:,1)';
0064   database_fields = fields_map(:,2)';
0065 
0066   % Build the query.
0067   deployment_ids_str = ...
0068     [sprintf('%s, ', deployment_ids{1:end-1}) deployment_ids{end}];
0069   database_fields_str = ...
0070     [sprintf('%s, ', database_fields{1:end-1}) database_fields{end}];
0071   sql_query = ['select ' database_fields_str ...
0072                '  from instrumentation.deployment' ...
0073                '  inner join instrumentation.instrument' ...
0074                '    on (deployment_instrument_id=instrument_id)' ...
0075                '  inner join instrumentation.instrument_type' ...
0076                '    on (instrument_instrument_type_id=instrument_type_id)' ...
0077                '  inner join instrumentation.instrument_platform' ...
0078                '    on (instrument_platform_instrument_id=instrument_id and (instrument_platform_installation_date < deployment_end_date or deployment_end_date is null) and (deployment_initial_date < instrument_platform_uninstallation_date or instrument_platform_uninstallation_date is null))' ...
0079                '  inner join instrumentation.platform' ...
0080                '    on (instrument_platform_platform_id = platform_id)' ...
0081                '  inner join instrumentation.institution' ...
0082                '    on (deployment_institution_id=institution_id)' ...
0083                '  where (deployment_id in (' deployment_ids_str '));'];
0084 
0085 end

Generated on Fri 06-Oct-2017 10:47:42 by m2html © 2005