简体   繁体   English

无法将此查询 function 转换为 Amazon Redshift

[英]Can't convert this query function to Amazon Redshift

I'm trying to migrate/create functions from a MySQL Database to Amazon Redshift.我正在尝试将函数从 MySQL 数据库迁移/创建到 Amazon Redshift。 I tried to use some tools to convert MySQL to Redshift but this line isn't working:我尝试使用一些工具将 MySQL 转换为 Redshift,但这条线不起作用:

DECLARE saldoAtual, saldoInicial, idPerfil INT default 0;声明 saldoAtual、saldoInicial、idPerfil INT 默认值 0;

I keep getting an error saying there is something wrong with "INT".我一直收到一条错误消息,说“INT”有问题。

Can anyone help me?谁能帮我?

You are going to need to pop up one level and evaluate what you My SQL code is doing.您将需要弹出一个级别并评估您的 My SQL 代码在做什么。 You see DECLARE in this case on MySQL is declaring a variable and setting its type and default value.在这种情况下,您会看到 DECLARE on MySQL 正在声明一个变量并设置其类型和默认值。 The DECLARE statement on Redshift is used to define a cursor for manipulating query output. These are two completely different actions that just happen to use the same term. Redshift 上的 DECLARE 语句用于定义一个 cursor 用于操作查询 output。这是两个完全不同的操作,只是恰好使用相同的术语。 These don't map.这些不是 map。

Further, Redshift doesn't have variable that you define and use at the SQL level.此外,Redshift 没有您在 SQL 级别定义和使用的变量。 Redshift does not have an operating environment like many transactional database have. Redshift 没有像许多事务数据库那样的操作环境。 It is focused on executing queries, not performing procedural scripts around these queries.它专注于执行查询,而不是围绕这些查询执行过程脚本。 It has a different division of labor than MySQL. You see Redshift is part of a larger computing environment, AWS, and these procedural actions are expected to be run outside the database using tools like Lambda, Glue, or Data Pipeline.它与 MySQL 有不同的分工。你看 Redshift 是更大的计算环境 AWS 的一部分,这些程序操作预计将使用 Lambda、Glue 或 Data Pipeline 等工具在数据库外部运行。

Redshift does have stored procedures and depending on your use case you may be able to map you code into a stored procedure. Redshift 确实有存储过程,根据您的用例,您可以将 map 编码到存储过程中。 These really aren't interchangeable but you may be able to get away with it.这些确实不可互换,但您可以摆脱它。 Otherwise you will need to evaluate what your MySQL code is doing and map it to the correct tool level at AWS.否则,您将需要评估您的 MySQL 代码在做什么,并将其 map 评估为 AWS 的正确工具级别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM