CheckValid(enable, !name.IsEmpty(), _("Please specify name."));
if (!isProcedure)
- CheckValid(enable, cbReturntype->GetGuessedSelection() >= 0, _("Please select return type."));
+ CheckValid(enable, cbReturntype->GetValue().Trim() != wxEmptyString, _("Please select return type."));
if (!(isProcedure && connection->GetIsEdb()))
CheckValid(enable, cbLanguage->GetGuessedSelection() >= 0, _("Please select language."));
else
{
sql += wxT("\n RETURNS ");
- if (GetReturnAsSet())
+ if (GetReturnAsSet() && !GetReturnType().StartsWith(wxT("TABLE")))
sql += wxT("SETOF ");
sql += GetReturnType();
for (unsigned int i=0; i < argTypesArray.Count(); i++)
{
+ /*
+ * All Table arguments lies at the end of the list
+ * Do not include them as the part of the argument list
+ */
+ if (argModesArray.Item(i) == wxT("TABLE"))
+ break;
+
if (args.Length() > 0)
args += wxT(", ");
if (GetIsProcedure())
{
- if (!argNamesArray.Item(i).IsEmpty())
+ if (!argModesArray.Item(i).IsEmpty())
+ {
arg += qtIdent(argNamesArray.Item(i));
+ }
+ else
+ {
+ if (!argNamesArray.Item(i).IsEmpty())
+ arg += qtIdent(argNamesArray.Item(i));
+ arg += wxT(" ") + argModesArray.Item(i);
+ }
if (!argModesArray.Item(i).IsEmpty())
{
for (unsigned int i=0; i < argTypesArray.Count(); i++)
{
// OUT parameters are not considered part of the signature, except for EDB-SPL
- if (argModesArray.Item(i) != wxT("OUT"))
+ if (argModesArray.Item(i) != wxT("OUT") && argModesArray.Item(i) != wxT("TABLE"))
{
if (args.Length() > 0)
args += wxT(", ");
}
else
{
- if (GetLanguage() == wxT("edbspl"))
+ if (GetLanguage() == wxT("edbspl") && argModesArray.Item(i) != wxT("TABLE"))
{
if (args.Length() > 0)
args += wxT(", ");
mode = wxT("IN OUT");
else if (mode == wxT("v"))
mode = wxT("VARIADIC");
+ else if (mode == wxT("t"))
+ mode = wxT("TABLE");
else
{
mode = wxT("IN");
function->iSetArgCount(functions->GetLong(wxT("pronargs")));
+ wxString strReturnTableArgs;
// Process default values
if (obj->GetConnection()->BackendMinimumVersion(8, 4) &&
function->GetArgCount() != 0)
function->iAddArgDef(argDefValArray[currINindex-1]);
}
}
+ else if(function->GetArgModesArray()[index] == wxT("TABLE"))
+ {
+ if (strReturnTableArgs.Length() > 0)
+ strReturnTableArgs += wxT(", ");
+ wxString strName = function->GetArgNamesArray()[index];
+ if (!strName.IsEmpty())
+ strReturnTableArgs += strName + wxT(" ");
+ strReturnTableArgs += function->GetArgTypesArray()[index];
+ }
function->iAddArgDef(wxEmptyString);
}
}
function->UpdateSchema(browser, functions->GetOid(wxT("pronamespace")));
function->iSetOwner(functions->GetVal(wxT("funcowner")));
function->iSetAcl(functions->GetVal(wxT("proacl")));
- function->iSetReturnType(functions->GetVal(wxT("typname")));
+ wxString strType = functions->GetVal(wxT("typname"));
+ if (strType.Lower() == wxT("record") && !strReturnTableArgs.IsEmpty())
+ {
+ strType = wxT("TABLE(") + strReturnTableArgs + wxT(")");
+ }
+ function->iSetReturnType(strType);
function->iSetComment(functions->GetVal(wxT("description")));
function->iSetLanguage(lanname);