Substring of a column in a join condition of database view - abap

I need to create an SAP Database view for EKPO table with some other tables. And need to get EBELN column's first three chars like Substring(EBELN,0,3)

No, this is impossible.
Even in CDS views, according to rules for ON operands, user-defined and standard function calls are prohibited:
No path expressions or other expressions or function calls can be specified.

Related

Names of RFC parameters are unique?

I am working on an interface for communicating with SAP RFC functions. I have some questions regarding parameter hierarchy and uniqueness of parameter and table naming to which I can't seem to find an answer anywhere online.
Are the deep hierarchical structures allowed when communicating via RFC? Here are some examples of input parameters:
Example A (Structure within Structure):
Field F1
Field F2
Structure S1
Field S1.F1
Structure S1.S1
Field S1.S1.F1
Field S1.S1.F2
Field S1.F2
Field S1.F3
Example B (Table within Structure):
Field F1
Field F2
Structure S1
Field S1.F1
Table S1.T1
Structure S1.T1.S1 (Row 1)
Field S1.T1.S1.F1
Field S1.T1.S1.F2
Structure S1.T1.S2 (Row 2)
Field S1.T1.S2.F1
Field S1.T1.S2.F2
Field S1.F2
Field S1.F3
Example C (Table within Table):
Field F1
Field F2
Table T1
Structure T1.S1 (Row 1)
Field T1.S1.F1
Table T1.S1.T1
Structure T1.S1.T1.S1 (Row 1)
Field T1.S1.T1.S1.F1
Field T1.S1.T1.S1.F2
Structure T1.S1.T1.S2 (Row 2)
Field T1.S1.T1.S2.F1
Field T1.S1.T1.S2.F2
Structure T1.S2 (Row 2)
Field T1.S2.F1
Table T1.S2.T1
Structure T1.S2.T1.S1 (Row 1)
Field T1.S2.T1.S1.F1
Field T1.S2.T1.S1.F2
Structure T1.S2.T1.S2 (Row 2)
Field T1.S2.T1.S2.F1
Field T1.S2.T1.S2.F2
Are the names of fields, structures and tables per hierarchical level unique? Or are the tables handled separately and could for example have the same name as a field or a structure?
RFC, including parameter types, is described in the documentation of each RFC Interface (documentation in each programming language RFC SDK, or ABAP documentation). You may use RFC both as client and server.
If you use RFC SDK (any programming language except ABAP) to create an RFC server (to expose RFC functions), I guess the types of the parameters support the same types as in ABAP (but I can't be sure so please refer to the documentation of each SDK in case of exceptions).
In ABAP, you can know the types of parameters supported in RFC by combining these two articles:
Properties of Interface Parameters
RFC - Restrictions
If you don't have the time to combine them, here's a summary of parameter types for RFC-enabled function modules:
A parameter can be of any type, elementary (what you call "fields"), structure, table.
Structures can have components of any of the 3 types above.
Tables which are not TABLES parameters can have lines of any of the 3 types above.
Tables which are TABLES parameters must have lines of type flat, which means that the line cannot contain fields of type STRING or XSTRING, nor tables.
The names of fields, structures and tables are unique per hierarchical level, whatever their parameter category, IMPORTING, EXPORTING, CHANGING or TABLES, e.g.
a component of a structure at level 1 may have the same name as a parameter at level 1.
a field and a structure at level 1 cannot have the same name
One exception to the previous rule is that two parameters can have the same name at level 1 if they are of type IMPORTING and EXPORTING (they are considered the same as one CHANGING parameter of that name - see SAP note 357348 - Import and export parameters of the same name).
The rows of one table all have the same type, so your diagrams mentioning S1 and S2 are incorrect, you could just mention S1. Note that a table parameter can have lines also of type elementary and table.
Here is an example of valid parameters of an RFC-enabled function module:
Field F1
Structure S1
Field S1.F1
Structure S1.S1
Field S1.S1.F1
Table T1
Structure T1.S1
Field T1.S1.F1
Table T2
Field T2.F1
Table T3
Table T3.T1
Field T3.T1.F1
Table T1
Table T1.T1
Field T1.T1.F1
Table T2
Structure T2.S1
Field T2.S1.F1
Table T3
Field T3.F1
Reference:
ABAP Documentation
Function Module Interface
Properties of Interface Parameters
FUNCTION, table_parameters (this concerns TABLES parameters with TYPE)
FUNCTION, LIKE, STRUCTURE (this concerns TABLES parameters with LIKE or STRUCTURE)
RFC - Restrictions
Pass-by value must be selected for the IMPORTING, EXPORTING, and CHANGING parameters of a remote-enabled function module. This cannot be specified explicitly for TABLES parameters, but are used implicitly for RFC.
*The formal parameter of a remote-enabled function module must be typed using data types from ABAP Dictionary or using predefined ABAP types. Data types from type groups cannot be specified.
No reference variables can be passed in RFCs. The formal parameters of a remote-enabled function module cannot, therefore, be typed using a reference type.
Others
357348 - Import and export parameters of the same name

PostgreSQL is it possible to parameterize the table name used in a query?

In PostgreSQL, is it possible to parameterize the table name used in a query?
Think of parameters as a replacement for scalar values only. Use one parameter in the place where you could use one string literal or numeric literal.
You cannot use parameters for other parts of an SQL query:
Identifiers like table names, column names, etc.
SQL keywords
Expressions
Lists of values, such as in an IN (...) predicate. Each value in the list would need an individual parameter.
All those parts of the SQL query must be fixed by the time the query is parsed during prepare(). If a client library supports "parameters" for identifiers, it's really doing string-interpolation into the SQL query before the query is parsed.

HIve/Impala Converting String into Lower case before using in hql

I need to convert the name of the table into lower before passing it for the query.
Irrespective of which case in pass the value for parameter $1 i need it to be converted into lower case before executing the below query.
QUERY:
show tables like '$1';
I have tried something like
QUERY
show tables like 'lower($1)';
But this doesn't work.
please help.
Your response would be highly appreciated
Impala identifiers are always case-insensitive. That is, tables named
t1 and T1 always refer to the same table, regardless of quote
characters. Internally, Impala always folds all specified table and
column names to lowercase. This is why the column headers in query
output are always displayed in lowercase.
Impala Documentation
All the below queries will give same result as internally impala converts to lowercase.
show tables like 'test*';
show tables like 'TeSt*';
show tables like 'TEST*';

Is it possible to use a generic identifier in a SELECT query in SQLite?

I'm creating a function for querying a SQLite database that should be generic in the sense of reading from multiple pre-defined tables. As part of the function's paremeters, it is necessary to tel which column of the table should be read, an info that is supposed to be passed by an enumerator value. So the call would be something like this:
callMyFunction(enumTableA,enumColumnB);
Since enumColumnB is an enumerator value, the argument is an integer and I would like to identify the column by that integer value without having to use a switch-case for that. Something like this:
SELECT column(enumColumnB) from ...
So instead of passing the name of the column or reading all columns with * and then selecting the desired one when reading, it would use the number of the column as passed by the enumerator value to identify what should be read.
Is it possible to do this for SQLite? I couldn't find any tutorial mentioning such possibility, so I'm almost concluding there is no such possibility (and I'll have to pass the name of the column as argument or use a switch-case at the end), but I'ld like to be sure I don't have this option available.
SQLite has no mechanism for indirect columns.
(SQLite is designed as an embedded database, i.e., to be used together with a 'real' programming language.)
You have to replace the column name in whatever programming language you're using.

In Oracle, how do you select multiple values from a related table and store them in a single column?

I'm selecting columns from one table and would like to select all values of a column from a related table when the two tables have a matching value, separate them by commas, and display them in a single column with my results from table one.
I'm fairly new to this and apologize ahead of time if I'm not wording it correctly.
It sounds like what you're trying to do is to take multiple rows and aggregate them into a single row by concatenating string values from one or more columns. Yes?
If that's the case, I can tell you that it's a more difficult problem than it seems if you want to do it using portable SQL - especially if you don't know ahead of time how many items you may get.
The Oracle-specific solution often used in such cases is to implement a custom aggregate function - STRAGG(). Here's a link to an article that describes exactly how to do so and has examples of it's usage.
If you're on Oracle 9i or later and are willing to live with using undocumented functions (that could change in the future), you can also look at the WM_CONCAT() function - which does much the same thing.
You want a row aggregation or concatenation function, choices are:
If you are using Oracle 11gR2, there is a built-in function to aggregate strings with a delimiter called LISTAGG(column, delimiter).
If you are using any earlier release of Oracle database, you can use WM_CONCAT(column) function, however you have no choice of delimiter and will have to use something like TRANSLATE(string, string_to_replace, replacement_string) function to change the delimiter afterwards if your data does not contain commas.
As mentioned by LBushkin, you can create a custom function in your schema to perform row aggregation for you. Here is PL/SQL code example for one: http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php#user_defined_aggregate_function