变量表或列名 [英] Variable table or column names

查看:87
本文介绍了变量表或列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

INFORMIX-SQL或任何其他基于SQL的数据库:

INFORMIX-SQL or any other SQL-based DB:

假设我有一个应用,其中取决于某些列的值,例如:

Suppose I have an app where depending on the value of some columns, example:

company.code  char(3) {abc}
company.branch char(2) {01}

我可以构造表名称"abc01"以包含在SELECT * FROM abc01中吗? ? 换句话说,变量表名..相同的问题适用于列名.

Can I construct table name "abc01" for inclusion in SELECT * FROM abc01; ? In other words, a variable table name.. same question applies for column names.

推荐答案

仅使用可以操纵字符串并处理Dynamic SQL的语言.它必须动态创建语句.

Only in a language which can manipulate character strings and handle Dynamic SQL. It has to create the statement on the fly.

您只能在查询值中使用占位符,而不能在查询的结构元素(如表名或列名)中使用占位符.

You can only use placeholders in queries for values, not for the structural elements of the query such as the table name or column name.

这篇关于变量表或列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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