Is this possible? Crosstab query

Hi All,
I have a rather complicated requirement am trying to fulfill. I'll make it simple and leave unnecessary details out. I have a table with structure similar to shown below.
DECLARE @Trans TABLE (
trans_year int NULL,
customer_name nvarchar(100) NULL,
Amount FLOAT,
Quantity FLOAT)
INSERT INTO @Trans VALUES (2010, 'ABC', 100, 200)
INSERT INTO @Trans VALUES (2011, 'ABC', 200, 100)
INSERT INTO @Trans VALUES (2012, 'ABC', 500, 100)
INSERT INTO @Trans VALUES (2013, 'ABC', 400, 700)
INSERT INTO @Trans VALUES (2014, 'ABC', 600, 800)
SELECT * FROM @Trans
What I am trying to do is, for each customer, get all the amounts across by year. And for each year, I need to add a field that can show the total
until that year(sort of like YTD). This code will be executed in a stored procedure and the stored procedure has two parameters called start_year and end_year. For the first year provided as the parameter, we don't need the Total column as
it is going to be same as the amount for that year. Also, the quantity column is going to act like a normal column(not shown in the desired output below) and can be ignored for our discussion. Below is how the output needs to be.
Can someone please help? Thanks in advance!!
Cust
2010
2011
Total 
2012
Total 
2013
Total 
2014
Total 
 ABC
100
200
300
500
800
400
1200
600
1800

