call data from sql in processmaker - processmaker

i have a table in sql which is like this:
| product code | weight|
| ----------------------|-----------|
| 1235896 | 0.5|
| 3256kms | 1.5|
| dk-kmsw | 3 |
and the data type for [product code] is nvarchar
now i want to call the weight by putting the product code in processmaker
the code that i wrote is this:
select [weight] from table where [product code] = ##textVar047
and by this code i get nothing, i have changed the ## to ##, #= but it did not work.
how can i do this?
any comment is appreciated.

When you use ## in the SQL of a control, it means you are referencing another control's value. If that's your scenario I'd suggest first to retrieve the full list of product codes in a Suggest control (instead of a Textbox) with this SQL:
select PRODUCT_CODE, PRODUCT_CODE FROM YOUR_TABLE_NAME
(you call product code twice since Suggest controls, like dropdowns, need 2 values to be filled up, one for the id and one for the label)
Now that you have a way to obtain the actual code and it's saved in the suggest control id, you can make another field a dependent field with the SQL you where proposing:
select WEIGHT FROM YOUR_TABLE_NAME where PRODUCT_CODE = ##your_suggest_control_id
(## should work just fine as it just adds quotes to the variable)
You can also check the wiki page to get an in depth explanation of this. https://wiki.processmaker.com/3.1/Dependent_Fields
I hope this helps!

select CAST(weight AS nvarchar(max)) from table where [product code] = ##textVar047

Related

Is it possible to use literal data as stream source in Sumologic?

Is it possible for a Sumologic user to define data source values inside a Query and use it in subquery condition?
For example in SQL, one can use literal data as source table.
-- example in MySQL
SELECT * FROM (
SELECT 1 as `id`, 'Alice' as `name`
UNION ALL
SELECT 2 as `id`, 'Bob' as `name`
-- ...
) as literal_table
I wonder if Sumo logic also have such kind of functionality.
I believe combining such literal with subqueries would make user's life easier.
I believe the equivalent in a Sumo Logic query would be combining the save operator to create a lookup table in a subquery: https://help.sumologic.com/05Search/Subqueries#Reference_data_from_child_query_using_save_and_lookup
Basically something like this:
_sourceCategory=katta
[subquery:(_sourceCategory=stream explainJSONPlan.ETT) error
| where !(statusmessage="Finished successfully" or statusmessage="Query canceled" or isNull(statusMessage))
| count by sessionId, statusMessage
| fields -_count
| save /explainPlan/neededSessions
| compose sessionId keywords]
| parse "[sessionId=*]" as sessionId
| lookup statusMessage from /explainPlan/neededSessions on sessionid=sessionid
Where /explainPlan/neededSessions is your literal data table that you select from later on in the query (using lookup).
You can define a lookup table with some static map/dictionary you update not so often (you can even point to a file in the internet in case you change the mapping often).
And then you can use the |lookup operator. It's nothing special for subqueries.
Disclaimer: I am currently employed by Sumo Logic.

Talend csv to relational db tables : foreign key setting

I'm a Talend beginner and searched about this simple problem, many have posted the web about the same problem but no solution appeared...
I have a csv file with 50 fields, I want to load it into a three tables relational database with Talend. I did a tMap, everything is ok except for foreign key : I don't know how to set them.
Here is my job
Here is my tMap
I hope someone could give me the simple exact solution
Cheers
Pascal
You can do it in two Time.
(CSV) -> (tmap) -> (organisation_output)
|
subjobok
|
| (organisation_input)
| |
(CSV) -> (tmap)-> (country and adress output)
Do a INNER JOIN in the second tmap on column that have unique value for each row.
And load 'ImpID' of your organisation input in the two other output table Impid column.

Sqlite3: Selecting from multiple tables without duplicates

I've got three tables:
paper: items: attachments:
============ ============== ==============
jkey | title itemID | jkey* itemID* | path
*foreign key from another table
I'm trying to retrieve the title of all papers and their associated attachment paths, for all papers that have attachments.
Current attempt is:
SELECT paper.title,attachments.path IN paper,attachments
WHERE paper.jkey IN (
SELECT items.jkey FROM items,attachments
WHERE items.itemID = attachments.itemID
);
Unfortunately this just seems to print gibberish (the same path for different titles and vice versa).
What am I doing wrong?
If you want to join, you should use joins:
SELECT paper.title,
attachments.path
FROM paper
JOIN items USING (jkey)
JOIN attachments USING (itemID);
To omit duplicate rows, use SELECT DISTINCT ... instead.

How to show same column in dbgrid with different criteria

i need your help to finish my delphi homework.
I use ms access database and show all data in 1 dbgrid using sql. I want to show same column but with criteria (50 record per column)
i want select query to produce output like:
No | Name | No | Name |
1 | A | 51 | AA |
2 | B | 52 | BB |
3~50 | | 53~100| |
Is it possible ?
I can foresee issues if you choose to return a dataset with duplicate column names. To fix this, you must change your query to enforce strictly unique column names, using as. For example...
select A.No as No, A.Name as Name, B.No as No2, B.Name as Name2 from TableA A
join TableB B on B.Something = A.Something
Just as a note, if you're using a TDBGrid, you can customize the column titles. Right-click on the grid control in design-time and select Columns Editor... and a Collection window will appear. When adding a column, link it to a FieldName and then assign a value to Title.Caption. This will also require that you set up all columns. When you don't define any columns here, it automatically returns all columns in the query.
On the other hand, a SQL query may contain duplicate field names in the output, depending on how you structure the query. I know this is possible in SQL Server, but I'm not sure about MS Access. In any case, I recommend always returning a dataset with unique column names and then customizing the DB Grid's column titles. After all, it is also possible to connect to an excel spreadsheet, which can very likely have identical column names. The problem arrives when you try to read from one of those columns for another use.

How to get output of sql queries in FitNesse + DbFit?

I am trying to get sql query output in DBfit using i.e. !|Execute|select * from abc| but don't know how it will display in DBfit.
I think that you are looking for the Inspect Query table (you can find reference docs about it here).
!|Inspect Query|select * from abc|
When executed, this will print the resultset of the query.
First, the execute fixture is typically used for actions that do not return data, e.g.:
!|Execute|insert into tablename values (…)|
or
!|Execute|update tablename st... where...|
However, even some non-data actions have more specific commands. The above update can be done with, for example, with:
!|Update|tablename |
|field_to_change=|field_to_select|
|new value |matching value |
For returning data, use the query fixture
!|query|select Id, BatchNum from tablename|
|Id |BatchNum? |
|1 |>>Bat1 |
|2 |<<Bat1 |
As shown, just put your field names in the row below the fixture, then your data rows below that.

Resources