Informix - Aggregating list of values into comma-delimited string - informix

Is there a way to convert a list of values into a comma-delimited string in Informix? For example, I have the following query as a subselect:
SELECT [State] From States
I would like to convert all the values from that select into a comma-separated list.
Can I do that in informix?

I think the answer you need is given in these questions: SO 715350, SO 489081. It shows how to create and use a GROUP_CONCAT() aggregate that will do exactly what you want. The functionality is otherwise not available - that is, you have to add it to Informix, but it can (fairly) easily be added.

Related

Write to BQ one field of the rows of a PColl - Need the entire row for table selection

I have a problem:
My Pcoll is made of rows with this format
{'word':'string','table':'string'}
I want to write into BigQuery only the words, however I need the table field to be able to select the right table in BigQuery.
This is how my pipeline looks:
tobq = (input
| 'write names to BigQuery '>> beam.io.gcp.bigquery.WriteToBigQuery(
table=compute_table_name, schema=compute_schema,
insert_retry_strategy='RETRY_ON_TRANSIENT_ERROR',
create_disposition=beam.io.gcp.bigquery.BigQueryDisposition.CREATE_IF_NEEDED,
write_disposition=beam.io.gcp.bigquery.BigQueryDisposition.WRITE_APPEND)
)
The function compute_table_name accesses an element and returns the table field. Is there a way to write into BQ just the words while still having this table selection mechanism based on rows?
Many thanks!
Normally the best approach with a situation like this in BigQuery is to use the ignoreUnknownValues parameter in ExternalDataConfiguration. Unfortunately Apache Beam doesn't yet support enabling this parameter while writing to BigQuery, so we must find a workaround, as follows:
Pass a Mapping of IDs to Tables as a table_side_input
This solution only works if identical word values are guaranteed to map to the same table each time, or there is some kind of unique identifier for your elements. This method is a bit more involved than Solution 1, but it relies only on the Beam model instead of having to touch the BigQuery API.
The solution involves making use of table_side_input to dynamically pick which table to place an element even if the element is missing the table field. The basic idea is to create a dict of ID:table (where ID is either the unique ID, or just the word field). Creating this dict can be done with CombineGlobally by combining all elements into a single dict.
Meanwhile, you use a transform to drop the table field from your elements before the WriteToBigQuery transform. Then you pass the dict into the table_side_input parameter of WriteToBigQuery, and write a callable table parameter that checks with the dict to figure out which table to use, instead of the table field.

Use reactivesearch to query multiple indices

I realize that one can use ReactiveBase to setup a connection to an index and then, use the components to query and return information from that index.
Is there a way to bind to multiple indices and search on a field across them or return results that are a 'merge' of fields from these multiple indices?
In order to query multiple indices ReactiveBase can accept comma separated values in the app prop. Example:
<ReactiveBase
app="index1,index2"
...
>
...
</ReactiveBase>
thanks to siddharthlatest, it is possible by providing multiple comma-separated indices - reference.
It has been reflected in the ReactiveBase documentation as well.

visNetwork selectedBy (visOptions function) for multiple columns

I have written code for a visNetwork network. Within the visOptions function, it can currently select node by id (using nodesIdSelection) as well as select nodes using values from a particular column (using selectedBy). I have looked through the documentation to see how to select nodes using additional columns (i.e. multiple drop down lists in HTML) but can't find the syntax.
Any help would be much appreciated.
try to use the DataSet get method with your prefered options.
then you can select the returned array to select your nodes.

IN Clause used in the case of IN parameters is not Working while DELETING

I want to delete my records from the database based on some ID's.
This is the statement written in my STORED PROCEDURE to delete records based on DeletedID.
DELETE FROM tms_activity where activity_id IN (DeletedID);
My DeletedID is a string with records comma seperated like("1,2,3")
Now when I am passing DeletedID in my Statement as a parameter it is taking the input as "1,2,3" and deleting the record with the first DeletedID it is getting(1 in this case).But I want to delete all the records based on the given parameter.
DeletedId must be passed like (1,2,3) rather than ("1,2,3") than only it can delete all the records based on provided ID's...Now how can I do that?
I consulted this question: MySQL wrong output with IN clause and parameter,
but couldn't understand how can I achieve my result.
Did you try this
DELETE FROM tms_activity where activity_id in
( SELECT ACTIVITY_ID FROM SOMETABLE WHERE FIELD = CRITERIA )
Or some more findings, if I were at this problem would select one of these solutions.
I investigated and found some very good links for you.
[http://johnhforrest.com/2010/10/parameterized-sql-queries-in-c/][1]
The Parametrized SQL queries have a benefit if you have to send a large number of parameters and want to run against one sql. It takes the sql in one chunk and all the parameters in other so keep the network traffic low.
You can search more in this topic
Thanks
QF

TFS: how can I create integer field based on string?

Work Item has "Rank" field of string type. Usually it contains numbers only.
It is necessary to provide ability to sort work items by this field in "numeric" interpretation. For now two values are compared like this:
"100"<"60"
But it is necessary to have:
100>60
It is not critical to sort fields that have string. But if possible - usual string sorting would be good.
I see few ways to do that:
Idea1: Apply some kind of formatting to existing column in order to interpret string value as integer. I don't know if it is possible though.
Q1. Is idea1 feasible? If yes, how can I do that.
Idea2: create additional field (RankInt) and apply rule "Copy", something like "Copy 'Rank' field".
Q2: When I tried to create such rule I got an error:
TF26048: The rule 'COPY' for field 'RankInt' refers to field 'Rank', which is a different field type.
How can I do such conversion?
Thanks a lot!
P.S. TFS 2008
We had a similar situation where in the dev team wanted to sort the work items and see it on the report.
We suggested that the dev team use the "Priority" field which is an integer field, and 2. After that change your team queries to include the "Priority" field in the columns based on which they can sort their work items,
You may optionally want to customize the workitem field to limit the values needed.
This addressed their issue.
Actually, I've added new field "RankInt" of integer type, using export to excel copied all values from "Rank" into "RankInt". On the work item UI field "Rank" was removed, "RankInt" was used instead.
Here we won't synchronize Rank and RankInt... but it is not too critical, at least for now.
If you see any other drawback, please let me know.

Resources