How to find length of ResultSet using IdocScript in Oracle UCM? - oracle-ucm

I am trying to find number of rows in a ResultSet using idocscript. Is there an optimal way of doing other than looping through the ResultSet as below?
<$sampleRSLength=0$>
<$if rsExists("sampleResultSet")$>
<$loop sampleResultSet$>
<$sampleRSLength=sampleRSLength+1$>
<$endloop$>
<$endif$>

I was able to find the answer myself after reading through the IdocScript reference guide in detail.
Idocscript has a method rsNumRows() which can be used for getting number of rows in a result set.
<$if rsExists("sampleResultSet")$>
<$sampleRSLength=rsNumRows("sampleResultSet")$>
<$endif$>

<$sampleResultSet.#numRows$>
will also work.

Related

Elquent Relation Limit records

I'm trying to send API with certain number of records
$category->products
I tried to use limit() or take() but it fails
so is there any smart solution than go to pivot and select it with limit ??
Copy data to a new collection.
$collection =$category->products;
you can now send the number of times you want using take ().
for example;
$collection->take(5);
if your question is different please explain it more clearly.
I found the solution I was easy
$category->products()->limit(2)->get()->all()
that's all

Oracle OCCI not able to retrieve the values after decimal point properly

I am retrieving the data from OracleDB using occi in my application.
While retrieving it, I found that the digits after decimal points were not properly retrieved.
For example, in the DB the original value was 12345.12 but while retrieving from resultset the value i got was 12345.1.
I need to retrieve the whole value (preferably double helps me a lot for my application mapping purpose). Any suggestions will help me a lot.
column in the Oracle DB is NUMBER(11,2) datatype.
I tried to retrieve from result set in the following ways but still got the same truncated value in it.
resultSet -> getDouble(1);
Number nr = resultSet -> getNumber(1);
double d = nr.operator double();
I have tried resultSet->getString(1) and able to get the whole value. Yes i need to cast it to double but getting the data is important than casting. So i will go for it. If anyone has any better solution post it and I am ready to take it.

Reversing a string using an index in Oracle

I have a table that has IDs and Strings and I need to be able to properly index for searching for the end of the strings. How we are currently handling it is copying the information into another table and reversing each string and indexing it normally. What I would like to do is use some kind of index that allows to search in reverse.
Example
Data:
F7421kFSD1234
d7421kFSD1235
F7541kFSD1236
d7421kFSD1234
F7421kFSD1235
b8765kFSD1235
d7421kFSD1234
The way our users usually input thier search is something along the lines of...
*1234
By reversing the strings (and the search string: 4321*) I could find what I am looking for without completely scanning the whole table. My question is: Is making a second table the best way of doing this?
Is there a way to reverse index?
Ive tried an index like this...
create index REVERSE_STR_IDX on TABLE(STRING) REVERSE;
but oracle doesn't seem to be using it according to the Explain Plan.
Thanks in advance for the help.
Update:
I did have a problem with unicode characters not being reversed correctly. The solution to this was casting them.
Example:
select REVERSE(cast(string AS varchar2(2000)))
from tbl
where id = 1
There is the myth that a reverse key index can be used for that, however, I've never seen that in action.
I would try a "manual" function based index.
CREATE INDEX REVERSE_STR_IDX on TBL(reverse(string));
SELECT *
FROM TBL
WHERE reverse(string) LIKE '4321%';

Get maximum value with Zend_Db_Table

Ive got a Zend_Db_Table
Now I want to get the maximum available value of a field.
Is there a way to get the MAX(number) value or do I need to use basic SQL?
Thanks!
Use
new Zend_Db_Expr('MAX(number)')
as one of the fields in the Zend_Db_Table_Select.

Linq stored procedure with dynamic results

So I'm extremely new to Linq in .Net 3.5 and have a question. I use to use a custom class that would handle the following results from a store procedure:
Set 1: ID Name Age
Set 2: ID Address City
Set 3: ID Product Price
With my custom class, I would have received back from the database a single DataSet with 3 DataTables inside of it with columns based on what was returned from the DB.
My question is how to I achive this with LINQ? I'm going to need to hit the database 1 time and return multiple sets with different types of data in it.
Also, how would I use LINQ to return a dynamic amount of sets depending on the parameters (could get 1 set back, could get N amount back)?
I've looked at this article, but didn't find anything explaining multiple sets (just a single set that could be dynamic or a single scalar value and a single set).
Any articles/comments will help.
Thanks
I believe this is what you're looking for
Linq to SQL Stored Procedures with Multiple Results - IMultipleResults
I'm not very familiar with LINQ myself but here is MSDN's site on LINQ Samples that might be able to help you out.
EDIT: I apologize, I somehow missed the title where you mentioned you wanted help using LINQ with Stored Procedures, my below answer does not address that at all and unfortunately I haven't had the need to use sprocs with LINQ so I'm unsure if my below answer will help.
LINQ to SQL is able hydrate multiple sets of data into a object graph while hitting the database once. However, I don't think LINQ is going to achieve what you ultimately want -- which as far as I can tell is a completely dynamic set of data that is defined outside of the query itself. Perhaps I am misunderstanding the question, maybe it would help if you provide some sample code that your existing application is using?
Here is a quick example of how I could hydrate a anonymous type with a single database call, maybe it will help:
var query = from p in db.Products
select new
{
Product = p,
NumberOfOrders = p.Orders.Count(),
LastOrderDate = p.Orders.OrderByDescending().Take(1).Select(o => o.OrderDate),
Orders = p.Orders
};

Resources