#include "owa_util.hpp"
|
|
#include <ctime>
|
#include <cstring>
|
#include <iomanip>
|
#include <limits>
|
#include <numeric>
|
#include <sstream>
|
#include <string>
|
#include <vector>
|
|
#include "dbms/htp.h"
|
|
extern "C"
|
{
|
#include "utils/builtins.h"
|
#include "utils/elog.h"
|
#include "utils/lsyscache.h"
|
#include "executor/executor.h"
|
}
|
|
#include "dbms/htp.h"
|
|
extern "C"
|
{
|
|
PG_FUNCTION_INFO_V1(owa_util_bind_variables);
|
PG_FUNCTION_INFO_V1(owa_util_calendarprint_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_calendarprint_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr3);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr4);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr5);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr6);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr7);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr8);
|
PG_FUNCTION_INFO_V1(owa_util_cellsprint_ovr9);
|
PG_FUNCTION_INFO_V1(owa_util_choose_date);
|
PG_FUNCTION_INFO_V1(owa_util_comma_to_ident_arr_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_comma_to_ident_arr_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_describe_cols);
|
// PG_FUNCTION_INFO_V1(owa_util_get_cgi_env);
|
PG_FUNCTION_INFO_V1(owa_util_get_owa_service_path);
|
PG_FUNCTION_INFO_V1(owa_util_get_procedure);
|
PG_FUNCTION_INFO_V1(owa_util_get_version);
|
PG_FUNCTION_INFO_V1(owa_util_ite);
|
PG_FUNCTION_INFO_V1(owa_util_listprint_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_listprint_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_mime_header);
|
PG_FUNCTION_INFO_V1(owa_util_name_resolve);
|
PG_FUNCTION_INFO_V1(owa_util_path_to_me);
|
PG_FUNCTION_INFO_V1(owa_util_redirect_url);
|
PG_FUNCTION_INFO_V1(owa_util_resolve_table);
|
PG_FUNCTION_INFO_V1(owa_util_showsource);
|
PG_FUNCTION_INFO_V1(owa_util_show_query_columns);
|
PG_FUNCTION_INFO_V1(owa_util_signature_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_signature_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_status_line);
|
PG_FUNCTION_INFO_V1(owa_util_tablecaption);
|
PG_FUNCTION_INFO_V1(owa_util_tableclose_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_tableclose_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_tabledata);
|
PG_FUNCTION_INFO_V1(owa_util_tableheader_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_tableheader_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_tableheaderrowclose_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_tableheaderrowclose_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_tableheaderrowopen_ovr1);
|
PG_FUNCTION_INFO_V1(owa_util_tableheaderrowopen_ovr2);
|
PG_FUNCTION_INFO_V1(owa_util_tablenodata);
|
PG_FUNCTION_INFO_V1(owa_util_tableopen);
|
PG_FUNCTION_INFO_V1(owa_util_tableprint);
|
PG_FUNCTION_INFO_V1(owa_util_tablerowclose);
|
PG_FUNCTION_INFO_V1(owa_util_tablerowopen);
|
PG_FUNCTION_INFO_V1(owa_util_todate);
|
PG_FUNCTION_INFO_V1(owa_util_validate_arg);
|
PG_FUNCTION_INFO_V1(owa_util_who_called_me);
|
PG_FUNCTION_INFO_V1(owa_util_http_header_close);
|
|
/**
|
* @brief This function prepares a SQL query by binding variables to it, and stores the output in an opened cursor. Use this function as a parameter to a procedure sending a dynamically generated query. Specify up to 25 bind variables.
|
* @details This function prepares a SQL query by binding variables to it, and stores the output in an opened cursor. Use this function as a parameter to a procedure sending a dynamically generated query. Specify up to 25 bind variables.
|
* * Parameters:
|
* * @param THEQUERY (in) VARCHAR2: The SQL query statement which must be a SELECT statement
|
* * @param BV1NAME (in) VARCHAR2: The name of the variable
|
* * @param BV1VALUE (in) VARCHAR2: The value of the variable
|
* * @param BV2NAME (in) VARCHAR2: TODO: Описание параметра BV2NAME
|
* * @param BV2VALUE (in) VARCHAR2: TODO: Описание параметра BV2VALUE
|
* * @param BV3NAME (in) VARCHAR2: TODO: Описание параметра BV3NAME
|
* * @param BV3VALUE (in) VARCHAR2: TODO: Описание параметра BV3VALUE
|
* * @param BV4NAME (in) VARCHAR2: TODO: Описание параметра BV4NAME
|
* * @param BV4VALUE (in) VARCHAR2: TODO: Описание параметра BV4VALUE
|
* * @param BV5NAME (in) VARCHAR2: TODO: Описание параметра BV5NAME
|
* * @param BV5VALUE (in) VARCHAR2: TODO: Описание параметра BV5VALUE
|
* * @param BV6NAME (in) VARCHAR2: TODO: Описание параметра BV6NAME
|
* * @param BV6VALUE (in) VARCHAR2: TODO: Описание параметра BV6VALUE
|
* * @param BV7NAME (in) VARCHAR2: TODO: Описание параметра BV7NAME
|
* * @param BV7VALUE (in) VARCHAR2: TODO: Описание параметра BV7VALUE
|
* * @param BV8NAME (in) VARCHAR2: TODO: Описание параметра BV8NAME
|
* * @param BV8VALUE (in) VARCHAR2: TODO: Описание параметра BV8VALUE
|
* * @param BV9NAME (in) VARCHAR2: TODO: Описание параметра BV9NAME
|
* * @param BV9VALUE (in) VARCHAR2: TODO: Описание параметра BV9VALUE
|
* * @param BV10NAME (in) VARCHAR2: TODO: Описание параметра BV10NAME
|
* * @param BV10VALUE (in) VARCHAR2: TODO: Описание параметра BV10VALUE
|
* * @param BV11NAME (in) VARCHAR2: TODO: Описание параметра BV11NAME
|
* * @param BV11VALUE (in) VARCHAR2: TODO: Описание параметра BV11VALUE
|
* * @param BV12NAME (in) VARCHAR2: TODO: Описание параметра BV12NAME
|
* * @param BV12VALUE (in) VARCHAR2: TODO: Описание параметра BV12VALUE
|
* * @param BV13NAME (in) VARCHAR2: TODO: Описание параметра BV13NAME
|
* * @param BV13VALUE (in) VARCHAR2: TODO: Описание параметра BV13VALUE
|
* * @param BV14NAME (in) VARCHAR2: TODO: Описание параметра BV14NAME
|
* * @param BV14VALUE (in) VARCHAR2: TODO: Описание параметра BV14VALUE
|
* * @param BV15NAME (in) VARCHAR2: TODO: Описание параметра BV15NAME
|
* * @param BV15VALUE (in) VARCHAR2: TODO: Описание параметра BV15VALUE
|
* * @param BV16NAME (in) VARCHAR2: TODO: Описание параметра BV16NAME
|
* * @param BV16VALUE (in) VARCHAR2: TODO: Описание параметра BV16VALUE
|
* * @param BV17NAME (in) VARCHAR2: TODO: Описание параметра BV17NAME
|
* * @param BV17VALUE (in) VARCHAR2: TODO: Описание параметра BV17VALUE
|
* * @param BV18NAME (in) VARCHAR2: TODO: Описание параметра BV18NAME
|
* * @param BV18VALUE (in) VARCHAR2: TODO: Описание параметра BV18VALUE
|
* * @param BV19NAME (in) VARCHAR2: TODO: Описание параметра BV19NAME
|
* * @param BV19VALUE (in) VARCHAR2: TODO: Описание параметра BV19VALUE
|
* * @param BV20NAME (in) VARCHAR2: TODO: Описание параметра BV20NAME
|
* * @param BV20VALUE (in) VARCHAR2: TODO: Описание параметра BV20VALUE
|
* * @param BV21NAME (in) VARCHAR2: TODO: Описание параметра BV21NAME
|
* * @param BV21VALUE (in) VARCHAR2: TODO: Описание параметра BV21VALUE
|
* * @param BV22NAME (in) VARCHAR2: TODO: Описание параметра BV22NAME
|
* * @param BV22VALUE (in) VARCHAR2: TODO: Описание параметра BV22VALUE
|
* * @param BV23NAME (in) VARCHAR2: TODO: Описание параметра BV23NAME
|
* * @param BV23VALUE (in) VARCHAR2: TODO: Описание параметра BV23VALUE
|
* * @param BV24NAME (in) VARCHAR2: TODO: Описание параметра BV24NAME
|
* * @param BV24VALUE (in) VARCHAR2: TODO: Описание параметра BV24VALUE
|
* * @param BV25NAME (in) VARCHAR2: TODO: Описание параметра BV25NAME
|
* * @param BV25VALUE (in) VARCHAR2: TODO: Описание параметра BV25VALUE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_bind_variables(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.bind_variables еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief These procedures creates a calendar in HTML with a visible border. Each date in the calendar can contain any number of hypertext links.
|
* @details These procedures creates a calendar in HTML with a visible border. Each date in the calendar can contain any number of hypertext links.
|
* * Parameters:
|
* * @param P_QUERY (in) VARCHAR2: A PL/SQL query.
|
* * @param P_MF_ONLY (in) VARCHAR2: If "N" (the default), the generated calendar includes Sunday through Saturday. Otherwise, it includes Monday through Friday only.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_calendarprint_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.calendarprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief These procedures creates a calendar in HTML with a visible border. Each date in the calendar can contain any number of hypertext links.
|
* @details These procedures creates a calendar in HTML with a visible border. Each date in the calendar can contain any number of hypertext links.
|
* * Parameters:
|
* * @param P_CURSOR (in) NUMBER: A PL/SQL cursor containing the same format asp_query.
|
* * @param P_MF_ONLY (in) VARCHAR2: If "N" (the default), the generated calendar includes Sunday through Saturday. Otherwise, it includes Monday through Friday only.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_calendarprint_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.calendarprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_COLCNT (in) NUMBER: The number of columns in the table.
|
* * @param P_RESULTTBL (in) PL/SQL TABLE: The index table which will contain the result of the query. Each entry in the query will correspond to one column value.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THEQUERY (in) VARCHAR2: A SQLSELECTstatement.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THECURSOR (in) NUMBER: A cursor ID. This can be the return value from theBIND_VARIABLES Function.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr3(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THEQUERY (in) VARCHAR2: A SQLSELECTstatement.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * @param P_SKIP_REC (in) NUMBER: The number of rows to exclude from the HTML table.
|
* * * @param P_MORE_DATA (out) BOOLEAN: TRUEif there are more rows in the query or cursor,FALSEotherwise. (Возвращается через результат)
|
* * * * @return record: Композитный тип (boolean), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr4(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THECURSOR (in) NUMBER: A cursor ID. This can be the return value from theBIND_VARIABLES Function.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * @param P_SKIP_REC (in) NUMBER: The number of rows to exclude from the HTML table.
|
* * * @param P_MORE_DATA (out) BOOLEAN: TRUEif there are more rows in the query or cursor,FALSEotherwise. (Возвращается через результат)
|
* * * * @return record: Композитный тип (boolean), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr5(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THEQUERY (in) VARCHAR2: A SQLSELECTstatement.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * * @param P_RECCNT (out) NUMBER: The number of rows that have been returned by the query. This value does not include skipped rows (if any). (Возвращается через результат)
|
* * * * @return record: Композитный тип (number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr6(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THECURSOR (in) NUMBER: A cursor ID. This can be the return value from theBIND_VARIABLES Function.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * * @param P_RECCNT (out) NUMBER: The number of rows that have been returned by the query. This value does not include skipped rows (if any). (Возвращается через результат)
|
* * * * @return record: Композитный тип (number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr7(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THEQUERY (in) VARCHAR2: A SQLSELECTstatement.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * @param P_SKIP_REC (in) NUMBER: The number of rows to exclude from the HTML table.
|
* * * @param P_MORE_DATA (out) BOOLEAN: TRUEif there are more rows in the query or cursor,FALSEotherwise. (Возвращается через результат)
|
* * @param P_RECCNT (out) NUMBER: The number of rows that have been returned by the query. This value does not include skipped rows (if any). (Возвращается через результат)
|
* * * * @return record: Композитный тип (boolean number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr8(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* @details This procedure generates an HTML table from the output of a SQL query. SQL atomic data items are mapped to HTML cells and SQL rows to HTML rows. You must write the code to begin and end the HTML table.
|
* * Parameters:
|
* * @param P_THECURSOR (in) NUMBER: A cursor ID. This can be the return value from theBIND_VARIABLES Function.
|
* * @param P_MAX_ROWS (in) NUMBER: The maximum number of rows to print.
|
* * @param P_FORMAT_NUMBERS (in) VARCHAR2: If the value of this parameter is notNULL, number fields are right justified and rounded to two decimal places.
|
* * @param P_SKIP_REC (in) NUMBER: The number of rows to exclude from the HTML table.
|
* * * @param P_MORE_DATA (out) BOOLEAN: TRUEif there are more rows in the query or cursor,FALSEotherwise. (Возвращается через результат)
|
* * @param P_RECCNT (out) NUMBER: The number of rows that have been returned by the query. This value does not include skipped rows (if any). (Возвращается через результат)
|
* * * * @return record: Композитный тип (boolean number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_cellsprint_ovr9(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.cellsprint еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure generates three HTML form elements that allow the user to select the day, the month, and the year.
|
* @details This procedure generates three HTML form elements that allow the user to select the day, the month, and the year.
|
* * Parameters:
|
* * @param P_NAME (in) VARCHAR2: The name of the form elements.
|
* * @param P_DATE (in) DATE: The initial date that is selected when the HTML page is displayed.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_choose_date(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.choose_date еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param LIST (in) VARCHAR2: TODO: Описание параметра LIST
|
* * * @param ARR (out) PL/SQL TABLE: TODO: Описание параметра ARR (Возвращается через результат)
|
* * @param LENARR (out) PL/SQL TABLE: TODO: Описание параметра LENARR (Возвращается через результат)
|
* * @param ARRLEN (out) NUMBER: TODO: Описание параметра ARRLEN (Возвращается через результат)
|
* * * * @return record: Композитный тип (pl/sql table pl/sql table number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_comma_to_ident_arr_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.comma_to_ident_arr еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param LIST (in) VARCHAR2: TODO: Описание параметра LIST
|
* * * @param ARR (out) PL/SQL TABLE: TODO: Описание параметра ARR (Возвращается через результат)
|
* * @param LENARR (out) PL/SQL TABLE: TODO: Описание параметра LENARR (Возвращается через результат)
|
* * @param ARRLEN (out) NUMBER: TODO: Описание параметра ARRLEN (Возвращается через результат)
|
* * * * @return record: Композитный тип (pl/sql table pl/sql table number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_comma_to_ident_arr_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.comma_to_ident_arr еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CTABLE (in) VARCHAR2: TODO: Описание параметра CTABLE
|
* * @param CCOLUMNS (in) VARCHAR2: TODO: Описание параметра CCOLUMNS
|
* * * @param COL_NAMES (out) PL/SQL TABLE: TODO: Описание параметра COL_NAMES (Возвращается через результат)
|
* * @param COL_DTYPES (out) PL/SQL TABLE: TODO: Описание параметра COL_DTYPES (Возвращается через результат)
|
* * @param NNUM_COLS (out) NUMBER: TODO: Описание параметра NNUM_COLS (Возвращается через результат)
|
* * * * @return record: Композитный тип (pl/sql table pl/sql table number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_describe_cols(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.describe_cols еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This function returns the value of the specified CGI environment variable.
|
* @details This function returns the value of the specified CGI environment variable.
|
* * Parameters:
|
* * @param PARAM_NAME (in) VARCHAR2: The name of the CGI environment variable. It is case-insensitive.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
/*
|
Datum owa_util_get_cgi_env(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.get_cgi_env еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
*/
|
|
/**
|
* @brief This function returns the full virtual path of the PL/SQL Gateway that is handling the request.
|
* @details This function returns the full virtual path of the PL/SQL Gateway that is handling the request.
|
* * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_get_owa_service_path(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.get_owa_service_path еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This function returns the name of the procedure that is being invoked by the PL/SQL Gateway.
|
* @details This function returns the name of the procedure that is being invoked by the PL/SQL Gateway.
|
* * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_get_procedure(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.get_procedure еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_get_version(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.get_version еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param TF (in) BOOLEAN: TODO: Описание параметра TF
|
* * @param YES (in) VARCHAR2: TODO: Описание параметра YES
|
* * @param NO (in) VARCHAR2: TODO: Описание параметра NO
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_ite(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.ite еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML selection list form element from the output of a SQL query.
|
* @details This procedure generates an HTML selection list form element from the output of a SQL query.
|
|
The first column specifies the values that are sent back. These values are for theVALUEattribute of theOPTIONtag.
|
The second column specifies the values that the user sees.
|
The third column specifies whether or not the row is marked asSELECTEDin theOPTIONtag. If the value is notNULL, the row is selected.
|
* * Parameters:
|
* * @param P_THECURSOR (in) NUMBER: The cursor ID. This can be the return value from theBIND_VARIABLES Function.
|
* * @param P_CNAME (in) VARCHAR2: The name of the HTML form element.
|
* * @param P_NSIZE (in) NUMBER: The size of the form element (this controls how many items the user can see without scrolling).
|
* * @param P_MULTIPLE (in) BOOLEAN: Whether multiple selection is permitted.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_listprint_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.listprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure generates an HTML selection list form element from the output of a SQL query.
|
* @details This procedure generates an HTML selection list form element from the output of a SQL query.
|
|
The first column specifies the values that are sent back. These values are for theVALUEattribute of theOPTIONtag.
|
The second column specifies the values that the user sees.
|
The third column specifies whether or not the row is marked asSELECTEDin theOPTIONtag. If the value is notNULL, the row is selected.
|
* * Parameters:
|
* * @param P_THEQUERY (in) VARCHAR2: The SQL query.
|
* * @param P_CNAME (in) VARCHAR2: The name of the HTML form element.
|
* * @param P_NSIZE (in) NUMBER: The size of the form element (this controls how many items the user can see without scrolling).
|
* * @param P_MULTIPLE (in) BOOLEAN: Whether multiple selection is permitted.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_listprint_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.listprint еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure changes the default MIME header that the script returns. This procedure must come before anyHTP.PRINT or HTP.PRNcalls to direct the script not to use the default MIME header.
|
* @details This procedure changes the default MIME header that the script returns. This procedure must come before anyHTP.PRINT or HTP.PRNcalls to direct the script not to use the default MIME header.
|
* * Parameters:
|
* * @param CCONTENT_TYPE (in) VARCHAR2: The MIME type to generate
|
* * @param BCLOSE_HEADER (in) BOOLEAN: Whether or not to close the HTTP header. IfTRUE, two newlines are sent, which closes the HTTP header. Otherwise, one newline is sent, and the HTTP header remains open.
|
* * @param CCHARSET (in) VARCHAR2: The character set to use.The character set only makes sense if the MIME type is of type 'text'. Therefore, the character set is only tagged on to the Content-Type header only if the MIME type passed in is of type 'text'. Any other MIME type, such as 'image', will not have any character set tagged on.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_mime_header(PG_FUNCTION_ARGS)
|
{
|
text *ccontent_type_txt = PG_GETARG_TEXT_P(0);
|
char *ccontent_type = text_to_cstring(ccontent_type_txt);
|
bool bclose_header = PG_GETARG_BOOL(1);
|
|
char *ccharset = nullptr;
|
if (!PG_ARGISNULL(2))
|
{
|
text *ccharset_txt = PG_GETARG_TEXT_P(2);
|
ccharset = text_to_cstring(ccharset_txt);
|
|
char *terminate = strchr(ccharset, '\n');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
terminate = strchr(ccharset, '\r');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
}
|
|
char *terminate = strchr(ccontent_type, '\n');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
terminate = strchr(ccontent_type, '\r');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
|
std::string header;
|
header.append("Content-Type: ");
|
header.append(ccontent_type);
|
|
if (ccharset != nullptr)
|
{
|
header.append("; charset=");
|
header.append(ccharset);
|
}
|
header.append("\n");
|
|
text *header_txt = cstring_to_text(header.c_str());
|
DirectFunctionCall1(htp_prn_ovr1, PointerGetDatum(header_txt));
|
|
if (bclose_header)
|
{
|
LOCAL_FCINFO(fcinfo2, 0);
|
InitFunctionCallInfoData(*fcinfo2, nullptr, 0, InvalidOid, nullptr, nullptr);
|
owa_util_http_header_close(fcinfo2);
|
}
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CNAME (in) VARCHAR2: TODO: Описание параметра CNAME
|
* * * @param O_PROCOWNER (out) VARCHAR2: TODO: Описание параметра O_PROCOWNER (Возвращается через результат)
|
* * @param O_PROCNAME (out) VARCHAR2: TODO: Описание параметра O_PROCNAME (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2 varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_name_resolve(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.name_resolve еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_path_to_me(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.path_to_me еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure specifies that the application server is to visit the specified URL. The URL may specify either a Web page to return or a program to execute.
|
* @details This procedure specifies that the application server is to visit the specified URL. The URL may specify either a Web page to return or a program to execute.
|
* * Parameters:
|
* * @param CURL (in) VARCHAR2: The URL to visit.
|
* * @param BCLOSE_HEADER (in) BOOLEAN: Whether or not to close the HTTP header. IfTRUE, two newlines are sent, which closes the HTTP header. Otherwise, one newline is sent, and the HTTP header remains open.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_redirect_url(PG_FUNCTION_ARGS)
|
{
|
text *location_txt = PG_GETARG_TEXT_P(0);
|
bool bclose_header = PG_GETARG_BOOL(1);
|
|
char *location = text_to_cstring(location_txt);
|
|
char *terminate = strchr(location, '\n');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
terminate = strchr(location, '\r');
|
if (terminate != nullptr)
|
{
|
*terminate = '\0';
|
}
|
|
std::string result;
|
|
result.append("Location: ");
|
result.append(location);
|
result.append("\n");
|
|
pfree(location);
|
|
text *result_txt = cstring_to_text(result.c_str());
|
|
DirectFunctionCall1(htp_print_ovr1, PointerGetDatum(result_txt));
|
|
if (bclose_header)
|
{
|
LOCAL_FCINFO(fcinfo2, 0);
|
InitFunctionCallInfoData(*fcinfo2, nullptr, 0, InvalidOid, nullptr, nullptr);
|
owa_util_http_header_close(fcinfo2);
|
}
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param COBJECT (in) VARCHAR2: TODO: Описание параметра COBJECT
|
* * @param CSCHEMA (in) VARCHAR2: TODO: Описание параметра CSCHEMA
|
* * * @param RESOLVED_NAME (out) VARCHAR2: TODO: Описание параметра RESOLVED_NAME (Возвращается через результат)
|
* * @param RESOLVED_OWNER (out) VARCHAR2: TODO: Описание параметра RESOLVED_OWNER (Возвращается через результат)
|
* * @param RESOLVED_DB_LINK (out) VARCHAR2: TODO: Описание параметра RESOLVED_DB_LINK (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2 varchar2 varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_resolve_table(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.resolve_table еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This procedure prints the source of the specified procedure, function, or package. If a procedure or function which belongs to a package is specified, then the entire package is displayed.
|
* @details This procedure prints the source of the specified procedure, function, or package. If a procedure or function which belongs to a package is specified, then the entire package is displayed.
|
* * Parameters:
|
* * @param CNAME (in) VARCHAR2: The function or procedure whose source you want to show.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_showsource(PG_FUNCTION_ARGS)
|
{
|
char *cname = text_to_cstring(PG_GETARG_TEXT_P(0));
|
|
char *proc_name, *owner_name;
|
|
char *dot_loc = strchr(cname, '.');
|
if (dot_loc != nullptr)
|
{
|
*dot_loc = '\0';
|
owner_name = cname;
|
proc_name = dot_loc + 1;
|
}
|
else
|
{
|
// TODO
|
}
|
|
int res = SPI_connect();
|
|
std::string query = "SELECT line, text FROM \"SYS\".\"ALL_SOURCE\" WHERE \"NAME\" = upper(";
|
query.append(proc_name);
|
query.append(") AND \"OWNER\" = upper(");
|
query.append(owner_name);
|
query.append(" ORDER BY \"TYPE\", \"LINE\"");
|
|
res = SPI_execute(query.c_str(), true, 0);
|
|
if (res < 0)
|
{
|
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
errmsg("SPI execute failed")));
|
}
|
|
{
|
std::string header = "Source code for ";
|
header.append(cname);
|
text *header_txt = cstring_to_text(header.c_str());
|
Datum header_lvl = DirectFunctionCall1(int4_numeric, Int32GetDatum(1));
|
DirectFunctionCall6(htp_header, header_lvl,
|
PointerGetDatum(header_txt),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
pfree(header_txt);
|
}
|
|
DirectFunctionCall3(htp_preopen, static_cast<Datum>(0),
|
static_cast<Datum>(0), static_cast<Datum>(0));
|
|
int line1s = 1;
|
|
for (size_t i = 0; i < SPI_tuptable->numvals; i++)
|
{
|
bool isnull;
|
Datum line_datum = GetAttributeByNum(SPI_tuptable->vals[i]->t_data, 0, &isnull);
|
int32_t line = DatumGetInt32(DirectFunctionCall1(numeric_int4, line_datum));
|
if (line == 1)
|
{
|
line1s++;
|
if (line1s == 2)
|
{
|
DirectFunctionCall1(htp_print_ovr1, static_cast<Datum>(0));
|
}
|
}
|
|
Datum text_datum = GetAttributeByNum(SPI_tuptable->vals[i]->t_data, 1, &isnull);
|
char *txt = text_to_cstring(DatumGetTextP(text_datum));
|
for (char *symbol = txt; *symbol != '\0'; symbol++)
|
{
|
if (*symbol == '\n')
|
{
|
*symbol = ' ';
|
}
|
}
|
text *out_line = cstring_to_text(txt);
|
DirectFunctionCall1(htp_print_ovr1, PointerGetDatum(out_line));
|
pfree(out_line);
|
}
|
|
DirectFunctionCall3(htp_preclose, static_cast<Datum>(0),
|
static_cast<Datum>(0), static_cast<Datum>(0));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CTABLE (in) VARCHAR2: TODO: Описание параметра CTABLE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_show_query_columns(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.show_query_columns еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_signature_ovr1(PG_FUNCTION_ARGS)
|
{
|
std::time_t timestamp = std::time(nullptr);
|
std::tm *local_tm = std::localtime(×tamp);
|
|
std::ostringstream stream;
|
stream << "This page was produced by the ";
|
stream << "<b>PL/SQL Web Toolkit</b> on";
|
stream << std::put_time(local_tm, "%B %e, %Y %H:%M");
|
stream << ".\n";
|
|
text *result = cstring_to_text(stream.str().c_str());
|
DirectFunctionCall1(htp_p_ovr1, PointerGetDatum(result));
|
pfree(result);
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CNAME (in) VARCHAR2: TODO: Описание параметра CNAME
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_signature_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.signature еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure sends a standard HTTP status code to the client.
|
* @details This procedure sends a standard HTTP status code to the client.
|
* * Parameters:
|
* * @param NSTATUS (in) NUMBER: The status code.
|
* * @param CREASON (in) VARCHAR2: The string for the status code.
|
* * @param BCLOSE_HEADER (in) BOOLEAN: Whether or not to close the HTTP header. IfTRUE, two newlines are sent, which closes the HTTP header. Otherwise, one newline is sent, and the HTTP header remains open.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_status_line(PG_FUNCTION_ARGS)
|
{
|
Datum nstatus_num = PG_GETARG_DATUM(0);
|
int32_t nstatus = DatumGetInt32(DirectFunctionCall1(numeric_int4, nstatus_num));
|
|
char *creason;
|
if (!PG_ARGISNULL(1))
|
{
|
text *creason_txt = PG_GETARG_TEXT_P(1);
|
creason = text_to_cstring(creason_txt);
|
}
|
else
|
{
|
creason = pstrdup("");
|
}
|
|
bool bclose_header = PG_GETARG_BOOL(2);
|
|
std::string result = "Status: ";
|
result.append(std::to_string(nstatus));
|
result.append(" ");
|
result.append(creason);
|
result.push_back('\n');
|
|
text *result_txt = cstring_to_text(result.c_str());
|
DirectFunctionCall1(htp_prn_ovr1, PointerGetDatum(result_txt));
|
pfree(result_txt);
|
|
if (bclose_header)
|
{
|
LOCAL_FCINFO(fcinfo2, 0);
|
InitFunctionCallInfoData(*fcinfo2, nullptr, 0, InvalidOid, nullptr, nullptr);
|
owa_util_http_header_close(fcinfo2);
|
}
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CCAPTION (in) VARCHAR2: TODO: Описание параметра CCAPTION
|
* * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tablecaption(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tablecaption еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableclose_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableclose еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param NTABLE_WIDTH (in) NUMBER: TODO: Описание параметра NTABLE_WIDTH
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableclose_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableclose еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CDATA (in) VARCHAR2: TODO: Описание параметра CDATA
|
* * @param NCOLUMN_SIZE (in) NUMBER: TODO: Описание параметра NCOLUMN_SIZE
|
* * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tabledata(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tabledata еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CCOLUMN_NAME (in) VARCHAR2: TODO: Описание параметра CCOLUMN_NAME
|
* * @param NCOLUMN_SIZE (in) NUMBER: TODO: Описание параметра NCOLUMN_SIZE
|
* * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheader_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheader еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CCOLUMN_NAME (in) VARCHAR2: TODO: Описание параметра CCOLUMN_NAME
|
* * @param NCOLUMN_SIZE (in) NUMBER: TODO: Описание параметра NCOLUMN_SIZE
|
* * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_WIDTH (in/out) NUMBER: TODO: Описание параметра NTABLE_WIDTH
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * @param NTABLE_WIDTH (in/out) NUMBER: TODO: Описание параметра NTABLE_WIDTH (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2 number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheader_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheader еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheaderrowclose_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheaderrowclose еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_WIDTH (in) NUMBER: TODO: Описание параметра NTABLE_WIDTH
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheaderrowclose_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheaderrowclose еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheaderrowopen_ovr1(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheaderrowopen еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * @param NTABLE_WIDTH (out) NUMBER: TODO: Описание параметра NTABLE_WIDTH (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2 number), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableheaderrowopen_ovr2(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableheaderrowopen еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NNUM_COLS (in) NUMBER: TODO: Описание параметра NNUM_COLS
|
* * @param NTABLE_WIDTH (in) NUMBER: TODO: Описание параметра NTABLE_WIDTH
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tablenodata(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tablenodata еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CATTRIBUTES (in) VARCHAR2: TODO: Описание параметра CATTRIBUTES
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableopen(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tableopen еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This function generates either preformatted tables or HTML tables (depending on the capabilities of the user's browser) from database tables.
|
* @details This function generates either preformatted tables or HTML tables (depending on the capabilities of the user's browser) from database tables.
|
* * Parameters:
|
* * @param CTABLE (in) VARCHAR2: The database table.
|
* * @param CATTRIBUTES (in) VARCHAR2: Other attributes to be included as-is in the tag.
|
* * @param NTABLE_TYPE (in) NUMBER: How to generate the table. SpecifyHTML_TABLEto generate the table using<TABLE>tags or PRE_TABLEto generate the table using the<PRE>tags. These are constants:HTML_TABLECONSTANT INTEGER:= 1;PRE_TABLECONSTANT INTEGER:= 2;
|
* * @param CCOLUMNS (in) VARCHAR2: A comma-delimited list of columns fromctableto include in the generated table.
|
* * @param CCLAUSES (in) VARCHAR2: WHEREor ORDERBYclauses, which specify which rows to retrieve from the database table, and how to order them.
|
* * @param CCOL_ALIASES (in) VARCHAR2: A comma-delimited list of headings for the generated table.
|
* * @param NROW_MIN (in) NUMBER: The first row, of those retrieved, to display.
|
* * @param NROW_MAX (in) NUMBER: The last row, of those retrieved, to display.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tableprint(PG_FUNCTION_ARGS)
|
{
|
char *ctable = text_to_cstring(PG_GETARG_TEXT_P(0));
|
|
Datum cattributes_datum = PG_ARGISNULL(1) ? static_cast<Datum>(0) : PG_GETARG_DATUM(1);
|
|
int32_t table_type = DatumGetInt32(DirectFunctionCall1(numeric_int4, PG_GETARG_DATUM(2)));
|
|
char *ccolumns = text_to_cstring(PG_GETARG_TEXT_P(3));
|
|
char *cclauses;
|
if (!PG_ARGISNULL(4))
|
{
|
cclauses = text_to_cstring(PG_GETARG_TEXT_P(4));
|
}
|
else
|
{
|
cclauses = pstrdup("");
|
}
|
|
std::vector<std::string> headings;
|
if (!PG_ARGISNULL(5))
|
{
|
char *ccol_aliases = text_to_cstring(PG_GETARG_TEXT_P(5));
|
char *alias = strtok(ccol_aliases, ",");
|
while (alias != nullptr)
|
{
|
headings.push_back(alias);
|
alias = strtok(nullptr, ",");
|
}
|
pfree(ccol_aliases);
|
}
|
|
int32_t nrow_min = DatumGetInt32(DirectFunctionCall1(numeric_int4, PG_GETARG_DATUM(6)));
|
int32_t nrow_max;
|
if (!PG_ARGISNULL(6))
|
{
|
nrow_max = DatumGetInt32(DirectFunctionCall1(numeric_int4, PG_GETARG_DATUM(7)));
|
}
|
else
|
{
|
nrow_max = std::numeric_limits<int32_t>::max();
|
}
|
|
SPI_connect();
|
|
std::string query = "SELECT ";
|
query.append(ccolumns);
|
query.append(" FROM ");
|
query.append(ctable);
|
query.append(" ");
|
query.append(cclauses);
|
query.append(";");
|
|
pfree(ccolumns);
|
pfree(ctable);
|
pfree(cclauses);
|
|
int query_res = SPI_execute(query.c_str(), true, 0);
|
|
if (query_res < 0)
|
{
|
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
|
errmsg("Query failed: %d", query_res)));
|
SPI_finish();
|
PG_RETURN_NULL();
|
}
|
|
if (headings.empty())
|
{
|
for (int i = 0; i < SPI_tuptable->tupdesc->natts; i++)
|
{
|
headings.push_back(TupleDescAttr(SPI_tuptable->tupdesc, i)->attname.data);
|
}
|
}
|
else if (headings.size() != static_cast<size_t>(SPI_tuptable->tupdesc->natts))
|
{
|
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
errmsg("Invalid number of aliases!")));
|
}
|
|
std::vector<Oid> out_functions(headings.size());
|
for (size_t i = 0; i < headings.size(); i++)
|
{
|
Oid target_type = TupleDescAttr(SPI_tuptable->tupdesc, i)->atttypid;
|
Oid out_func;
|
bool output_is_varlena;
|
getTypeOutputInfo(target_type, &out_func, &output_is_varlena);
|
out_functions.push_back(out_func);
|
}
|
|
std::vector<size_t> column_widths(headings.size());
|
if (table_type == OWA_UTIL_PRE_TABLE)
|
{
|
for (size_t i = 0; i < headings.size(); i++)
|
{
|
column_widths[i] = headings[i].size();
|
}
|
}
|
|
std::vector<std::vector<std::string>> entries(SPI_tuptable->numvals);
|
|
for (size_t i = 0; i < SPI_tuptable->numvals; i++)
|
{
|
for (size_t j = 0; j < headings.size(); i++)
|
{
|
bool isnull;
|
Datum value = GetAttributeByNum(SPI_tuptable->vals[i]->t_data, j, &isnull);
|
if (!isnull)
|
{
|
char *out_value = OidOutputFunctionCall(out_functions[j], value);
|
if (table_type == OWA_UTIL_PRE_TABLE)
|
{
|
column_widths[i] = Max(column_widths[i], strlen(out_value));
|
}
|
entries[i].push_back(out_value);
|
pfree(out_value);
|
}
|
else
|
{
|
entries[i].push_back("");
|
}
|
}
|
}
|
|
bool too_many_rows = SPI_tuptable->numvals > static_cast<uint64_t>(nrow_max - nrow_min + 1);
|
|
char table_border;
|
// print table
|
// start
|
if (table_type == OWA_UTIL_HTML_TABLE)
|
{
|
DirectFunctionCall5(htp_tableopen,
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
cattributes_datum);
|
|
DirectFunctionCall5(htp_tablerowopen,
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
|
for (auto &heading: headings)
|
{
|
text *heading_txt = cstring_to_text(heading.c_str());
|
DirectFunctionCall6(htp_tabledata,
|
PointerGetDatum(heading_txt),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
pfree(heading_txt);
|
}
|
|
DirectFunctionCall5(htp_tablerowclose,
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
|
for (auto &row: entries)
|
{
|
DirectFunctionCall5(htp_tablerowopen,
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
|
for (auto &cell: row)
|
{
|
text *cell_txt = cstring_to_text(cell.c_str());
|
DirectFunctionCall6(htp_tabledata,
|
PointerGetDatum(cell_txt),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
pfree(cell_txt);
|
}
|
|
DirectFunctionCall5(htp_tablerowclose,
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0),
|
static_cast<Datum>(0));
|
}
|
}
|
else // table_type == OWA_UTIL_PRE_TABLE
|
{
|
table_border = PG_ARGISNULL(1)? ' ' : '|';
|
std::ostringstream stream;
|
std::string line;
|
|
size_t line_width = std::accumulate(column_widths.begin(),
|
column_widths.end(),
|
static_cast<size_t>(0));
|
|
// For each column we add two spaces and one table_border characters
|
// also we add additional table border character for table line begin
|
line_width += 3 * headings.size() + 1;
|
line.resize(line_width, '-');
|
|
stream << "<pre>\n" << line << "\n" << table_border;
|
for (size_t i = 0; i < headings.size(); i++)
|
{
|
stream << ' ' << std::setw(column_widths[i] + 1) << headings[i]
|
<< std::setw(0) << table_border;
|
}
|
stream << "\n";
|
|
for (auto &row: entries)
|
{
|
stream << table_border;
|
for (size_t i = 0; i < row.size(); i++)
|
{
|
stream << ' ' << std::setw(column_widths[i] + 1) << headings[i]
|
<< std::setw(0) << table_border;
|
}
|
stream << "\n";
|
}
|
|
stream << "</pre>";
|
|
text *result = cstring_to_text(stream.str().c_str());
|
|
DirectFunctionCall1(htp_print_ovr1, PointerGetDatum(result));
|
pfree(result);
|
}
|
|
SPI_finish();
|
PG_RETURN_BOOL(too_many_rows);
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tablerowclose(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tablerowclose еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING
|
* * @param NTABLE_TYPE (in) NUMBER: TODO: Описание параметра NTABLE_TYPE
|
* * * @param CROWSTRING (in/out) VARCHAR2: TODO: Описание параметра CROWSTRING (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_tablerowopen(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.tablerowopen еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
/**
|
* @brief This function converts the DATETYPE Datatype to the standard OracleDATEtype.
|
* @details This function converts the DATETYPE Datatype to the standard OracleDATEtype.
|
* * Parameters:
|
* * @param P_DATEARRAY (in) PL/SQL TABLE: The value to convert.
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_todate(PG_FUNCTION_ARGS)
|
{
|
ArrayType *arr = PG_GETARG_ARRAYTYPE_P(0);
|
|
Datum *elems;
|
bool *nulls;
|
int len;
|
|
deconstruct_array(arr, VARCHAR2OID, -1, false, TYPALIGN_INT,
|
&elems, &nulls, &len);
|
|
Assert(len == 3);
|
|
text *dd_txt = DatumGetTextP(elems[0]);
|
text *mm_txt = DatumGetTextP(elems[1]);
|
text *yyyy_txt = DatumGetTextP(elems[2]);
|
|
char dd[3];
|
char mm[3];
|
char yyyy[5];
|
char date[11];
|
|
text_to_cstring_buffer(dd_txt, dd, 2);
|
text_to_cstring_buffer(mm_txt, mm, 2);
|
text_to_cstring_buffer(yyyy_txt, yyyy, 4);
|
|
sprintf(date, "%s-%s-%s", dd, mm, yyyy);
|
|
text *date_txt = cstring_to_text(date);
|
|
pfree(elems);
|
pfree(nulls);
|
|
PG_RETURN_DATUM(DirectFunctionCall1(date_in, PointerGetDatum(date_txt)));
|
}
|
|
/**
|
* @brief TODO: Добавить описание
|
* @details TODO: Добавить детальное описание
|
* * Parameters:
|
* * @param PARAM (in) VARCHAR2: TODO: Описание параметра PARAM
|
* * * * *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_validate_arg(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.validate_arg еще не реализована.")));
|
|
PG_RETURN_VOID();
|
}
|
|
/**
|
* @brief This procedure returns information (in the form of output parameters) about the PL/SQL code unit that invoked it.
|
* @details This procedure returns information (in the form of output parameters) about the PL/SQL code unit that invoked it.
|
* * Parameters:
|
* * * @param OWNER (out) VARCHAR2: The owner of the program unit. (Возвращается через результат)
|
* * @param NAME (out) VARCHAR2: The name of the program unit. This is the name of the package, if the calling program unit is wrapped in a package, or the name of the procedure or function if the calling program unit is a standalone procedure or function. If the calling program unit is part of an anonymous block, this isNULL. (Возвращается через результат)
|
* * @param LINENO (out) NUMBER: The line number within the program unit where the call was made. (Возвращается через результат)
|
* * @param CALLER_T (out) VARCHAR2: The type of program unit that made the call. The possibilities are: package body, anonymous block, procedure, and function. Procedure and function are only for standalone procedures and functions. (Возвращается через результат)
|
* * * * @return record: Композитный тип (varchar2 varchar2 number varchar2), содержащий OUT/INOUT параметры.
|
* *
|
* @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/OWA_UTIL.html
|
*/
|
Datum owa_util_who_called_me(PG_FUNCTION_ARGS)
|
{
|
ereport(NOTICE, (errmsg("Функция owa_util.who_called_me еще не реализована.")));
|
|
PG_RETURN_NULL();
|
}
|
|
Datum owa_util_http_header_close(PG_FUNCTION_ARGS)
|
{
|
text *nl = cstring_to_text("\n");
|
DirectFunctionCall1(htp_prn_ovr1, PointerGetDatum(nl));
|
PG_RETURN_VOID();
|
}
|
|
} // extern "C"
|