标签: syntax-error

在函数中使用EXECUTE时出现PostgreSQL语法错误

我正在尝试创建一个引用PostgreSQL 8.4中的临时表的函数.基于我的研究,似乎最好的方法是使用EXECUTE命令从定义的字符串执行我的查询.

不幸的是,我在尝试创建函数时遇到奇怪的语法错误.

我目前的功能定义如下:

CREATE OR REPLACE FUNCTION example() RETURNS void AS $$
  EXECUTE 'INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 from temp_table';
$$ LANGUAGE SQL;
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

ERROR:  syntax error at or near "'INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 from temp_table'"
LINE 2:   execute 'INSERT INTO table1 (col1, col2, col3) SELECT col1...
Run Code Online (Sandbox Code Playgroud)

无论字符串文字中的实际内容如何,​​我似乎都得到了同样的错误.

我的问题是,1)使用EXECUTE特性的正确语法是什么,2)是否有更好的方法来编写这样一个引用临时表的函数?

postgresql function execute temp-tables syntax-error

6
推荐指数
1
解决办法
2万
查看次数

意外令牌"完成"附近的语法错误令人困惑

我正在尝试学习shell脚本,所以我创建了一个简单的脚本,其循环不执行任何操作:

#!/bin/bash
names=(test test2 test3 test4)
for name in ${names[@]}
do
        #do something
done
Run Code Online (Sandbox Code Playgroud)

但是,当我运行此脚本时,我收到以下错误:

./test.sh:line 6:意外令牌完成附近的语法错误'
./test.sh:line 6:done'

我错过了什么?shell脚本'tab敏感'?

syntax bash shell for-loop syntax-error

6
推荐指数
2
解决办法
3万
查看次数

:Sequelize如何设置返回的数据顺序

我发布了使用限制和偏移设置findAll查询的返回数据顺序的问题,我正在使用文档中的示例代码:order: 'group DESC'但是它会抛出错误说:

Error: SQLITE_ERROR: near "group": syntax error
Run Code Online (Sandbox Code Playgroud)

这是完整的功能.

A_Model.findAll({
     offset:req.query.page * req.query.rows - req.query.rows,
     limit :req.query.rows // TODO: Of course, I put the trailing comma here ;)
     // TODO: order: 'group DESC'
    })