Well, to fix your immediate problem you needed to use correct variable in the loop (@year).
So, this is your code corrected
CREATE TABLE #Trans (
trans_year INT NULL
,customer_name NVARCHAR(100) NULL
,Amount FLOAT
,Quantity FLOAT
INSERT INTO #Trans
VALUES (
2010
,'ABC'
,100
,200
INSERT INTO #Trans
VALUES (
2011
,'ABC'
,200
,100
INSERT INTO #Trans
VALUES (
2012
,'ABC'
,500
,100
INSERT INTO #Trans
VALUES (
2013
,'ABC'
,400
,700
INSERT INTO #Trans
VALUES (
2014
,'ABC'
,600
,800
DECLARE @StartYear INT
,@EndYear INT;
SELECT @StartYear = MIN(trans_year)
,@EndYear = MAX(trans_year)
FROM #Trans;
DECLARE @Columns NVARCHAR(max)
,@Year INT;
SET @Columns = '';
SET @Year = @StartYear
WHILE @Year <= @EndYear
BEGIN
SET @Columns = @Columns + ', ' + quotename(cast(@year AS NVARCHAR(max)))
SET @Year = @Year + 1;
END
SET @Columns = STUFF(@Columns, 1, 2, '');
DECLARE @SQL NVARCHAR(max);
SET @SQL = ';WITH CTE AS (SELECT trans_year, customer_name, Amount FROM #Trans
WHERE trans_year >= @StartYear and trans_year < @EndYear)
SELECT * FROM CTE PIVOT (SUM(Amount) FOR trans_year IN (' + @Columns + ')) pvt'
--print @SQL;
EXECUTE sp_ExecuteSQL @SQL
,N'@StartYear INT, @EndYear INT'
,@StartYear
,@EndYear
DROP TABLE #Trans
However, this is not exactly what I had in mind for your case. In your case since you wanted to add Total columns in between I proposed to use slightly different approach of using CASE expressions and GROUP BY.
Will you be able to figure this out now or you need the solution spelled out?
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • Is this Possible through a query?

    Hi All,
    i am calling this function in an update statement.
    this function queries a table based on the conditions and will return the latest(max) date from table.
    Is it possible to achieve this in a query?
    CREATE OR REPLACE Function getmaxdate(pRLK_RK number,
    pLN_RK number,pRLK_ACT_FLG varchar) Return date Is
    vnum number(3);
    pmaxdate date;
    Begin
    select (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT)) into vnum from rate_tab
    where RLK_RK=pRLK_RK
    and LN_RK=pLN_RK
    and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
    dbms_output.put_line('Value of vnum'||vnum);
    If vnum < 0 then
         select RLOCK_EXT_END_DT into pmaxdate from rate_tab
         where RLK_RK=pRLK_RK
         and LN_RK=pLN_RK
         and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
    elsif vnum > 0 then
         select RLOCK_END_DT into pmaxdate from rate_tab
         where RLK_RK=pRLK_RK
         and LN_RK=pLN_RK
         and RLK_ACTIVE_FLG=pRLK_ACT_FLG;
         --return pmaxdate;     
    End If;
    return pmaxdate;
    dbms_output.put_line('Value of pmaxdate'||pmaxdate);
    End;
    Any suggestions?
    Thanks.

    may be this
    select (case when (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT)) <0 then
                      RLOCK_EXT_END_DT
              when    (Trunc(RLOCK_END_DT) - Trunc(RLOCK_EXT_END_DT))> 0 then
                    RLOCK_END_DT
              end) max_date       
    from rate_tab
    where RLK_RK=pRLK_RK
         and LN_RK=pLN_RK
         and RLK_ACTIVE_FLG=pRLK_ACT_FLG;

  • Crosstab query is it possible in BEX?

    Hi
    I am working with the Marketing attributes ODS 0ATR_DS01 and I want a query that has the partner in rows with the attribute name in columns showing the attribute values i.e. a crosstab query.
    I've been playing with BEx trying to create a crosstab query - something I thought should be very straight forward but I just don't seem to be able to get it to work.  I searched the forums for Crosstab and don't get any hits, has anyone tried to create a crosstab - is it possible with BW - if so please point me in the right direction.
    Regards
    Gareth

    Hi,
    Make the<i> Attribute</i> the navigational attribute.
    Then you can take Partner in rows and <i>attribute</i> in columns.
    With rgds,
    Anil Kumar Sharma .P

  • SQL Query Help - Is this possible or impossible????

    Hi guys,
    I need help with an SQL query that I'm trying to develop. It's very easy to explain but when trying to implement it, I'm struggling to achieve the results that I want.....
    For example,
    I have 2 tables
    The first table is:
    1) COMPANY create table company (manufacturer varchar2(25),
                                                          date_established date,
                                                          location varchar2(25) );My sample test date is:
    insert into company values ('Ford', 1902, 'USA');
    insert into company values ('BMW', 1910, 'Germany');
    insert into company values ('Tata', 1922, 'India');The second table is:
    2) MODELS create table models (manufacturer varchar(25),
                                                 model varchar2(25),
                                                 price number(10),
                                                 year date,
                                                 current_production_status varchar2(1) ) ;My sample test data is:
    insert into models values ('Ford', 'Mondeo', 10000, 2010, 0);
    insert into models values ('Ford', 'Galaxy', 12000,   2008, 0);
    insert into models values ('Ford', 'Escort', 10000, 1992, 1);
    insert into models values ('BMW', '318', 17500, 2010, 0);
    insert into models values ('BMW', '535d', 32000,   2006, 0);
    insert into models values ('BMW', 'Z4', 10000, 1992, 0);
    insert into models values ('Tata', 'Safari', 4000, 1999, 0);
    insert into models values ('Tata', 'Sumo', 5500,   1996, 1);
    insert into models values ('Tata', 'Maruti', 3500, 1998, 0);And this is my query:
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer IN ('Ford', 'BMW', 'Tata')
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCWhat I want the query to output is this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               Sumo               5500               1998          1If current_production_status is 1 it means this particular model has been discontinued
    If current_production_status is 0 it means the manufacturer does not have any discontinued models and all are in procuction.
    The rule is only one record per manufacturer is allowed to have a current_production_status of 1 (so only one model from the selection the manufactuer offers is allowed to be discontinued).
    So the query should output the one row where current_production_status is 1 for each manufacturer.
    If for a given manufacturer there are no discontinued models and all have a current_production_status of 0 then ouput a SINGLE row that only includes the data from the COMPANY table (as above). The rest of the columns from the MODELS table should be populated with a '-' (hyphen).
    My query as it is above will output all the records where current status is 1 or 0 like this
    com.manufacturer        com.date_established          com.location          mod.model          mod.price          mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    Tata               1922                    India               Sumo               5500               1998          1
    Ford               1902                    USA               -               -               -          0                    
    Ford               1902                    USA               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    BMW               1910                    Germany               -               -               -          0
    Tata               1922                    India               -               -               -          0
    Tata               1922                    India               -               -               -          0However this is not what I want.
    Any ideas how I can achieve the result I need?
    Thanks!
    P.S. Database version is '10.2.0.1.0'

    Hi Vishnu,
    Karthiks query helped...
    But this is the problem I am facing...
    SELECT
            com.manufacturer,
            com.date_established,
            com.location,
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.model),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.price),
            DECODE(nvl(mod.current_production_status, '0'), '0', '-', mod.year),
            mod.current_production_status
    FROM
           company com,
           models mod
    WHERE
          mod.manufacturer = com.manufacturer
          and com.manufacturer = 'Ford'
          and mod.current_production_status IN (1,0)
    ORDER BY
            mod.current_production_status DESCThe value of:
    and com.manufacturer = 'Ford'will be dependent on front end user input....
    When I run the query above I get all the rows where current_production_status is either 1 or 0.
    I only require the rows where current_production_status is 1.
    So if I amend it to look like this:
         and mod.current_production_status = 1This works....
    BUT if a user now passes in more than one manufacturer EG:
    and com.manufacturer IN ('Ford', 'BMW')The query will only return the one row for Ford where current_production_status is 1. However because BMW has no models where current_production_status is 1 (all 3 are 0), I still want this to be output - as one row....
    So like this:
    com.manufacturer        com.date_established          com.location          mod.model          mod.price             mod.year     mod.current_production_status
    Ford               1902                    USA               Escort               10000               1992          1
    BMW               1910                    Germany               -               -               -          0So (hopefully you understand), I want both cases to be catered for.....whether a user enters one manufacturer or more than one...
    Thanks you so much!
    This is really driving me insane :-(

  • Is it possible the query in view object is dynamic?

    Is it possible the query in view object is dynamic?
    Generally, make the column list dynamic.
    I think this is related to whether view object can be assembled at runtime based on a dynamic cursor in a procedure?
    I ask this because I would like to know how we can use OA framework to simulate crosstab workbook in Discoverer?
    Anybody has some clues, please advise.
    Thanks.

    Hi Shay,
    Let me tell you briefly... I am sending input as customerId,customerNumber,CustomerName to the web service, if the record is available i am getting the response and i am displaying those records on page as a table. Now when i click a row i need to populate another table with all sale orders of that customer. From webservice datacontrol i have only customer object, I dont have Sales Order Object. For this i need master detail relation. In this case how to proceed. Thats why i am thinking to create a vO and EO object for sales orders table and i want to create view link for this sales order and customers. As i don't have customer VO and EO object to create view link.

  • Crosstab Query in Oracle

    Dear members:
    I have been trying to generate a crosstab query in Oracle using SQL.
    This is the situation:
    I have two tables in Oracle. One contains characteristics of institutions which people visit, and includes, amongst other fields, the ID of the institution (number) and an identificator for the district where the institution is implanted (number; ranging 1 - 18).
    The second table also contains a field with the ID of the institution, and more: the date when the visit occured (date), and a sequential (unique) number for each visit.
    What I need to obtain is a final table containing the following fields:
    Date of the visit, total number of visitors per date of visit, and a field for each district containing the total number of visitors to instituitions of the district per each date of visit.
    Can anyone give me a hint on this?
    Also; is there a user-frindly interface minimizing the use of SQL that I can download from Oracle for generating this?
    Thank You
    André

    Crosstab is a reporting function not a SQL one. SQL statements must have a fixed number of columns regardless of the data.
    The only way to do it using SQL is to use PL/SQL to generate a dynamic query as shown on Ask Tom here
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:15151874723724
    Otherwise there are reporting tools such as Oracle Reports that can do it as well.

  • Select Empno,name,sum()..group by empno only  Is this possible?

    select empno,name,sum(sal) from emptable where year=' ' groub by empno order by empno.
    this query getting error because i didn't include empname in group by.
    But if i include this name, my sum is not correct.
    so i want to empno,name but i don't want to include name in group by. Is this possible?
    My oracle verion is 8.
    IS any other solution to solve this problem?
    Thanks in advance.

    i want to empno,name but i don't want to include name in group by. Is this possible?<br>
    <br>
    No. It isn't.
    <br>
    select empno,name,sum(sal) over (partition by empno) <br>
    from emptable
    <br>where year=' '
    <br>
    -- <s>groub by empno</s>
    <br>
    order by empno;

  • Format Column Header in Crosstab Query in Crystal Reports for Enterprise

    Hi
    I am using Crystal reports for Enterprise and I would like to format the Column header of a crosstab query one block of colour say light blue.  However I cannot select the header in isolation to the rest of the cross tab.  All I can select is either column text boxes, which doesnu2019t look good formatted as a different colour to the background of the crosstab.  Or I can only select either entire column or the entire row, which kind of defeats the object of formatting just the column header itself.  Is there a way to isolate the column headers so I can format just the header, as the report is looking extremely bland all in white?
    Many Thanks in advance
    Regards
    Neil

    Alright, here's what you need to do:
    1) RIght-click one of the Column Headers and select 'Format Result Object Element' > Appearance > click on the formula button (fx) beside 'Fill' and use this code:
    if currentrowindex < 0 then crBlue
    You wanted light blue right? So, the rgb value for light blue or sky blue would be 135-206-250. So, you can change the color by modifying the formula like this:
    if currentrowindex < 0 then color(135,206,250)
    If this is not the exact blue you're after, just google!
    Hope this helps!
    -Abhilash

  • Custom column in Crosstab query in BO 6.5

    Hello Gurus,
    I am trying to create a report in BO 6.5 using data from two flat files by linking them and I applied cross-tab template as I need row data as columns based on a field called STATUS (Approved, Cancelled, In process etc). And in this STATUS field I want to add another column (Not Ordered) on the run using some conditions which is not in the flatfile. How can I do that?
    Please let me know if my post in unclear so that I can provide more data regarding the report.
    Thanks in advance for your time.

    Let me elaborate my requirement. I am trying to create a report using data from two flat files. I am supposed to give the status of orders. So I created crosstab query and I chose STATUS field data to be as columns. Currently it have three fields----Approved, In process, Waiting for approval. Now as per requirement I am supposed to include another column called Not applicable based on two fields Amount and Local/No local. Before this we used to create the same report uising excel and I used below formula:
    =IF(AND(Amount=0,B2="Non-Local"),"Not Applicable","Approved")
    But in BO if the above condition is False I want that particular record to fall under already existing "Approved" but it is creating another "Approved" status and it is not catagorizing Not applicable....I mean every record with amount =0 falls under new Approved status but not in Not applicable as expected. Hope you understand my issue.
    Am i doing anything wrong in creating formula?

  • Use for a Crosstab Query?

    I have a table with the following metric data in it.
    one entry for a metric, whether its integrity was checked and the date checked.
    I need a report that puts all monthly activity on a single line.
    Examples:
    Here's what the table looks like
    proj_name metric integrity_checked Date
    abc broke Y 01-Apr-08
    abc fixed Y 01-Apr-08
    abc trashed Y 01-Apr-08     
    abc broke Y 01-Mar-08
    abc fixed Y 01-Mar-08
    abc trashed Y 01-Mar-08
    xyz broke Y 01-Apr-08
    yxz fixed Y 01-Apr-08
    yxz trashed Y 01-Apr-08     
    yxz broke Y 01-Mar-08
    yxz fixed Y 01-Mar-08
    yxz trashed Y 01-Mar-08
    Report needs to look like this.
    Prog Metric Apr-08 Mar-08
    abc broke Y Y
    abc fixed Y Y
    abc trashed Y Y
    xyx broke Y Y
    xyz fixed Y Y
    xyz trashed Y Y
    Does this call for a crosstab-type query and if so
    how would I code it?
    I've done one crosstab query before but can't get this one to come out right.
    Thanks
    David

    See this link
    http://www.myoracleguide.com/s/Pivot_Tables.htm

  • Crosstab Query for Remaining Revenue (Count, If, Date Between )

    Hi all, hope you had a great new year.
    I am wanting to create a crosstab query for my Projects which shows ProjectID in the row headers and Time Periods split into months quarter or year as the Column Headers using the [DateAgreed] from the Session table. 
    I have created crosstabs which show revenue from sessions and count of sessions with different time periods but i am trying to make it so that it counts only completed sessions from before the column date, so that i can then multiply by the [SessionCost].
    Any ideas guys?
    Here's what i have been working with;
    TRANSFORM Sum(([tblSession]![SessionCompleted]*[tblProject]![SessionCost])) AS Revenue
    SELECT tblProject.ProjectID, tblCompany.CompanyName
    FROM (tblSession INNER JOIN tblCompany ON tblSession.CompanyID = tblCompany.CompanyID) INNER JOIN ((tblProject INNER JOIN tblProjectMetrics ON tblProject.ProjectID = tblProjectMetrics.ProjectID) INNER JOIN qryProjectStatus ON tblProject.ProjectID = qryProjectStatus.ProjectID)
    ON (tblProject.ProjectID = tblSession.ProjectID) AND (tblCompany.CompanyID = tblProject.CompanyID)
    GROUP BY tblProject.ProjectID, tblCompany.CompanyName, tblProject.Total
    PIVOT Format([DateAgreed],"yyyy-mm");
    Thanks :)

    Hi Gord0oo,
    You could concatenates the data as a result and show in a cell.
    TRANSFORM Sum([tblProject]![SessionCost])) & ";" & Sum([tblSession]![SessionCompleted]) AS Revenue
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • HELP! JSP as items in a region - is this possible?

    Hi All,
    Can someone please tell me how to bring in a JSP code as an item or portlet within a region. Is this possible with Oracle9iAS release 2? I need to generate dynamic html within a particular region based on a query string parameter and I thought this is one way of doing it.
    If anyone can help, that would be great!
    Thanks in advance,
    Kim

    Kim,
    There are many articles on Portal Center that discuss building portlets from JSPs. You can also post questions on this topic to the PDK forum.
    For PL/SQL, there are a number of options. You can build PL/SQL portlets - the dynamic page component is a good start, that is conceptually similar to JSPs.
    You can also create PL/SQL items that can be rendered in-place or displayed as a link - make sure that you don't use the "Simple PL/SQL" item type, as you can't control the rendering behaviour. Use the supplied "PL/SQL" item type, or create your own custom item type based on "Simple PL/SQL".
    Finally, any item type (except the "simple" ones) can be associated with a procedure that can generate dynamic content. The procedures can be PL/SQL or any function that can be invoked via a URL (e.g. a JSP or servlet).
    Note that in your PL/SQL procedures you'll need to use the HTP package to generate HTML.
    Regards,
    Jerry
    Portal PM

  • Data Entry - Crosstab Query

    Is it possible to do perform data entry in a crosstab query view?

    If you want to insert, update or delete in a view you need to write ON-INSERT, ON-UPDATE and/or ON-DELETE trigger and perform your DML inside these triggers ...
    Hope it helps
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JAMIE MCPHIE ([email protected]):
    Is it possible to do perform data entry in a crosstab query view?<HR></BLOCKQUOTE>
    null

  • Remome "Manual value entry" possibility in query filter

    Hi everybody, i'm currently using Bex ver 7.0 and i have a problem. I need to find a way to dissable the possibility to enter any value manually in a query's filter. For example, when i run a query and i see the filter, let's say "Coste Center" the filter variable gives me the range of values, but also it gives me the values that had been entered before "History" and below it gives me the possibility to enter the values manually. I need to dissable this option, it has to be just the filter with authorixed values to choose from, no "History data" nor this little window for manual antry.
    Do you happen to know if this possibility exist? 
    Thank you very much.
    P.D. the points will be awarded for all your ideas!!

    Hi,
    In the variable properties window, uncheck the "Ready for Input".
    It will solve the problem.
    Assign points if it helps.....

  • Crosstab Query?

    Is there Oracle Crosstab query like access?

    Hi,
    Shirani wrote:
    ... Any idea to diplay data in this format using ASP Classic Code.. but connectivity with Oracle DB?Sorry, I don't know anything about ASP.
    If the problem is that ASP needs to know how many columns the dynamic query will be returning, then perhaps you can do something on the ASP side like the preliminary query.
    Another approach would be not to return separate columns, but to concatenate the pivoted results into one huge VARCHAR2 column, with the columns delimied as in a csv file. This might be simpler on the Oracle side; you can do String Aggregation without dynamic SQL. Your ASP application could then parse the huge VARCHAR2 to get the individual parts.

  • I Need to Return Two values or more from Function, Is this possible?

    Below is the offending query, I am trying to pass v_bu and v_po to this function, and after validations then return v_count and v_action is this possible in a function? I am having problem returning two values.
    see below code
    function po_edi_func(v_bu purchase_order.business_unit_id%type,
         v_po purchase_order.purchase_order_number%type)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    return v_count;
    end;

    Paul,
    This is becoming a nightmare to me, can you look at the below and tell me where I am having a problem
    This is the Function below
    CREATE OR REPLACE function po_edi_func(v_bu sewn.purchase_order.business_unit_id%type,
         v_po sewn.purchase_order.purchase_order_number%type,v_action_out OUT VARCHAR2)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    v_action_out := (lpad(v_count,8,'0')||lpad(v_action,1,' '));
    return v_action_out;
    end;
    and this is how I am calling it from my trigger which has to pass the v_bu and v_po values to be used in extracting data and returning the records
    see below
    if po_edi_func(v_bu,v_po) <> '' then;
    v_count:= (substr(v_action,1,8));
    v_action := substr(v_actione,9,1);
    else
    v_count:=0;
    v_action := 'I';
    end if;
    I need the extracted values of v_count and v_action for my app to reset some values

Maybe you are looking for