从RECORD变量中选择值

时间:2016-03-21 07:28:37

标签: sql postgresql postgresql-9.3

作为我的k-medoid算法的一部分,我在我的函数中声明了一个名为o_random的记录变量,我用它来存储从犯罪表中检索的随机行,如下所示:

EXECUTE 'SELECT * FROM algorithms.kmedoid_crimes_' ||k||' WHERE  
cluster_id='||k_count||' OFFSET floor(random()*'||row_count||') LIMIT 1'   
INTO o_random;

但是,以下查询给出了一个错误,说明"无法识别列"纬度"在记录数据类型"。我从行中得到的犯罪表肯定有一个叫做纬度的字段..所以我想我试图从记录变量中错误地获取数据?

EXECUTE 'UPDATE algorithms.km_cluster_centres_' ||k||'
SET latitude = $1.latitude, longitude = $1.longitude, geom =   
ST_Transform(ST_SetSRID(ST_MakePoint($1.longitude, $1.latitude), 4326),3435)
WHERE id=' ||k_count
USING o_random;  

在堆栈上找到了一些解决方案,但它们似乎都没有工作..帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

只是一个猜测

public function validate() {        
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('game_players');

        if($query -> num_rows() == 1) {       // if we have one match
            return true;
        }       
    }

更新:如果它不起作用,请尝试使用http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html

进行登录