.success(function (docs) {
    response_from_server.records = count;
    response_from_server.page = req.query.page;
    response_from_server.total = Math.ceil(count / req.query.rows);
    response_from_server.rows = [];

    for (item in docs) {
        response_from_server.rows.push({
            id  :docs[item].id,
            cell:[
                docs[item].group,
                docs[item].description,
                docs[item].path,
                docs[item].value
            ]
        });
    }

    // Return the gathered data.
    res.json(response_from_server);
})
.error(function (error) { …
Run Code Online (Sandbox Code Playgroud)

syntax-error node.js sequelize.js

6
推荐指数
1
解决办法
9550
查看次数

令牌"class"上的语法错误

我正在尝试创建一个嵌套类以便使用AsyncTask,但是eclipse在类SendData上给出了一个错误,说"令牌上的语法错误"类,"无效类型"为什么它会给我这个错误?

package com.example.myfirstapp;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.os.Bundle;
import android.app.Activity;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.content.Intent;
import android.widget.TextView;

public class DisplayMessageActivity extends Activity {
    String url = "http://www.mySIte.com/phpFIle";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

        TextView textView = new TextView(this);
        textView.setTextSize(40);
        textView.setText(message);

        setContentView(textView);

        new SendData().execute();
    }

    private class SendData() extends AsyncTask<Void, Void, Void>{ …
Run Code Online (Sandbox Code Playgroud)

java eclipse android syntax-error nested-class

6
推荐指数
2
解决办法
2万
查看次数

在VHDL中声明实体内的数组

我正在尝试建立一个缓冲区,以便为小型CPU设计保存16位,16位宽的指令.

我需要一种从我的测试平台将指令加载到缓冲区的方法.所以我想使用一个std_logic_vectors数组来实现这一目标.但是,我收到语法错误,我不知道为什么(或者如果我允许在VHDL中执行此操作).

语法错误位于我声明的行 instructions

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;




entity instruction_buffer is
    port
    (
    reset               : in std_logic;
    instructions        : in array(0 to 15) of std_logic_vector(15 downto 0);
    instruction_address : in  std_logic_vector(3 downto  0);
    clk                 : in std_logic;
    instruction_out     : out std_logic_vector(15 downto 0)
    );
end instruction_buffer;
Run Code Online (Sandbox Code Playgroud)

我也试过这样做,但后来我的实体端口映射中出现语法错误,告诉我这std_logic_vector是一个未知的类型.我发誓,VHDL的语法错误没有C哈哈那么有意义

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

package instructionBuffer is
    type instructionBuffer is array(0 to 15) of std_logic_vector (15 downto 0);
end package instructionBuffer;

entity instruction_buffer is
    port
    (
    instruction_address …
Run Code Online (Sandbox Code Playgroud)

syntax-error vhdl hdl

6
推荐指数
2
解决办法
1万
查看次数

使用"class"关键字声明变量vs在函数签名中声明一个没有"class"关键字的变量

这两种方法有什么区别?

有时当我遇到编译时错误抱怨编译器无法识别函数签名中的某些类类型时,如果我在相应变量前面添加关键字"class",它总能解决这种编译时错误.

例如,如果编译器无法识别Client中的类型

void recv( Client * c )
Run Code Online (Sandbox Code Playgroud)

然后,如果我改变它

void recv( class Client * c )
Run Code Online (Sandbox Code Playgroud)

问题已经解决了.

对不起,我无法想出一个具体的例子,因为我随机提出了​​这个问题.

c++ compiler-errors class syntax-error keyword

6
推荐指数
1
解决办法
215
查看次数

HTML5验证时出现空标题警告

我尝试验证我的HTML代码,我发现了这个警告:空标题.看这里

显然标题不是空的.<h3></h3>在WordPress中,按the_title()函数生成内容.所以,我不明白为什么会发生这种情况..有人可以解释一下这是什么问题?谢谢!

validation wordpress html5 syntax-error

6
推荐指数
1
解决办法
1万
查看次数

用于SQL Server的Microsoft OLE DB提供程序错误"80040e14"'='附近的语法不正确

当我尝试使用以下代码从数据库中检索数据时,我收到此错误.

有人可以帮忙吗?

set rs = Server.CreateObject("ADODB.recordset")
sql = " SELECT * from COMPANY WHERE COMPANY_ID = " & Request.Form("CompanyId")
rs.Open sql, cnn
Run Code Online (Sandbox Code Playgroud)

sql-server syntax-error

6
推荐指数
1
解决办法
3万
查看次数

'CREATE PROCEDURE'必须是批次中唯一的声明(Erro)

我正在创建此表,但我遇到了第一个过程的问题(sp_joseview)

create table josecustomer(
name varchar(50),
address varchar(300),
ssnid int,
balance bigint,
accountnumber bigint
)

insert into josecustomer values('Aman','Canada',10000,5000,100000000)
insert into josecustomer values('Shubham','USA',10001,6000,200000000)
insert into josecustomer values('Himanshu','Australia',10002,2000,300000000)
insert into josecustomer values('Jose','India',10003,3000,400000000)
insert into josecustomer values('Albert','Brazil',10004,4000,500000000)
insert into josecustomer values('Peterson','Germany',10005,7000,600000000)
insert into josecustomer values('Adam','Honkong',10006,8000,700000000)
insert into josecustomer values('William','Paris',10007,9000,800000000)

select * from josecustomer

create proc sp_joseview
as begin
select * from josecustomer
end
go

create proc sp_updatejose
(@accountno bigint,@newbalance bigint)
as begin
update josecustomer 
set balance=@newbalance
where accountnumber=@accountno
end 
go
Run Code Online (Sandbox Code Playgroud)

第一个过程显示语法错误,但我无法弄清楚该错误可能是什么.

sql sql-server syntax-error

6
推荐指数
2
解决办法
2万
查看次数

为什么在这里引发IndentationError而不是SyntaxError?

为什么在以下程序中IndentationError被提升而不是SyntaxError?

>>> if True:
... print "just right!"
  File "<stdin>", line 2
    print "just right!"
        ^
IndentationError: Missing parentheses in call to 'print'
Run Code Online (Sandbox Code Playgroud)

为了确保IDLE不只是表现得很有趣,我还通过从普通源文件运行它来测试此代码.仍然会引发相同的异常类型.我用来测试它的Python版本是Python 3.5.2和Python 3.6.1.

我的理解是,在使用时缺少括号print被认为是a SyntaxError,而不是a IndentationError.帖子中的首要答案在Python中,"SyntaxError:调用'print'时缺少括号"是什么意思?似乎也支持这个:

"SyntaxError:调用'print'时缺少括号"是Python 3.4.2中添加的新错误消息,主要是为了帮助那些在运行Python 3时尝试遵循Python 2教程的用户.

这是一个错误吗?如果是这样,是什么导致了它?

python indentation syntax-error python-3.x

6
推荐指数
1
解决办法
178
查看次数