Incorrect column names returned using OCIDescribeAny

I am trying to retrieve column names using OCIDescribeAny and OCIAttrGet api calls.
The column names and the lengths of the column names returned by OCIAttrGet calls are usually correct.
Except when the length of column names are divisible by 4, an extra tab is padded at the end of the returned string by OCIAttrGet.
The length returned by the call is fine.
Example 1.
Column Name:
CITY
Results Returned by OCIAttrGet:
column name: CITY\t
column length: 4
Example 2.
Column Name:
PHONE_NUMBER
Results Returned by OCIAttrGet:
column name: PHONE_NUMBER\t
column length: 12
Does anyone has experience with this?
Edited by: simon780 on Mar 13, 2010 2:48 PM
Edited by: simon780 on Mar 13, 2010 4:03 PM

Thank you for answering my question, I thought I was doing something wrong, since this is my very first time using oci.
I do see non-null terminated strings mentioned from places to places on the oracle docs, but I don't see it mentioned specifically on the attribute OCI_ATTR_NAME.
Anyway, as long as I have the string length returned by the function call, then it's all good. Thank you again!!

Similar Messages

  • What is the column name when use select ... from table(my_table)

    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;

    Chris wrote:
    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;
    I have some code that takes a csv and loads it into a type table.Why a type table? Where is type table defined as such?
    with PL/SQL, objects must be declared before they can be referenced.
    You need to correct syntax errors before tackling any runtime/logic flaws.

  • Using Column Name returned by function in SELECT statement

    Hi
    Output from my function (RETURN data type is VARCHAR2) is column name. I want to use it directly in my SELECT statement. Below is simplified example of this:
    --- Function
    CREATE OR REPLACE FUNCTION simple RETURN varchar2 IS
    BEGIN
    RETURN ‘my_column’;
    END simple;
    --- Select
    SELECT simple FROM my_table;
    This does not work. It seems that output from function is passed in quotation i.e.
    SELECT ‘my_column’ FROM my_table;
    So the output from SELECT is a list of rows populated with values my_table:
    COLUMN     simple
    ROW1     my_column
    ROW2     my_column
    ROW3     my_column
    Can please someone help me with this?

    I'm not sure I got you right.
    In standard SQL everything must be known at compile time. If not dynamic SQL is required, but is a costly operation (usually requires parsing before each execution) so it should better not be used when standard SQL can do it.
    I provided a design time example where a function returns the column name from the given the table name and column id for a varchar2 column data type to make things simple. Then a query string is constructed and executed dynymically to return all column values of the chosen table_name.column_name.
    SELECT simple FROM my_tableAt compile time the simple function return value is unknown (any varchar2 value would do) you already find out you get the (same) return value (i.e column name) for each table row => dynamic SQL needed to get the column values
    The purpose of function would be to rename all columns for provided table.The table name would be provided, right? If yes => dynamic SQL
    What is the function supposed to return the column name (where would the new name come from?), the column alias (which table column would be renamed to the new name?)
    The user could use the new_column name as the column alias name submitting the query.
    Is it possible to do this?Maybe () using a pipelined function (different data types - number,date, ... not cosidered yet) but your simple query;
    <tt>SELECT simple FROM my_table</tt>
    might look like:
    <tt>select my_column_value new_column_name from table(get_column_value(table_name,column_name))</tt>
    Sorry, no Database at hand to provide a specific example.
    Regards
    Etbin

  • Query to Find Table and Column Name by using a value

    Dear Legends,
    I hope and surfed in our forums and google to find the Table Name and Column Name by having a value(Number/String). And my where clauses are
    where owner NOT IN ('SYS','SYSTEM') and
          data_type IN ('CHAR','VARCHAR2','NUMBER')
    May I have your help for building the query. and my query as follows
    select a.owner, c.column_name, c.data_type, c.owner, c.table_name
    from dba_objects a, all_tab_cols c
    where a.owner NOT IN ('SYS','SYSTEM') and
    where c.owner NOT IN ('SYS','SYSTEM') and
    where c.data_type IN ('CHAR','VARCHAR2')
    order by a.owner
    Thanks,
    Karthik

    You can use
    select * from user_tab_columns a, user_tables b
    where a.table_name = b.table_name
    and  a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR');
    Or if you want to user DBA_* tables, you can use.
    select * from dba_tab_columns a, dba_tables b
    where a.table_name = b.table_name
    and a.owner = b.owner
    and  a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR')
    and b.owner not in ('SYS', 'SYSTEM');
    And now when I look a bit more closely, you don't need DBA_TABLES there. dba_tab_columns alone is sufficient. And requirement is still not clear yet. Why you need a group by there? If I get it right, you can use this.
    select * from dba_tab_columns a
    where a.data_type in ('NUMBER', 'VARCHAR2', 'NCHAR', 'CHAR')
    and a.owner not in ('SYS', 'SYSTEM');
    Whether you use group by or not, the query will give you the same output.
    Ishan

  • UD Datasource Proposal Tab Shows Incorrect Column Names

    I created a UD datasource in BW and the "Proposal" tab showed me the correct column names for the table I had selected.  A couple of column names were then changed for this table in the source system but they are not showing up in the "Proposal" tab (the old column names are still there).  I refreshed and reactivated the source system in BW but it didn't work.  Any ideas on how to get the new column names to show up in the "Proposal" tab?  Thanks for any help on this.

    hi,
    check with the following steps you carried out in the ud data source creation.
    You are in the DataSource tree in the Data Warehousing Workbench.
           1.      Select the application components in which the DataSource is to be created and choose Create DataSource.
           2.      In the next screen, enter a technical name for the DataSource, select the type of the DataSource and choose Copy.
    The DataSource maintenance screen appears.
           3.      Go to the General tab page.
                                a.      Enter descriptions for the DataSource (short, medium, long).
                                b.      If necessary, specify if the DataSource builds an initial non-cumulative and supplies potentially duplicate data records within a request.
           4.      Go to the Extraction tab page.
                                a.      Define the delta method for the DataSource.
                                b.      Specify whether you want the DataSource to support direct access to data.
                                c.      UD Connect does not support real-time data acquisition.
                                d.      The system displays Universal Data Connect (Binary Transfer) as the adapter for the DataSource.
    Choose Properties if you want to display the general adapter properties.
                                e.      Select the UD Connect source object.
    The connection to the UD Connect source is established. All source objects that are available in the selected UD Connect source can be selected using input help. Source objects can be multi-dimensional storage or relational objects.
           5.      Go to the Proposal tab page.
    The system displays the elements of the source object (for JDBC for example fields, or for XMLA and ODBO characteristics and key figures) and creates a mapping proposal for DataSource fields. The mapping proposal is based on the similarity of the names of the source object element and DataSource field and the compatibility of the respective data types.
    Note that source object elements can have a maximum of 90 characters. Both upper and lower case are supported.
                                a.      Check the mapping and change the proposed mapping as required. Assign the non-assigned source object elements to free DataSource fields.
    You cannot map elements to fields if the types are incompatible. The system produces an error message in this case.
                                b.      Under Copy to Field List, select the fields that you want to transfer to the field list for the DataSource. All fields are selected by default.
           6.      Maintain the Fields tab page.
    Here you edit the fields that you transferred to the field list of the DataSource from the Proposal tab page.
                                a.      Under Transfer, specify the decision-relevant DataSource fields that should be available for extraction and transferred to BI.
                                b.      If required, change the values for the key fields of the source.
    These fields are generated as a secondary index in the PSA. This is important in ensuring good performance for data transfer process selections, in particular with semantic grouping.
                                c.      If required, change the data type for a field.
                                d.      Specify whether the source provides the data in the internal or external format.
                                e.      If you choose an External Format, ensure that the output length of the field (external length) is correct. Change the entries, as required.
                                  f.      If required, specify a conversion routine that converts data from an external format into an internal format.
                                g.      Select the fields for which you want to be able to set selection criteria when you schedule a data request using an InfoPackage. Data for this type of field is transferred in accordance with the selection criteria specified in the InfoPackage.
                                h.      Choose the selection options (such as EQ, BT) that you want to be available for selection in the InfoPackage.
                                  i.      Under Field Type, specify whether the data to be selected is language-dependent or time-dependent, as required.
    Note
    If you did not transfer the field list from a proposal, you can define the fields of the DataSource directly. Choose Insert Row and enter a field name. You can specify InfoObjects in order to define the DataSource fields. Under Template InfoObject, specify InfoObjects for the fields of the DataSource. This allows you to transfer the technical properties of the InfoObjects into the DataSource field.
    Entering InfoObjects here does not equate to assigning them to DataSource fields.  Assignments are made in the transformation. When you define the transformation, the system proposes the InfoObjects you entered here as InfoObjects that you might want to assign to a field.
           7.      Check, save and activate the DataSource.
           8.      Go to the Preview tab page.
    If you select Read Preview Data, the number of data records you specified in your field selection is displayed in a preview.
    This function allows you to check whether the data formats and data are correct.
    Result
    The DataSource is created and added to the DataSource overview for the UD Connect source system in the application component in the Data Warehousing Workbench. When you activate the DataSource, the system generates a PSA table and a transfer program.
    You can now create an InfoPackage. You define the selections for the data request in the InfoPackage. The data can be loaded into the entry layer of the BI system, the PSA. Alternatively you can access the data directly if the DataSource allows direct access and you have a VirtualProvider in the definition of the data flow.
    http://help.sap.com/saphelp_nw70/helpdata/en/bc/ed1640b7b6dd5fe10000000a155106/frameset.htm
    hope this give you an idea
    regards
    harikrishna N

  • How to retrieve DB links and column names details used in code

    Hi All,
    I am looking for code that will retrieve database links name, referenced object and column names used in source code within the schema.
    It’s easy enough to find the link names using xxx_db_links / user_source, the trick part it to list the column names used within the code.
    Any expert advice is much appreciate
    Thanks
    Aali

    That wil not give me column names .
    Thanks
    Message was edited by:
    aalishan

  • Invalid column name - fixed by inserting a carriage return - Why?

    I'm writing some JSP pages and am executing a statement that retrieves values from three tables.
    When executing the statement I receive the error
    java.sql.SQLException: Invalid column name
    I just want to state here that ALL the column names are definitely correct. I attempted to isolate the problem using my SQL*Plus Interface.
    When copying and pasting the SQL that was used (I put the SQL statement into the HTML to allow me to do this) into SQL*Plus it also come up with the error. I found that if I broke up the statement it would run. Specifically if I placed a carriage return (by hitting enter) prior to the 'A' of the AND operator and then copied and pasted into SQL*Plus it would work!
    I thought the problem was related to bad syntax in the outer join operator. But removal of the outer join operator and making it a EQUI JOIN situation still gave the same results. I tried the use of brackets to 'help' the DB engine figure it out - silly I know, but it didn't work anyway :(
    I've tried this out on UNIX in SQL*Plus where the query was on one line and it worked fine. I've tried it on Oracle 8.1.5 SQL*Plus & Oracle 8.1.7 SQL*Plus on Win2000 and WinNT and no go.
    It has also been tested on an Oracle 7.3.4 DB and no go either.
    Remember I'm only using SQL*Plus to find out why it is not working - I'm actually attempting to execute this via JDBC (classes12.zip Oracle9 version) in my JavaBean. I can't place a carriage return to 'fix' the problem, and I'm assuming that I shouldn't either.
    I've pasted the SQL below (both non-working and working versions). I was going to paste the output of DESC on the associated tables should you too would rule out a mispelled column name, but I didn't want to put anyone off with a long post.
    If you can provide any advice I would be very appreciative.
    Darren James
    Show Me Technology
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS
    .Novell_User_Name = PERSON.Novell_User_Name (+) ORDER BY Make,
    Model, Asset_Number,Serial_Number,
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_Name;
    3 /
    WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+) AND UNIT_USERS.Novel
    ERROR at line 2:
    ORA-00904: invalid column name
    REM -- Using the one with an return prior to the AND
    SQL> SELECT UNIT.Asset_Number,Model,PERSON.Novell_User_Name FROM
    UNIT, UNIT_USERS, PERSON
    2 WHERE UNIT.Hardware_Reference_Number =
    UNIT_USERS.Hardware_Reference_Number(+)
    3 AND UNIT_USERS.Novell_User_Name = PERSON.Novell_User_Name
    (+) ORDER BY Make, Model,
    4 Asset_Number,Serial_Number,
    5
    UNIT.Hardware_Reference_Number,Unit_Type,PERSON.Last_Name,PERSON.Fi
    rst_Name,PERSON.Novell_User_
    Name;
    ASSET_NUMBER
    MODEL
    NOVELL_USE
    10023445
    desktop raider
    tabisho
    10023445
    desktop raider
    pjblee
    100349864
    VEi8
    SQL>

    Ok. I feel ashamed that the answer was so simple and not the
    problem I thought it was. But in the interests of perhaps
    preventing someone else doing the same silly thing....
    The error was caused by using a wrong name when 'getting' the
    values int the return ResultSet object. (eg using getString
    ("s.Some_Name") when it should have been getString
    ("s.Another_Name").
    Interestingly the error did occur in one of our SQL*Plus
    versions. Why we still are not sure, but since this was a silly
    error on my part, I'm sure a similarly silly reason will be the
    cause there two.
    I appreciate those who responded though. It is a great resource.
    Darren James
    I'm just guessing here, but could it be some sort of a size thing? Could it be that, if you don't break up line 2, somehow
    it gets truncated or wrapped at an inappropriate place? To test
    this theory, you might try putting the carriage return in front
    of the ORDER BY, instead of in front of the AND, and see if it
    has the same effect. If you do get it figured out, please
    satisfy our curiosity and let us know.

  • Passing parameters to table valued functions and using parameters as column name on select

    I am creating a function where I want to pass it parameters and then use those parameters in a select statement. When I do that it selects the variable name as a literal not a column. How do I switch that context.
    Query:
    ALTER FUNCTION [dbo].[ufn_Banner_Orion_Employee_Comparison_parser_v2]
    @BANNER_COLUMN AS VARCHAR(MAX),
    @ORION_COLUMN AS VARCHAR(MAX)
    RETURNS @Banner_Orion_Employee_Comparison TABLE 
    LAST_NAME nvarchar(max),
    EMPNO int,
    BannerColumnName nvarchar(max),
    BANNER nvarchar(max),
    ORION nvarchar(max)
    AS
    BEGIN
    INSERT INTO @Banner_Orion_Employee_Comparison
    (LAST_NAME, BANNER, ORION)
    SELECT
    a.LAST_NAME, @BANNER_COLUMN, @ORION_COLUMN
    FROM OPENQUERY(ORCLPROD_APDORACLE, 'select LAST_NAME, BANNER_RANK, BADGE, EMP_STATUS from XTRACT_VIEW') AS a
    inner join IWM_Stage.dbo.ViewPersonnel AS b
    on a.BADGE = b.badge
    WHERE a.EMP_STATUS = 'A'
    and a.BANNER_RANK <> b.[rank]
    RETURN;
    END;
    GO
    Output
    I execute this:
    select * from ufn_Banner_Orion_Employee_Comparison_parser_v2 ('a.BANNER_RANK' , 'b.[rank]')
    and get:
    Cerecerez NULL
    NULL a.BANNER_RANK
    b.[rank]
          

    George,
    You could go for using a CASE statement as earlier mentioned by Erland. This would look like below: (Downside is that you need to be mentioning all possible values in the CASE)
    ALTER FUNCTION [dbo].[ufn_Banner_Orion_Employee_Comparison_parser_v2]
    @BANNER_COLUMN AS VARCHAR(MAX),
    @ORION_COLUMN AS VARCHAR(MAX)
    RETURNS @Banner_Orion_Employee_Comparison TABLE
    LAST_NAME nvarchar(max),
    EMPNO int,
    BannerColumnName nvarchar(max),
    BANNER nvarchar(max),
    ORION nvarchar(max)
    AS
    BEGIN
    INSERT INTO @Banner_Orion_Employee_Comparison(LAST_NAME, BANNER, ORION)
    SELECT
    a.LAST_NAME
    , CASE @BANNER_COLUMN WHEN 'a.BANNER_RANK' THEN a.BANNER_RANK WHEN 'a.BADGE' THEN a.BADGE END --put values as required
    , CASE @ORION_COLUMN WHEN 'b.[rank]' THEN b.[rank] END --put values as required
    FROM OPENQUERY(ORCLPROD_APDORACLE, 'select LAST_NAME, BANNER_RANK, BADGE, EMP_STATUS from XTRACT_VIEW') AS a
    inner join IWM_Stage.dbo.ViewPersonnel AS b
    on a.BADGE = b.badge
    WHERE a.EMP_STATUS = 'A'
    and a.BANNER_RANK <> b.[rank]
    RETURN;
    END;
    GO
    Another method that I would suggest is to get all values from the function, then build a dynamic query to obtain results from it .. Something like:
    ALTER FUNCTION [dbo].[ufn_Banner_Orion_Employee_Comparison_parser_v2]()
    RETURNS @Banner_Orion_Employee_Comparison TABLE
    LAST_NAME nvarchar(max),
    EMPNO int,
    BannerColumnName nvarchar(max),
    BANNER nvarchar(max),
    ORION nvarchar(max)
    AS
    BEGIN
    INSERT INTO @Banner_Orion_Employee_Comparison(LAST_NAME, BANNER, ORION)
    SELECT
    * --Returns all the columns
    FROM OPENQUERY(ORCLPROD_APDORACLE, 'select LAST_NAME, BANNER_RANK, BADGE, EMP_STATUS from XTRACT_VIEW') AS a
    inner join IWM_Stage.dbo.ViewPersonnel AS b
    on a.BADGE = b.badge
    WHERE a.EMP_STATUS = 'A'
    and a.BANNER_RANK <> b.[rank]
    RETURN;
    END;
    GO
    --Execution
    DECLARE @BANNER_COLUMN AS VARCHAR(MAX), @ORION_COLUMN AS VARCHAR(MAX),@SQL NVARCHAR(MAX)
    SET @BANNER_COLUMN='BANNER_RANK'
    SET @ORION_COLUMN='[rank]'
    SET @SQL='
    select LAST_NAME,'+@BANNER_COLUMN+','+@ORION_COLUMN+' from ufn_Banner_Orion_Employee_Comparison_parser_v2 ()'
    PRINT @SQL
    EXEC @SQL
    You just need to make sure that the column names returned by the function are UNIQUE (Using proper alias names) so that you don't have a problem referring to them from the outside..
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Retrieving Column Names from a Query

    I need to be able to generate XML that looks like this:
    <Categories>
    <Category Name='Arrivals'/>
    <Category Name='Departures'/>
    <Category Name='Unused'/>
    <Category Name='Out of Commission'/>
    </Categories>
    Where the name attribute value is the name of columns in a query. For example, a standard SQL query might look something like this:
    select
    year, arrivals, departures, unused, out_of_commission
    from
    some_table
    I am able to generate the XML that represents the data just fine. However, my vended application is requiring this column header information. I've browsed and searched the XMLDB documentation but could not see a way to retrive the column names returned by the query. I think I Just need to be pointed in the right direction.
    Thanks,
    Steve

    What technique are you itending using to generate the XML ?.
    Does something like this work
    select xmlelement("Categories",
    xmlelement("Category", xmlattributes('Arrivals' as "Name"), Arrivals),
    xmlelement("Category", xmlattributes('Departures' as "Name"), Departures),
    xmlelement("Category", xmlattributes('Unused' as "Name"), Unsused),
    xmlelement("Category", xmlattributes('Out Of Commission' as "Name"), Out_of_Commission)
    from some_table

  • Retrieval of the column name in Java Mapping

    Hi All
    I am presently working on JAVA mapping which retrives the data construct the xml I want to dynamically generate the xml tag name (table column names of the Table) is there any way to do it
    Thanks
    Jayaraman

    Hi,
    You can get column names from database tables as...
    ResultSet resultSet=statement.executeQuery("select * from table");
    resultSetMetadata=resultSet.getMetaData();
    String col1 = resultSetMetadata.getColumnLabel(1);  ---> to get first column name
    and use in XML node creation as...
    Document document = DocumentHelper.createDocument();
    Element root = document.addElement("Root");
    Element Node1 = document.addElement(col1);
    Regards,
    Uma

  • Restriction for tag name and column name

    It seems that the XML tag name has to be the same as the
    corresponging column name when using xmlgen.insertXML. Is there
    any plan to relax this restriction?
    null

    Yes, tag names have to be the same as the corresponding column
    names. That is the how we can figure out which tag/element
    should be loaded into which column. This seems to be the simples
    and the cleanest way of mapping tags to columns. Nevertheless, we
    are open to suggestions.
    Also, keep in mind that you can use XSLT to do all sorts of
    transformation (including tag name transformations) to your XML
    document, before inserting it into the database. This might
    solve your problem.
    B Lou (guest) wrote:
    : It seems that the XML tag name has to be the same as the
    : corresponging column name when using xmlgen.insertXML. Is there
    : any plan to relax this restriction?
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Simplest way to get column names

    i need to retrieve column names in a rowset, let me explain a bit;
    i can simply retrieve a column name by using IColumnsInfo::GetColumsInfo, but the problem is when i use "AS" keyword in the select statement such like;
    SELECT identification AS  id FROM test_table_a
    i see alias name of that column instead the internal column name.
    as you can guess the qestion is; how can i get both alias and internal name at the same time and of course what is the *usual* way to get it.
    thanks in advance

    Getting 'real' column names from a table:
    Code Snippet
    SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'Products'

  • Named iterator can not accept certain column names

    i have a table named S as
    table S
    s# varchar2(50;
    sname varchar2(20);
    now when i try to retrieve the values of this table through named iterator i must supply the same name as java variables in the iterator.
    but column "s#" has # character and java does not support this character for a variable name . how shall i achieve this in a named iterator .
    this is giving me translation error
    #sql iterator IterS (String s#, String sname );

    Fahad,
    I assume the code you have posted is SQLJ. While I don't use SQLJ -- and hence, don't know what a "named iterator" is, is it possible to use a column alias for the "s#" column? Perhaps the following query:
    select s# as ss, sname from sOther obvious suggestions are:
    1. change the column name
    2. use JDBC (instead of SQLJ)
    Good Luck,
    Avi.

  • Using values returned from SQL for Report column names

    I am building reports against our TFS development db.
    One of the reports tracks days spent (Dwell Time) in various status categories (eg: New, Assigned, In Development, Hold, etc) for a given "ticket".
    For a fixed list of values from {Work Item].System_State, I can send the results (days in Assigned) to the column named (Assigned) for each status for each event in the [Work Item History], and then sum them for each ticket as:
    Ticket ID      New          Assigned       InDev       etc
    1230001        2                  0                 0          ...
    1230001        0                  1                 2          ....      
    SUM            2                    1                2         ....            
    However, I have many different Projects, each of which use their own Status names.
    I don't want to duplicate the same basic report, if I can avoid it.
    How can I name and generate this data for the unique Status list for each Project?
    Simplest analog is:  name = First(Fields!Status.Value, "TFSdb")
    and allows value for a column name (category) as: =IIF(Fields!Status.Value = First(Fields!Status.Value, "TFSdb"), Fields!Days.Value, 0)
    However this fails beause:
    1. It only delivers the FIRST status value, and,
    2. I cannot SUM an expression which is itself an aggregate (using First).

    RRapport,
    Is this still an issue?
    Thanks!
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • How to use the column names generated from Dynamic SQL

    Hi,
    I have a problem with Dynamic SQL.
    I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
    But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
    For that i have used a ref cursor to open and insert the table.
    In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
    Please find below the sample code:
    TYPE ref_csr IS REF CURSOR;
    insert_csr ref_csr;
    v_select VARCHAR2 (4000) := NULL;
    v_table VARCHAR2 (4000) := NULL;
    v_where VARCHAR2 (4000) := NULL;
    v_ins_tab VARCHAR2 (4000) := NULL;
    v_insert VARCHAR2 (4000) := NULL;
    v_ins_query VARCHAR2 (4000) := NULL;
    OPEN insert_csr FOR CASE
    WHEN v_where IS NOT NULL
    THEN 'SELECT '
    || v_select
    || ' FROM '
    || v_table
    || v_where
    || ';'
    ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
    END;
    LOOP
    v_ins_query :=
    'INSERT INTO '
    || v_ins_tab
    || '('
    || v_insert
    || ') VALUES ('
    || How to fetch the column names here
    || ');';
    EXECUTE IMMEDIATE v_ins_query;
    END LOOP;
    Please help me out with the above problem.
    Edited by: kumar0828 on Feb 7, 2013 10:40 PM
    Edited by: kumar0828 on Feb 7, 2013 10:42 PM

    >
    I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
    So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
    >
    Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307

Maybe you are looking for

  • BP replication from CRM to R/3

    Dear All, Is there a way to assign R/3 account groups during BP creation in CRM. i.e When I create a BP in CRM, system should assign it to one out of many available account groups based on a user defined condition. In PIDE I can maintain an Account g

  • PCA Financial Statement (Profit/Loss Account and Balance Sheet)

    Hi Experts, I have the following question on preparing PCA Financial Statement (Profit/Loss Account and Balance Sheet), ECC6.0, with document splitting features. Let say I started my business with the following GL accounts: Bank A, USD6,000 Bank B, U

  • Populating an error message

    Hi,   I need to populate an error message in crmd_order when the status is 'open' or 'dispatched' for uninstall order. how to get only these two status into a table?????? Regards, Lakshmi

  • Teredo Tunneling Network Driver. How to reinstall missing driver?

    System Description: T60p 8244-J2U - Vista Business - Trend Micro As the Lenovo ToolBox was indicating an error message (triangle) in Device Manager and I was unable to update the Teredo Tunneling pseudo (something) Network Driver, I uninstalled it th

  • Issue with Standard price

    The issue is coming when we are using currency as TND and HUF TND Currency has 3 decimal points HUF Currency has NO decimal points. 1) Issue with TND Currency: - Price value shifting left side by one decimal Sample Scenario for TND: When a cart is ge