将存储过程嵌套在Where子句中 [英] Nest a Stored Procedure in a Where Clause

查看:83
本文介绍了将存储过程嵌套在Where子句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi DB People,


我有一个存储过程将特定的id转换为另一种格式(某些条件和按位操作)。现在我需要将它放在SELECT语句中。


除了创建一个INOUT参数然后在SELECT中使用该变量之外,我不知道该怎么做。


SP将此转换为:EP001234561234类似于1234567


我搜索谷歌并且无法执行此操作:

Hi DB People,

I have a stored procedure that converts a specific id into another format (some conditions and bit-wise operations). Now I need to put this in a SELECT statement.

I''m not sure how to do it other than make an INOUT parameter and then use that variable in the SELECT.

The SP converts this: EP001234561234 to something like 1234567

I searched google and wasn''t able to do this:

展开 | 选择 | Wrap | 行号

推荐答案

我认为WHERE子句中的函数是OK
I think a function in a WHERE clause is OK
展开 | 选择 | Wrap | 行号


谢谢,我需要输入谷歌的关键词是MySQL存储过程与存储过的函数


杜!他们是不同的东西。 有用的链接


你提到的第二种方法对我的设置不起作用,因为对于我表中的每一行,我必须分配该变量,然后只为该行运行select。 (我已经用代码做的事情)。


Mucho Gracias!



Dan
Thank you, the keyword I needed to put into Google was "MySQL stored procedure vs stored functions"

Duh! They''re different things. Helpful Link:

The second method you mentioned wouldn''t work for my setup because for each row in my table I''d have to assign that variable, then run a select for that row only. (something I already do with code).

Mucho Gracias!



Dan


我无法使功能按预期工作并观察到一些奇怪的行为。


我没有第一个初始号码插入到我的查询中,就像我最初暗示的OP一样,这个id实际上是另一个表中的一个字段。


所以基本上有2个表,一个有ID的格式,另一个有整数格式。


这个有效:

I have trouble getting the function to work as intended and observed some weird behavior.

I don''t have that first initial number to insert into my query like my OP initially implied, this id is actually a field in another table.

So basically 2 tables, one has one format for the ID, the other has the integer format.

This works:

展开 | 选择 | Wrap < span class =codeDivider> | 行号


这篇关于将存储过程嵌套在Where子句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