Store a double into a variable of type int

if I have a calculated value of type "double", and I would like to store it as an "int" in a variable of type "int".
when i casted the double to int, seems it doesn't work.
what should the command be?
Thanks in advance!

post your expression. I'd bet you aren't casting the value of assignment but rather a component of some computation.
Something like this:
double dub = 2.4;
int returnvalue = (int)12/dub;as opposed to
double dub=2.4;
int returnvalue = (int)(12/dub);In the first entry, you would be casting 12 to an int and then dividing by a double and assigning the result to an int (returnvalue). Java will always try to expand precision to greatest common denominator, so the return value of the division will be a double (and hence the loss of precision assigning it to an int). The second entry properly casts the result of the whole expression as an int before assigning it to the int variable.

Similar Messages

  • Store multiple values into a variable

    I was wondering if it was possible to store multiple values into one varaible. Something along the lines of...
    Oracle: 10g
    --Table xSample (this is obviously a dumbed down version of the table for the sake of showing what I want to accomplish
    S_ID   YEAR
    1         2009
    2         2009
    3         2009
    4         2009
    --Query
    select     s_id
    into       pID
    from      xSample
    where    year = 2009;Basically the reason I was trying to figure out how to store multiple values into a variable is b/c I was going to use that variable (pID) as a parameter and have it's values passed dynamically when the proc was called. The values would go into a query that would look something like:
    select *
    from cust_data
    where person_id in (pID)
    aka
    select *
    from cust_data
    where person_id in (1,2,3,4)Not sure if this is possible, but if anyone knows of a way I could accomplish this that would be great.
    Edited by: user652714 on Dec 23, 2009 9:37 AM

    Here's a basic idea building a comma seperated list, then consuming it in another query (taking the in list approach from Tom's post, linked earlier).
    create table xsample (s_id number not null, year number);
    insert into xsample select level, 2009 from dual connect by level <=4;
    commit;
    declare
       --4000 should be lots ... hopefully?
       v_parameter_list varchar2(4000);
    begin
      --create the comma seperated list
      select
        substr(max(sys_connect_by_path(s_id, ',') ), 2, 4000)
      into
        v_parameter_list
      from
        select s_id, row_number() over(order by 1) as rn
        from xsample
        where year = 2009
      start with rn = 1
      connect by prior rn = rn - 1;
      --consume the comma seperated list
      for x in
        with data as
          select
            trim( substr (txt,
            instr (txt, ',', 1, level  ) + 1,
            instr (txt, ',', 1, level+1)
            - instr (txt, ',', 1, level) -1 ) ) as token
          from
            select ','||v_parameter_list||',' txt
            from dual
          connect by level <= length(v_parameter_list)-length(replace(v_parameter_list,',',''))+1
        select *
        from xsample
        where s_id in (select * from data) 
      loop
        dbms_output.put_line('next item = ' || x.s_id);
      end loop;
    end;
    /

  • Mapping proc output to vars gets error extracting result into a variable of type (DBTYPE_UI2)

    Hi, we run std 2012.  I have a proc (sets nocount on) whose params r shown in the first block .   My execute ssis sql task mapping is shown in the block following that (same order as shown, the param sizes are all -1).  The variable
    characteristics and initial values are shown in the 3rd block.  The execute sql task command is
    exec usp_fileArrivalStatus ?,?,?,?,?,? output,? output,? output
    when I run the proc in ssms followed by a select on the output fields, I get stat 0, instance id -1 and file name empty string (aka tick tick aka '')
    The error is:
    [Execute SQL Task] Error: Executing the query "exec usp_fileArrivalStatus ?,?,?,?,?,? output,? ou..." failed with the following error:
    "An error occurred while extracting the result into a variable of type (DBTYPE_UI2)".
    Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Does anybody know what is wrong?
    CREATE PROCEDURE [dbo].[usp_fileArrivalStatus] @NewFilePattern varchar(500),
    @PkgName varchar (257),
    @appid int,
    @MsgHistCreateDate date,
    @messageFriendlyName varchar(500),
    @arrivalStatus int output,
    @instanceId bigint output,
    @fileName varchar(500) output
    VariableName Direction DataType ParamName
    User::TranFilePattern Input VARCHAR 0
    System::PackageName Input VARCHAR 1
    User::AppID Input SHORT 2
    User::todaysDate Input DATE 3
    User::TranFileArriveStatus OUTPUT SHORT 5
    User::TranFileInstanceId OUTPUT LARGE_INTEGER 6
    User::TranFileName OUTPUT VARCHAR 7
    User::TranFileFriendlyName Input VARCHAR 4
    User::TranFilePattern,string,tranfile05-Nov-2014
    User::fileDate,string,05-Nov-2014
    System::PackageName,
    User::AppID,int32,12
    User::todaysDate,DateTime, set by select getdate()
    User::TranFileArriveStatus,int32,0
    User::TranFileInstanceId,Int64,0
    User::TranFileName,string
    User::TranFileFriendlyName,string,Tran File

    I may have gotten past this.  The ui showed the first execution of that proc as the aborting component but when I looked at my error code (-1073548784), and component name in the
    message sent with notification email, I noticed the second component name.  It too executes that proc and still had ushort for appid in sql task mapping and long for instance id.  I changed these characteristics to match what I posted and got green
    on the seq container that runs both.
    I think I go thru this kind of adventure every time I try to map proc output to ssis vars.   

  • Variable Data Type Error.

    I have a fast question. I am setting up a variable with a
    data type of Number, when I declare the variable it has a default
    value.
    I am trying to pass data to the variable from a input text
    box but I am getting an error when I run the Movie. I have tried
    both a input text box and a Dynamic Text box, but they both produce
    the same error.
    If I remove the data typing from the variable declaration the
    Movie runs and it updates the variable data but from all that I
    have read this is not a good practice.
    I have attached the code, could someone Please help me out. I
    do not remember having these types of problems with ActionScript 2.
    Thanks for the help.
    Code:
    var rectangle:Shape;
    var thick :Number = 2; // line thickness
    var color:Number= 0x000000; // Holds the color value
    myButton_btn.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
    color = colorField_txt.text; (Line 11)
    thick = lineThick_txt.text; (Line 12)
    rectangle = new Shape();
    rectangle.graphics.lineStyle(thick, color, .5);
    rectangle.graphics.drawRect(10, 10, 100, 150);
    addChild(rectangle);
    myButton_btn.buttonMode = true;
    ERROR MESSAGE:
    1067: Implicit coercion of a value of type String to an
    unrelated type Number. (Refers to line 11)
    1067: Implicit coercion of a value of type String to an
    unrelated type Number. (Refers to line 12)
    Thanks again for any help.
    Mike

    the text property of a textfield is of type String, so to
    place that String into a variable of type Number, you need to first
    convert it to a Number
    eg.
    thick = Number(lineThick_txt.text);
    ActionScript 2 performed this conversion
    automatically.

  • Replacing String month with type Int - What to do!?!

    import java.util.Scanner;
    public class Date
        private String month;
        private int day;
        private int year; //a four digit number.
        public Date( )
            month = "January";
            day = 1;
            year = 1000;
        public Date(int monthInt, int day, int year)
            setDate(monthInt, day, year);
        public Date(String monthString, int day, int year)
            setDate(monthString, day, year);
        public Date(int year)
            setDate(1, 1, year);
        public Date(Date aDate)
            if (aDate == null)//Not a real date.
                 System.out.println("Fatal Error.");
                 System.exit(0);
            month = aDate.month;
            day = aDate.day;
            year = aDate.year;
        public void setDate(int monthInt, int day, int year)
            if (dateOK(monthInt, day, year))
                this.month = monthString(monthInt);
                this.day = day;
                this.year = year;
            else
                System.out.println("Fatal Error");
                System.exit(0);
        public void setDate(String monthString, int day, int year)
            if (dateOK(monthString, day, year))
                this.month = monthString;
                this.day = day;
                this.year = year;
            else
                System.out.println("Fatal Error");
                System.exit(0);
        public void setDate(int year)
            setDate(1, 1, year);
        public void setYear(int year)
            if ( (year < 1000) || (year > 9999) )
                System.out.println("Fatal Error");
                System.exit(0);
            else
                this.year = year;
        public void setMonth(int monthNumber)
            if ((monthNumber <= 0) || (monthNumber > 12))
                System.out.println("Fatal Error");
                System.exit(0);
            else
                month = monthString(monthNumber);
        public void setDay(int day)
            if ((day <= 0) || (day > 31))
                System.out.println("Fatal Error");
                System.exit(0);
            else
                this.day = day;
        public int getMonth( )
            if (month.equals("January"))
                return 1;
            else if (month.equals("February"))
                return 2;
            else if (month.equalsIgnoreCase("March"))
                return 3;
            else if (month.equalsIgnoreCase("April"))
                return 4;
            else if (month.equalsIgnoreCase("May"))
                return 5;
            else if (month.equals("June"))
                return 6;
            else if (month.equalsIgnoreCase("July"))
                return 7;
            else if (month.equalsIgnoreCase("August"))
                return 8;
            else if (month.equalsIgnoreCase("September"))
                return 9;
            else if (month.equalsIgnoreCase("October"))
                return 10;
            else if (month.equals("November"))
                return 11;
            else if (month.equals("December"))
                return 12;
            else
                System.out.println("Fatal Error");
                System.exit(0);
                return 0; //Needed to keep the compiler happy
        public int getDay( )
            return day;
        public int getYear( )
            return year;
        public String toString( )
            return (month + " " + day + ", " + year);
        public boolean equals(Date otherDate)
            return ( (month.equals(otherDate.month))
                      && (day == otherDate.day) && (year == otherDate.year) );
        public boolean precedes(Date otherDate)
            return ( (year < otherDate.year) ||
               (year == otherDate.year && getMonth( ) < otherDate.getMonth( )) ||
               (year == otherDate.year && month.equals(otherDate.month)
                                             && day < otherDate.day) );
        public void readInput( )
            boolean tryAgain = true;
            Scanner keyboard = new Scanner(System.in);
            while (tryAgain)
                System.out.println("Enter month, day, and year.");
                  System.out.println("Do not use a comma.");
                String monthInput = keyboard.next( );
                int dayInput = keyboard.nextInt( );
                int yearInput = keyboard.nextInt( );
                if (dateOK(monthInput, dayInput, yearInput) )
                    setDate(monthInput, dayInput, yearInput);
                    tryAgain = false;
                else
                    System.out.println("Illegal date. Reenter input.");
        private boolean dateOK(int monthInt, int dayInt, int yearInt)
            return ( (monthInt >= 1) && (monthInt <= 12) &&
                     (dayInt >= 1) && (dayInt <= 31) &&
                     (yearInt >= 1000) && (yearInt <= 9999) );
        private boolean dateOK(String monthString, int dayInt, int yearInt)
            return ( monthOK(monthString) &&
                     (dayInt >= 1) && (dayInt <= 31) &&
                     (yearInt >= 1000) && (yearInt <= 9999) );
        private boolean monthOK(String month)
            return (month.equals("January") || month.equals("February") ||
                    month.equals("March") || month.equals("April") ||
                    month.equals("May") || month.equals("June") ||
                    month.equals("July") || month.equals("August") ||
                    month.equals("September") || month.equals("October") ||
                    month.equals("November") || month.equals("December") );
        private String monthString(int monthNumber)
            switch (monthNumber)
            case 1:
                return "January";
            case 2:
                return "February";
            case 3:
                return "March";
            case 4:
                return "April";
            case 5:
                return "May";
            case 6:
                return "June";
            case 7:
                return "July";
            case 8:
                return "August";
            case 9:
                return "September";
            case 10:
                return "October";
            case 11:
                return "November";
            case 12:
                return "December";
            default:
                System.out.println("Fatal Error");
                System.exit(0);
                return "Error"; //to keep the compiler happy
    }My question is that if I were to change the String month in the instance variables to type int, what changes do I make to the code to make this work WITHOUT changing the method headings and it also says that none of the type String paraenters should change to type int. I need to redefine the methods to make it work. I've been at this for hours and am just stuck so this is the reason for my early morning post.

    import java.util.Scanner;
    public class Date
        private int month;
        private int day;
        private int year; //a four digit number.
        public Date( )
            month = 1;
            day = 1;
            year = 1000;
        public Date(int monthInt, int day, int year)
            setDate(monthInt, day, year);
        public Date(String monthString, int day, int year)
            setDate(monthString, day, year);
        public Date(int year)
            setDate(1, 1, year);
        public Date(Date aDate)
            if (aDate == null)//Not a real date.
                 System.out.println("Fatal Error.");
                 System.exit(0);
            month = aDate.month;
            day = aDate.day;
            year = aDate.year;
        public void setDate(int monthInt, int day, int year)
            if (dateOK(monthInt, day, year))
                this.month = monthInt;
                this.day = day;
                this.year = year;
            else
                System.out.println("Fatal Error");
                System.exit(0);
        public void setDate(String monthString, int day, int year)
            if (dateOK(monthString, day, year))
                this.month = monthStringToInt(monthString);
                this.day = day;
                this.year = year;
            else
                System.out.println("Fatal Error");
                System.exit(0);
        public void setDate(int year)
            setDate(1, 1, year);
        public void setYear(int year)
            if ( (year < 1000) || (year > 9999) )
                System.out.println("Fatal Error");
                System.exit(0);
            else
                this.year = year;
        public void setMonth(int monthNumber)
            if ((monthNumber <= 0) || (monthNumber > 12))
                System.out.println("Fatal Error");
                System.exit(0);
            else
                month = monthNumber;
        public void setDay(int day)
            if ((day <= 0) || (day > 31))
                System.out.println("Fatal Error");
                System.exit(0);
            else
                this.day = day;
        public int getMonth( )
             return month;
        public int getDay( )
            return day;
        public int getYear( )
            return year;
        public String toString( )
            return (month + " " + day + ", " + year);
        public boolean equals(Date otherDate)
            return ( (month == otherDate.month)
                      && (day == otherDate.day) && (year == otherDate.year) );
        public boolean precedes(Date otherDate)
            return ( (year < otherDate.year) ||
               (year == otherDate.year && getMonth( ) < otherDate.getMonth( )) ||
               (year == otherDate.year && month == otherDate.month
                                             && day < otherDate.day) );
        public void readInput( )
            boolean tryAgain = true;
            Scanner keyboard = new Scanner(System.in);
            while (tryAgain)
                System.out.println("Enter month, day, and year.");
                  System.out.println("Do not use a comma.");
                String monthInput = keyboard.next( );
                int dayInput = keyboard.nextInt( );
                int yearInput = keyboard.nextInt( );
                if (dateOK(monthInput, dayInput, yearInput) )
                    setDate(monthInput, dayInput, yearInput);
                    tryAgain = false;
                else
                    System.out.println("Illegal date. Reenter input.");
        private boolean dateOK(int monthInt, int dayInt, int yearInt)
            return ( (monthInt >= 1) && (monthInt <= 12) &&
                     (dayInt >= 1) && (dayInt <= 31) &&
                     (yearInt >= 1000) && (yearInt <= 9999) );
        private boolean dateOK(String monthString, int dayInt, int yearInt)
            return ( monthOK(monthString) &&
                     (dayInt >= 1) && (dayInt <= 31) &&
                     (yearInt >= 1000) && (yearInt <= 9999) );
        private boolean monthOK(String month)
            return (month.equals("January") || month.equals("February") ||
                    month.equals("March") || month.equals("April") ||
                    month.equals("May") || month.equals("June") ||
                    month.equals("July") || month.equals("August") ||
                    month.equals("September") || month.equals("October") ||
                    month.equals("November") || month.equals("December") );
        private String monthString(int monthNumber)
            switch (monthNumber)
            case 1:
                return "January";
            case 2:
                return "February";
            case 3:
                return "March";
            case 4:
                return "April";
            case 5:
                return "May";
            case 6:
                return "June";
            case 7:
                return "July";
            case 8:
                return "August";
            case 9:
                return "September";
            case 10:
                return "October";
            case 11:
                return "November";
            case 12:
                return "December";
            default:
                System.out.println("Fatal Error");
                System.exit(0);
                return "Error"; //to keep the compiler happy
        private int monthStringToInt(String monthString) {
             if (monthString.equals("January")) return 1;
             else if (monthString.equals("February")) return 2;
             else if (monthString.equals("March")) return 3;
             else if (monthString.equals("April")) return 4;
             else if (monthString.equals("May")) return 5;
             else if (monthString.equals("June")) return 6;
             else if (monthString.equals("July")) return 7;
             else if (monthString.equals("August")) return 8;
             else if (monthString.equals("September")) return 9;
             else if (monthString.equals("October")) return 10;
             else if (monthString.equals("November")) return 11;
             else if (monthString.equals("December")) return 12;
             else return -1;
    }I've added one method: monthStringToInt to convert "January", "February" into an integer value. There are probably better ways to do this (Calendar), but this involes no other classes.

  • MDO Query errors in log -[Cannot fetch column 22, which has JDBC type DOUBLE, into a Java variable of type ]

    Hello,
    We are seeing a lot of log messages like the one below when an MDO select query is run. There is a message for every numeric column. There doesnt seem to be any issue with the queries working properly its just creating a lot of log messages. Has anyone else had this issue?
    Exception of type com.sap.sql.log.OpenSQLException caught:
    Cannot fetch column 22, which has JDBC type DOUBLE, into a Java variable of type
    float..
    [EXCEPTION]
    com.sap.sql.log.OpenSQLException: Cannot fetch
    column 22, which has JDBC type DOUBLE, into a Java variable of type float.
    at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:83) ...

    Hi Christian,
    You are right. As in your case it is a select query it does not reflect the error automatically. In my case, I had an insert query so it failed then and there, which was easier to debug and fix.
    I have one question regarding your case. When you read the MDO using the query, what do you do with the output? Do you assign it to any local/transaction property in the output links of the query block or in a proceeding assignment block?
    Because, the error mentions that the assignment of float to double datatype fails. So, in theory there should be some assignment done with the output.
    Please check if you could figure out this part in your transaction.
    Regards,
    Saumya Govil

  • Store results into a variable...

    How can I get a result I need into a variable, that I can use in a subsequent query.
    My initial thought was something like:
    select emp_id into MyVariable
    from emp where emp_NAME='Kevin';
    select * from emp
    where emp_id='&MyVariable';
    I'm doing this in TOAD, and I need to manually type the 'Kevin' once, and use the MyVariable in a series of queries; otherwise I would just use ACCEPT, and ask for the Name, and lookup the emp_id. But this is not what I need for this.
    I've tried OBG (Oracle By Google) which suggested something like:
    DECLARE
    MyVariable number;
    BEGIN
    select emp_id into MyVariable
    where emp_NAME='Kevin';
    dbms_output.put.line ('My Variable is ' || MyVariable);
    END
    But I'm getting and error on the dbms_output statement, and I can't seem to use the variable in a subsequet select statement!
    Appreciate any thoughts on this!

    I would advise putting the sql statements into a pl/sql block - then you could reuse the value
    declare
        v_my_var NUMBER;
    begin
        -- Get your value
        select ... into v_my_var from ... where name = 'Kevin' ...
        -- your first sql statement
        select  .... from .... where id = v_my_var;
        -- your second sql statement
        select .... from .... where id = v_my_var;
        etc.
    end;Toad does also provide for using the same value multiple times - for example, if you execute
    select &name from dual;   (any select statement)it will prompt you for a value for &name
    You can then have multiple statements after that in your sql tab
    select .... from .... where name = &nameand it will replace the &name with the value you previously entered. You need to use Editor -> Run as Script (F5) to run all the sql statements in your tab.
    Hope this helps.

  • Problem to store a oracle sql result into a variable

    Hello everyone,
    I'm working on a little project that use c#, Oracle ODT and asp.net, so here is the thing, I need to save the result of a sequence (SECNUM.NEXTVAL ) into a variable, then call that value from many inserts and querys and for last make the commit. My problem is that I don't know how to convert the string result to a number and the call it from the statements. Always brings two errors, one is invalid number because Im sending a string and the another is that if I comment the line cmd.ExecuteNonQuery(); the script runs but no commit happens.
    This is my code, is attached to a button:
    C# Syntax (Toggle Plain Text)
    string oradb = "Data Source=BBDD;User Id=DEMO;Password=DEMO;";
    string cmd1 = "SELECT SECNUM.NEXTVAL FROM DUAL";
    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();
    OracleParameter parm = new OracleParameter();
    parm.OracleDbType = OracleDbType.Decimal;
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.Parameters.Add(parm);
    cmd.CommandText = "INSERT INTO DEMOINCI (CODINCI, CODCLI) VALUES (('" + cmd1 +"'), 'TEST')";
    cmd.CommandText = "INSERT INTO DEMOINCILIN (CODINCI,CODLIN) VALUES (('" + cmd1 +"'),1)";
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();
    So my problem is that the column CODINCI is a column number of (9) and not a VARCHAR and can not be changed because is already have data, so when I use the code of the example, Oracle return an error saying Invalid number (of course).
    With the help of a friend I tried to put with the cast like this cmd.CommandText = "INSERT INTO DEMOINCI (CODINCI, CODCLI) VALUES (" + "CAST(" + cmd1 + "AS NUMBER), 'TEST')"; and it works but only if I comment the line cmd.ExecuteNonQuery();, so the commit never happend and of course there is no insert in the database.
    ¿It is so difficult to store a result of an SQL into a variable and then call it back on a statement?, on Oracle Forms you create a cursor like cursor=CVAL SELECT SECNUM.NEXTVAL VAL FROM DUAL and that it you can then use the VAL result into all other queries of the same form an retrieving with the :VAL option.
    Thanks for all the help.

    I just had to do something similar for my C# class, using SQL Server. The primary key for a "Customers" table was an auto-incrementing integer. After inserting a new customer I had to retrieve and display the primary key:
    string selectStatement = "SELECT IDENT_CURRENT('Customers') from Customers";
    SqlCommand selectCommand = new SqlCommand(selectStatement, connection);
    int customerID = Convert.ToInt32(selectCommand,ExecuteScalar());
    The ExecuteScalar() method of selectCommand returned the first column of the first row of the dataset, which in this case was the key of the new Customers record, as an object. Convert.ToInt32() converted the key to an integer.
    Once you store SECNUM.NEXTVAL as an integer, you can use it to create a Parameter for the Command object.
    HTH.

  • Store Column-Name into variable

    Hello from germany
    I got stuck with following:
    How is it possible to store the name of a column into a variable or is it possible to put an index "on" a column?
    The reason for this: I need to fill and check a complete column!
    Thanks for Your help!
    Best regards
    Marlon

    Those sure are unrelated questions. Lets say we have a table like this:
    SQL> CREATE TABLE t (
      2    a  number,
      3    b  varchar2(8),
      4    c  date );
    Table created.You can get a column name like this:
    SQL> set serveroutput on
    SQL> DECLARE
      2    second_col   VARCHAR2 (30);
      3  BEGIN
      4    SELECT column_name
      5      INTO second_col
      6      FROM user_tab_columns
      7     WHERE table_name = 'T'
      8       AND column_id = 2;
      9    DBMS_OUTPUT.PUT_line(second_col);
    10  END;
    11  /
    B
    PL/SQL procedure successfully completed.
    SQL> You can put an index on a column like this:
    SQL> CREATE INDEX t_n1 ON t(b);
    Index created.And you can add data to the table like this:
    SQL> insert into t(a, b) values (4, 'asdf');
    1 row created.
    SQL> select * from t;
             A B        C
             4 asdf
    SQL>

  • Store current Order from ShoppingCart.current into a variable..?

    Hi All,
    how to get current Order from /atg/commerce/ShoppingCart.current into a variable in ShoppingCart.jsp and use it in the Page instead of using ShoppingCart.current every time.
    Thanks,
    Vishnu

    Try this:
    <dsp:param name="order" bean="ShoppingCart.current"/>
    ${orde}
    or
    <dsp:getvalueof var="order" bean="ShoppingCart.current" vartype="atg.commerce.order">
    <body bgcolor="${order}" >
    </dsp:getvalueof>
    Peace
    Shaik

  • Fetches more values into one variable

    Hi, inside a cursor loop I'd like to assign, each fetch, a value to a variable, in order, at the end to have a collection of all the values fetched into the same variable.
    The code is the following:
    CREATE OR REPLACE procedure APPS.AAA as
    v_pino varchar2(64);
    CURSOR tks_opened_range IS
    SELECT incident_number AS YP_TKS_OPENED_WITHIN_RANGE FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) BETWEEN 1 AND 11111111111
    AND incident_attribute_2 IN ('ΓΕΝΙΚΗ ΔΙΕΥΘΥΝΣΗ ΤΕΧΝΟΛΟΓΙΑΣ')
    ORDER BY incident_number;
    rec_tks_opened_range tks_opened_range%ROWTYPE;
    begin
    FOR rec_tks_opened_range IN tks_opened_range
    LOOP
    v_pino := rec_tks_opened_range.YP_TKS_OPENED_WITHIN_RANGE;
    DBMS_OUTPUT.PUT_LINE('v_pino: ' || v_pino);
    end loop;
    end AAA;
    This works with the variable v_pino!....but at the end, the value of the variable v_pino is ONLY the last fetched by the cursor.
    Is there a way to declare a variable (or better a collection) or a new type in order to have all the data fetched into this variable and the end of the fetching ?
    I need to know this trick because, after, I have to assign this variable to a pipelined table function.
    Thanks in advance
    Alex
    /

    Great Devang !! Thanks a lot ! It works ! Now I am able to retrieve all the values I need and store them into my variable gino
    I searched on the note you mentioned in your mail in order to pass an array as a variable to a table function (PIPE ROW call), but I didn't find nothing about it.
    Now I explain to you my situation.
    I already implemented a table function that works perfectly. I have 2 cursors declared and 2 PIPE ROW calls.
    FUNCTION statistic_report_2_1 (p_resolv_time_ll varchar2, p_resolv_time_ul varchar2, p_ypiresia varchar2)
    RETURN xxi_statistic_rep_2_1_tab PIPELINED
    IS
    -- CURSORS FOR THE FIRST SHEET - Tickets opened per group and per duration
    -- Cursor for tickets opened within 1 hour --
    CURSOR tks_opened_1_h IS
    SELECT incident_number AS YP_TKS_OPENED_WITHIN_1_HOUR
    FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) < 60
    AND incident_attribute_2 IN (SELECT * FROM TABLE(CAST(xxi_szf_discoverer.ypiresia_values(p_ypiresia) AS xxi_ypiresia_list_tab)))
    ORDER BY incident_number;
    rec_tks_opened_1_h tks_opened_1_h%ROWTYPE;
    -- Cursor for tickets opened between 1 hour and 3 hours --
    CURSOR tks_opened_1_3_h IS
    SELECT incident_number AS YP_TKS_OPENED_BE_1_3_HOURS FROM cs.cs_incidents_all_b a, cs_incident_statuses_b b, Cs_Incident_Statuses_Tl c
    WHERE b.incident_status_id = c.incident_status_id
    AND a.incident_status_id = b.incident_status_id
    AND (b.attribute1 <> '3' OR b.attribute1 IS NULL)
    AND c.language = 'EL'
    AND ((sysdate - to_date(incident_attribute_6, 'dd-mm-yyyy hh24:mi'))*1440) BETWEEN 60 AND 179
    AND incident_attribute_2 IN (SELECT * FROM TABLE(CAST(xxi_szf_discoverer.ypiresia_values(p_ypiresia) AS xxi_ypiresia_list_tab)))
    ORDER BY incident_number;
    rec_tks_opened_1_3_h tks_opened_1_3_h%ROWTYPE;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    -- FIRST SHEET OPEN CURSORS --
    TICKETS NUMBER OPENED WITHIN 1 HOUR
    FOR rec_tks_opened_1_h IN tks_opened_1_h
    LOOP
    PIPE ROW(stat_rep_2_1_type(
    rec_tks_opened_1_h.YP_TKS_OPENED_WITHIN_1_HOUR
    END LOOP;
    -- TICKETS NUMBER OPENED BETWEEN 1 HOUR AND 3 HOURS --
    FOR rec_tks_opened_1_3_h IN tks_opened_1_3_h
    LOOP
    PIPE ROW(stat_rep_2_1_type(
    ,rec_tks_opened_1_3_h.YP_TKS_OPENED_BE_1_3_HOURS));
    END LOOP;
    RETURN;
    END statistic_report_2_1;
    But, in this way and with this syntax, I obtain for each PIPE ROW call only one field filled each time, because I can’t call 2 cursors in a nested loop together (data duplication);
    For example:
    1st PIPE ROW call : only the first field is filled and into the second I have to put ‘’
    2nd PIPE ROW call : only the second field is filled and into the first I have to put ‘’
    ….and I cant’ call with a single PIPE ROW call two cursor variables…..
    Into a Discoverer report this data layout is really bad (you can imagine with thousand
    of records).
    For this reason I thought to use an array variable (gino) to pass to a single PIPE ROW call outside the cursor loop……but it doesn’t work !!!
    Can you suggest me how to resolve this problem….if it possible ?
    Did I have to declare other TYPE or collection ?
    Thanks you so much
    Alex

  • BPS Variables of Type Exit (How To Document)

    Hello,
    I'm trying to restrict entries for (say) variable #2, based on the selection of variable #1. 
    I've just realised characteristic relationships cannot be used and need to use a user exit.  I've gone through the "How To" on BPS Variables of Type Exit and have gotten the function modules to working properly. 
    However when the function module attempts to pass the data to BPS Variable #2, BPS gives an ERROR saying that in order to write new values into variable #2, the variable must have a replacement path "USER DEFINED VALUES".
    However this is not possible as the replacement path must be set to "USER EXIT" so the function module can be activated.
    The only way around this is to tell the function module which BPS Variable it should choose to write the data to, if so does anyone the ABAP to store values into a BPS Variable.
    Right now would appreciate any comment on this.
    Kind regards,
    Marinos

    Hi Marc,
    Yes, the How To paper answers my problem, and when I run the program via se37 the correct variable selections are being populated in table ETO_CHARSEL.  However when values are passed to the BPS Variable, the first information message read "The Conditions were Adapted"  but no values are passed to the variable.  Then a second error message "Entry not possible, var does not have replacement type user-spec vals."  This seems to be a conundrum as the variable needs to be set as user-exit.
    Any thoughts?
    Marinos
    My Z_SIMPLE_RELATION code is
    FUNCTION Z_SIMPLE_RELATION.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(I_AREA) TYPE  UPC_Y_AREA
    *"     VALUE(I_VARIABLE) TYPE  UPC_Y_VARIABLE
    *"     VALUE(I_CHANM) TYPE  UPC_Y_CHANM
    *"     VALUE(ITO_CHANM) TYPE  UPC_YTO_CHA
    *"  EXPORTING
    *"     VALUE(ETO_CHARSEL) TYPE  UPC_YTO_CHARSEL
    Change constant according to your needs
    TABLES: /BIC/MTASSTCAT.
    CONSTANTS:
    l_source_var TYPE upc_y_variable VALUE 'TCAPASST',
    l_source_area TYPE upc_y_area VALUE 'TCAP001P',
    l_use_restricted_values TYPE boole-boole VALUE 'X',
    l_buffer_call TYPE boole-boole VALUE 'X'.
    DATA:
    l_subrc LIKE sy-subrc,
    ls_return LIKE bapiret2,
    l_type LIKE upc_var-vartype,
    lto_varsel_all TYPE upc_yto_charsel,
    lto_varsel TYPE upc_yto_charsel,
    lto_var TYPE upc_yto_charsel,
    lt_chavl TYPE /bic/PTASSTCAT occurs 0,
    ls_chavl like line of lt_chavl,
    lto_chanm type upc_yto_cha.
    read source value
    CALL FUNCTION 'Z_VARIABLE_GET_DETAIL'
    EXPORTING
    i_area = l_source_area
    i_variable = l_source_var
    i_buffer = l_buffer_call
    IMPORTING
    e_subrc = l_subrc
    es_return = ls_return
    e_type = l_type
    eto_varsel_all = lto_varsel_all
    eto_varsel = lto_varsel
    eto_chanm = lto_chanm.
    IF l_subrc <> 0.
    MESSAGE i136(upc_fw) WITH l_source_var.
    Values of variable &1 cannot be determined
    EXIT.
    ENDIF.
    now, you are free to determine the logic on how to
    derive the values based on the source values.
    Example 1: determine the next year
    Assumptions:
    - we have only a single year in the selection
    - the variable is of type characteristic
    DATA: ls_varsel TYPE upc_ys_charsel,
    l_next_year(4) TYPE n,
    l_entries TYPE i.
    We have a single value for the year and only one characteristic
    => our value is stored in the first line
    IF l_use_restricted_values IS INITIAL.
    lto_var = lto_varsel_all.
    ELSE.
    lto_var = lto_varsel.
    ENDIF.
    READ TABLE lto_var INTO ls_varsel INDEX 1.
    check prerequisites:
    - record found?
    IF sy-subrc <> 0.
    MESSAGE i147(upc_fw) WITH l_source_var.
    Variable &1 does not contain any values
    EXIT.
    ENDIF.
    - exactly one record and characteristic?
    DESCRIBE TABLE lto_var LINES l_entries.
    IF l_entries <> 1.
    MESSAGE i534(upc) WITH l_source_var.
    Variable &1 must be restricted to a value
    EXIT.
    ENDIF.
    SELECT * FROM /BIC/PTASSTCAT INTO TABLE lt_chavl
      WHERE asset_clas = ls_varsel-low.
      if sy-subrc <> 0.
        MESSAGE e026(upc) WITH ls_varsel-low '0ASSET_CLAS'.
    Attribute value not found
      exit.
    endif.
    ls_varsel-seqno = '0000'.
    ls_varsel-chanm = '/BIC/TASSTCAT'.
    LOOP AT lt_chavl INTO ls_chavl.
    ls_varsel-seqno = ls_varsel-seqno + 1.
    ls_varsel-low = ls_chavl-/BIC/TASSTCAT.
    APPEND ls_varsel TO eto_charsel.
    ENDLOOP.
    ENDFUNCTION.

  • Error message into a Variable.

    Dear users,
    I have a rather usual (unusual from the weekend beers for me though!!) query which I can't figure out a proper way to implement.
    My requirement is like this:
    I have a message class in which I want to define a text 'Employee number & not found'.
    I want to use this in the program, but not to raise this error. Instead, I want to move this error message with the Employee number into a Character(200) variable.
    So instead of using MESSAGE e0xx(messageclass) USING employee number, I would like to move the error text into a variable which looks like:
    lv_text = e0xx(messageclass) USING '1234'   which stores the text 'Employee number 1234 not found' in lv_text.
    How would I acheive it??
    Thanks, V!

    Try tis way
    message e999(00) with i_emp-empno into lv_text.
    press f1 in message will provide you more details

  • How to take data from HTML Template into BSP Variable?

    hi all,
                can we take the data from the input field of HTML Template and collect into BSP variable? i have the shown the HTML Template into BSP page by passing the url in <IFRAME> tag now i have to take the data form the into field of HTML Template and save it back to the BSP table onclicking the Save button of BSP Page. please help me out thanks in advance.
    Thanks & Regards,
    Amol

    Hi Amol,
    This is very simple....
    In the onInputProcessing event of the page use the following code to read data from the InputField into an ABAP variable...
    Then you can use it at will..!
    Code is :
    data : event       TYPE REF TO if_htmlb_data,
           but_event   TYPE REF TO cl_htmlb_event_button.
    event = cl_htmlb_manager=>get_event( request ).
    IF event->EVENT_NAME = 'button' and event->EVENT_TYPE = 'click'.
          but_event ?= event.
          CASE event->EVENT_ID.
            when 'your_button_id'.
              data : lw_inf type ref to cl_htmlb_inputfield.
                 lw_inf ?= cl_htmlb_manager=>get_data(
                                request = runtime->server->request
                                name    = 'inputField'
                                id      = 'your_inputField_id'  ).
              if lw_inf->value is not initial.
                lw_variable = lw_inf->value.
              endif.
         ENDCASE.
    ENDIF.

  • How I can transfer data from the database into a variable (or array)?

    I made my application according to the example (http://corlan.org/2009/06/12/working-in-flash-builder-4-with-flex-and-php/). Everything works fine. I changed one function to query the database - add the two parameters and get the value of the table in String format. A test operation shows that all is ok. If I want to display this value in the text area, I simply drag and drop service to this element in the design mode
    (<s:TextArea x="153" y="435" id="nameText" text="{getDataMeanResult.lastResult[0].name}"  width="296" height="89"  />).
    It also works fine, just a warning and encouraged to use ArrayCollection.getItemAt().
    Now I want to send the value to a variable or array, but in both cases I get an error: TypeError: Error #1010: A term is undefined and has no properties..
    How can I pass a value from the database into a variable? Thank you.
    public var nameTemp:String;
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[0], dir_id);
    nameTemp = getDataMeanResult.lastResult[0].name;
    public var nameArray:Array = new Array();
    for (var i:uint=o; i<3; i++){
    getDataMeanResult.token = authors.getDataMean(arrayOfNumber[i], dir_id);
    nameArray[i] = getDataMeanResult.lastResult[0].name;
    And how i can use syntax highlighting in this forum?

    Astraport2012 wrote:
    I have to go back to the discussion. The above example works fine when i want to get a single value of the database. But i need to pass an array and get an array, because i want to get at once all the values for all pictures tooltips. I rewrote the proposed Matt PHP-script and it works. However, i can not display the resulting array.
    yep, it won't work for Arrays, you'll have to do something slightly more intelligent for them.
    easiest way would be to get your PHP to generate XML, then read that into something like an ArrayList on your HTTPService result event (depends what you're doing with it).
    for example, you could have the PHP generate XML such as:
    <pictures>
         <location>test1.png</location>
         <location>test2.png</location>
         <location>test3.png</location>
         <location>test4.png</location>
         <location>test5.png</location>
         <location>test6.png</location>
    </pictures>
    then you'll read that in as the ResultEvent, and perform something like this on it
    private var tempAC:ArrayList = new ArrayList
    protected function getStuff_resultHandler(event:ResultEvent):void
        for each(var item:Object in event.result.pictures)
           var temp:String = (item.@location).toString();
           tempAC.addItem(temp);
    in my example on cookies
    http://www.mattlefevre.com/viewExample.php?tut=flash4PHP&proj=Using%20Cookies
    you'll see an example of how to format an XML structure containing multiple values:
    if($_COOKIE["firstName"])
            print "<stored>true</stored>";
            print "<userInfo>
                    <firstName>".$_COOKIE["firstName"]."</firstName>
                    <lastName>".$_COOKIE["lastName"]."</lastName>
                    <userAge>".$_COOKIE["userAge"]."</userAge>
                    <gender>".$_COOKIE["gender"]."</gender>
                   </userInfo>";
        else
            print "<stored>false</stored>";
    which i handle like so
    if(event.result.stored == true)
                        entryPanel.title = "Welcome back " + event.result.userInfo.firstName + " " + event.result.userInfo.lastName;
                        firstName.text = event.result.userInfo.firstName;
                        lastName.text = event.result.userInfo.lastName;
                        userAge.value = event.result.userInfo.userAge;
                        userGender.selectedIndex = event.result.userInfo.gender;
    depends on what type of Array you're after
    from the sounds of it (with the mention of picture tooltips) you're trying to create a gallery with an image, and a tooltip.
    so i'd probably adopt something like
    <picture>
         <location>example1.png</location>
         <tooltip>tooltip for picture #1</tooltip>
    </picture>
    <picture>
         <location>example2.png</location>
         <tooltip>tooltip for picture #2</tooltip>
    </picture>
    <picture>
         <location>example3.png</location>
         <tooltip>tooltip for picture #3</tooltip>
    </picture>
    etc...
    or
    <picture location="example1.png" tooltip="tooltip for picture #1"/>
    <picture location="example2.png" tooltip="tooltip for picture #2"/>
    <picture location="example3.png" tooltip="tooltip for picture #3"/>
    etc...

Maybe you are looking for