1
//////////////////////////////////////////////////////////////////////////
3
// pgScript - PostgreSQL Tools
4
// RCS-ID: $Id: pgsRemoveLine.cpp 7758 2009-03-26 20:49:59Z dpage $
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
// This software is released under the BSD Licence
8
//////////////////////////////////////////////////////////////////////////
12
#include "pgscript/expressions/pgsRemoveLine.h"
14
#include "pgscript/exceptions/pgsParameterException.h"
15
#include "pgscript/objects/pgsRecord.h"
16
#include "pgscript/objects/pgsString.h"
18
pgsRemoveLine::pgsRemoveLine(const wxString & rec, const pgsExpression * line) :
19
pgsExpression(), m_rec(rec), m_line(line)
24
pgsRemoveLine::~pgsRemoveLine()
29
pgsExpression * pgsRemoveLine::clone() const
31
return pnew pgsRemoveLine(*this);
34
pgsRemoveLine::pgsRemoveLine(const pgsRemoveLine & that) :
35
pgsExpression(that), m_rec(that.m_rec)
37
m_line = that.m_line->clone();
40
pgsRemoveLine & pgsRemoveLine::operator =(const pgsRemoveLine & that)
44
pgsExpression::operator=(that);
47
m_line = that.m_line->clone();
52
wxString pgsRemoveLine::value() const
54
return wxString() << wxT("RMLINE(") << m_rec << wxT("[")
55
<< m_line->value() << wxT("])");
58
pgsOperand pgsRemoveLine::eval(pgsVarMap & vars) const
60
if (vars.find(m_rec) != vars.end() && vars[m_rec]->is_record())
62
pgsRecord & rec = dynamic_cast<pgsRecord &>(*vars[m_rec]);
65
pgsOperand line(m_line->eval(vars));
66
if (line->is_integer())
69
line->value().ToLong(&aux_line);
71
if (!rec.remove_line(aux_line))
73
throw pgsParameterException(wxString() << wxT("an error ")
74
<< wxT("occurred while executing ") << value());
79
throw pgsParameterException(wxString() << line->value()
80
<< wxT(" is not a valid line number"));
87
throw pgsParameterException(wxString() << m_rec << wxT(" is not a record"));