If the result of the pollingStatement (OracleDB Binding) in my Receive location is empty, can I proceed to the postPollStatement to execute an update?
It seems now it doesn't.
Yes, your PolledDataAvailableStatment should look something like
SELECT CASE
WHEN COUNT(*) > 0 THEN 0
ELSE 1
END
FROM <table>
WHERE <conditions>
This will a zero when there are rows and return a 1 when there are no rows.
Related
In Teradata I need a condition to select only records:
starting in numbers between 0 and 4
followed by string ABCD
followed by anything
I can use substring and it works. But this is not a nice piece of code.
SELECT
'4ABCDXXX' AS T
, CASE WHEN
Cast (Substring (T, 1,1) AS SMALLINT) BETWEEN 0 AND 4
AND Substring (T, 2,4) = 'ABCD'
THEN 'OK' ELSE 'NOK' END
I tried
LIKE '[0-4]ABCD%'
But this does not seem to be working...
How can this be elegantly achieved?
Thanks.
I don't think that Teradata supports the enhanced LIKE syntax which are you attempting. But, in lieu of this, we can use REGEXP_SIMILAR:
SELECT
'4ABCDXXX' AS T,
CASE WHEN REGEXP_SIMILAR('4ABCDXXX', '^[0-4]ABCD.*$', 'c')
THEN 'OK' ELSE 'NOK' END AS label
FROM yourTable;
I've never been able to make negative lookaheads work in Teradata, so I would use two tests:
select
'4ABCD123' as t,
case when
regexp_similar(t,'^[0-4]ABCD') = 1 -- starts with 0-4 followed by ABCD
and t like '%ABCD' -- does not end with ABCD
then 'nok' else 'ok' end,
I'd like to be able to do the following initially and also at anytime.
insert into balance (closing_amount, opening_amount, created, tx_id)
select closing_amount + :value, closing_amount, :date, :tx_id from balance order by id desc limit 1
Basically I'm inserting by using previous values. But if there are no values to begin with, nothing gets inserted.
I could use a union to which works the first time but duplicates on subsequent inserts.
I want to avoid two trips. Is there a way to do this?
Also, the tx_id will always be unique.
I think you want something like this:
insert into balance (closing_amount, opening_amount, created, tx_id)
select coalesce(max(closing_amount), 0) + :value,
coalesce(max(closing_amount), 0),
:date,
:tx_id
from (
select closing_amount
from balance
order by tx_id desc
limit 1
) t;
You only need the last closing_amount, so max(closing_amount) from the subquery, which returns 1 row or none at all, will return that closing_amount or null respectively.
See a simplified demo.
I have a quirky issue. I have a checkbox, a reports table and i'd like to click a checkbox or multi check boxes to return a result. In the Database I have a saved list of checkbox results seperated by a colon :
It all works except when I check box 'A' and 'C'. which is the first and last result in the database. I can click A and B or just A or just C or C and B but when i click A and C it doesn't work.
any clue?
select ...
from ...
where
AND (CASE WHEN :P1_BENEFITS_TAG IS NOT NULL
THEN instr( ':'|| UPPER(b.BENEFITS_TAGS)||':',
':'|| UPPER(:P1_BENEFITS_TAG) ||':' )
ELSE 1
END) > 0
It looks like your database row contains the string 'A:B:C:'.
When :P1_BENEFITS_TAG is any of the values 'A:B', 'B:C', 'A', 'B' or 'C' then the database row "contains" that value and your INSTR expression will return a number > 0.
However, 'A:B:C' does not contain the string 'A:C', so the INSTR will return 0 for that.
I'm new in mdx, i have question about count function and where clause.
if we want count a set that we have condition on it in where clause, condition act on count?
foe rexample:
with
member countofrows as
count([Date].[Date].[Date])
select countofrows on 0
from [Adventure Works]
where ([Date].[Date].&[20050101])
the mention queries must return 1 but the where cluse dont work and it returens 2191 rows.
Try the existing keyword:
Count(existing [Date].[Date].[Date].Members)
I have table with fields task_priority, task_completed_time,task_completed. Completed colume have values 0 and 1 and it is a primary sort. I want to make secondary sort to be priority if completed is 0 and completed_time if completed is 1. How can i get it?
after some typo fixes i made it:
SELECT * FROM task_table
WHERE (task_name LIKE ? )
ORDER BY task_completed ASC,
CASE task_completed
WHEN 0 THEN task_priority
WHEN 1 THEN task_completed_time
END DESC