Query to damp file

Hi community
I need a query to damp file exported by EXPDP to return the list of tables contains in that damp if possible. I want to import only specific tables from that damp but I don't know actually the tables contains in it
Regards
Sadock

Sadock wrote:
Dear Ajinkya
The comand you gave return errors as follows:
C:\Users\Administrator>imp file=d:\damp\scott_schema.dmp logfile=d:\damp\logfile_scott_schema.log fromuser=scott touser=scott buffer=1000000 show=y
LRM-00101: unknown parameter name 'logfile'
IMP-00022: failed to process parameters, type 'IMP HELP=Y' for help
IMP-00000: Import terminated unsuccessfully
actually the damp file contains tables from the scott's schema
If you are using traditional IMPORT then it has to be log=d:\damp\logfile_scott_schema.log
and if you are using DataPump then logfile=d:\damp\logfile_scott_schema.log

Similar Messages

  • Procedure to save the output of a query into excel file or flat file

    Procedure to save the output of a query into excel file or flat file
    I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
    I have run the query --
    DECLARE @cmd VARCHAR(255)
    SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
    Exec xp_cmdshell @cmd
    error message--
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
    NULL
    Goel.Aman

    Hello,
    -T:
    Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
    login_id, and password are not required. If
    –T is not specified, you need to specify
    –U and –P to successfully log in.
    -U:
    Specifies the login ID used to connect to SQL Server.
    Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
    -T option (trusted connection) instead of the
    user name and password combination
    I would suggest you take a look at the following article:
    bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
    A similar thread regarding this issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
    Regards,
    Elvis Long
    TechNet Community Support

  • Alarm & Event Query To Spreadsheet File VI doesn't work correctly (DSC 7.1)

    I am using the Alarm & Event Query To Spreadsheet File VI to write alarms/events to an Excel spreadsheet. However there are two things it does wrong:
    1. Global variables in the header are not correctly inserted. I am using the header "{creationDate}{delimiter}{creationTime}" but none of the variables are translated to their actual values. The same header in Write Traces To Spreadsheet VI works correctly, so I assume it is only the Alarm & Event Query To Spreadsheet File VI that isn't working.
    2. My display format is set to display the date of the alarms but it never appears. Set time/ACK time, etc all appear, just not the date.
    Can anyone explain what might be wrong?

    Hi AndrewWilliams,
    I have been looking into this problem for you and I can't quite figure out exactly what it is you are trying to do. Could you possibly send me your VI's (for the Alarm & Event Query To Spreadsheet File VI and for the Write Traces To Spreadsheet VI) so I can get a better idea of it.
    Have you looked at the Export Alarms to File VI in the LabVIEW examples that are installed with the DSC module. This is a very good VI and it might help you to see any faults in your code.
    Hope this helps, I look forward to speaking to you soon.
    Best regards,
    Peter H.
    Applications Engineer.
    National Instruments.

  • Output of SQ01 Query to a file in background

    Hello,
           I have created a SQ01 query for a certain specific outpur from my SAP system. I need to get the output of this query to a file. While i have tried executing this report from the frontend; it works smoothly, and based on the variant it creates the output and writes to a file at a remote location. But while i am trying to process the same query using background job, it creates a spool request and doesnt export the data to a file.
           Can someone please help me in getting me right in case i am doing anything wrong.
    Regards,
    V

    Hi,
    SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.
    Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
    It look exactly like what you see during a spool display.
    Please note that it is not restricted to sapsciprts spool only.  Any reports in the spool can be converted using the program 'RSTXPDFT4'.
    Regards,
    Pavan

  • Unattended Daily Exporting of Query to Flat File

    I am VERY new to Oracle and SQL Plus. I've been tasked with automating a query to run unattended daily to export data and store it in a flat file with structured naming convention (CC_MMDDYY.exp). I need to have it be able to an "on demand" query to flat file too. Any help would be appreciated.

    search asktom.oracle.com (temporary unavailable right now) for keyword flat file to obtain a procedure to write the result of a given query to a flat file and that's it. You can then schedule it's execution using DBMS_SCHEDULER or execute it on demand.
    Regards
    Etbin
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:68212348056
    Message was edited by: Etbin
    user596003

  • How to query a csv file

    Hello I am new to cold fusion.
    I am wondering if there is a way to query a csv file using a read from cffile? Currently I have it setup as a cffile read and then I try to query the file using cffquery. Obviously this doesn't work because I have to set a datasource. Is there anyway to do this or any way to set a csv file as a data source? Any help or direction would be greatly appreciated.
    Thanks.

    You would have to read in the csv and create a query using QueryNew(). Once you have the csv in a query format, then you can perform query of queries to do most anything you want on the data. There is probably code already written out there to do the csv to query, you just need to find it. The query of queries is in the documentation. The only gotcha is that query of queries sorting and matching is case sensitive. Hope this helps.

  • CohQL command line Tool select query output in file (unix)

    Ho to insert Coherence CohQL command line Tool select query result in file in unix platform. I have tried below query but failed
    query.cmd -s -c -l "select * from 'dist-example'" >myOutput.txt
    I also tried below query, result is displayed in command line but no file is created in folder.
    select * from dist-example >myOutput.txt
    I also tried one more query, result is displayed in command line but no file is created in folder.
    select * from dist-example >/opt/bin/myOutput.txt

    Hi,
    In Unix you should use query.sh instead of query.cmd
    In your case then the command would be smething like:
    query.sh -s -c -l "select * from 'dist-example'" >myOutput.txt
    You can also try using '>>' instead of '>' in order to redirect to a text file.
    Hope this helps.
    -Cris

  • How to query the flat files?

    Hi
    How to query the flat files that are used in Etl From EBS source.

    That can be done in OBIEE. Save the flat file as .csv format. Then go to ODBC Administrator on windows machine where you BI server is running, and create an System DSN and select "Microsft Access Text Driver (*.txt, *.csv)" as driver type.
    Next, import tables in RPD using this ODBC connection. Rest of the steps as same as building model from a table source.
    Hope this helps.

  • Small query from batch file

    I have just created batch file with the below code
    FOR /F "usebackq delims=!" %%i IN (`sqlplus -s usr/pwd@orclprd @runquery.sql`) DO set var_x=%%i
    rem @echo on
    echo "value of var_x " is %var_x%
    Trying to get the value of variable x from the query which is in runquery.sql(select status from table1 where id=20292;)
    but when i execute the batch file ,it got stuked and not giving or printing the value of 'X';
    Do i need to add or modify any thing else to get the X Value????

    Wrong forum but this is what I do to get variables back....
    sqlplus -L -S %user%/%pw%@%host% @sp\oracle\sp_etl_rollback.sql > connect.logThe results of this connection test is put into the connect.log file (the greater than (>) symbol is a assignment operator to assign whatever it gets from the buffer on that query into the file).
    Then just use any FOR /F look to get the value from the .log file.
    Here is an example I use to find a certain ID:
    echo set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on linesize 4096 serveroutput on > temp.sql
    echo select count(*) from d_grid where grid_id = '%grid%'; >> temp.sql
    echo exit; >> temp.sql
    sqlplus -S %user%/%pw%@%host% @temp.sql > result.dat
    for /f %%x in ('more result.dat') do set exists=%%x
    IF '%exists%'=='0' goto :NO_GRID
    IF '%exists%'=='1' IF '%undo_type%'=='1' goto :GET_DATE
    IF '%exists%'=='1' IF '%undo_type%'=='2' goto :ORA_GET_BATCH
    IF '%exists%' GTR '1' (
         SET errormsg=Two separate grid entries contain the same name!!      
         goto :ERROR )TimS

  • SQL Query to Text file

    I need to dump a query out to files, the issue is that this
    query has to break by an specific code and then create the text
    file based on this code. But when I try to execute it I get a Jrun
    Server error "Jrun 500 Null".
    please take a look at the code and tell me what I'm doing
    wrong.

    ok some of these suggestions worked, I no longer get the Jrun
    Server 500 NUll error but the query still does not execute except
    for the last Master_IPA code.
    <!------Revised Code------>
    <cfsetting requesttimeout="500000">
    <cfparam name="form.data_var" default="0">
    <cfswitch expression="#form.data_var#">
    <cfcase value="1">
    <cfinvoke component="dataCOM" method="getCapdata"
    returnvariable="ipaList">
    <cfset List = #ValueList(ipaList.MASTER_IPA,",")#>
    <CFSET CRLF = chr(13) & chr(10)>
    <cfoutput>
    <cfloop index="curLine" list="#List#" delimiters =
    ",">
    <cfset fields = #TRIM(curLine)#>
    <cfset filePath =
    #GetDirectoryFromPath(ExpandPath("."))#&"downloads\"&#TRIM(curLine)#&"_capPremSpec_"&#Dat eFormat(NOW(),'mmddyyyy')#&".txt">
    <cffile action="write" file="#filePath#"
    output="WDW_PRODUCT|MASTER_IPA|WDW_IPA_ID|WDW_PCP_ID|EXTERNAL_PCP_ID|SEQ_MEMB_ID|ACTIVITY _DATE|ADJUSTMENT|FUNDING_AB|FUNDING_D|FUNDING_MEMBER_PREMIUM|GROSS_DC_ABOVE_ATTACH_PNT_AMT |IBNR|INST_CLAIM|IPA_CLAIM|IPA_DISBURSEMENTS|LOW_INCOME_COST_SHARING_AMT|MED_EXP_AB|MED_EX P_D|MEMBER_COUNT|MEMBER_PREMIUM|NET_AB|NET_PART_D|PART_D_INCLUDE_FLAG|PART_D_PREMIUM|PCP_C AP|PHARMACY|PLAN_DISBURSEMENTS|PREMIUM|PROF_CLAIM|REINSURANCE|RISK_CORRIDOR|RX_CLAIM_DOLLA RS|RX_STOP_LOSS|SPEC_CAP|SSC_AMT|STOP_LOSS|WDW_FUNDING_COUNTY|PLAN_CODE|PCP_LAST_NAME|PCP_ FIRST_NAME|WDW_INPUT_CHANNEL|WDW_COHORT|WDW_ELIG_CATEGORY|MASTER_DOB|MASTER_SEX|MEDICAID_N O|MEDICARE_NO|SUBSCRIBER_ID|LAST_NAME|FIRST_NAME|ADDRESS_LINE_1|ADDRESS_LINE_2|CITY|WDW_ST ATE|ZIP|RISK_SCORE_AB|RISK_SCORE_D|HOSPICE|ESRD|INSTITUTIONAL|NURSING_HOME_CERTIFIABLE|MED ICAID|MEDICAID_ADD_ON|PREVIOUS_DISABLE|PHONE|REGION|WDW_PRODUCT|MASTER_IPA|WDW_IPA_ID|WDW_ PCP_ID|EXTERNAL_PCP_ID|SEQ_MEMB_ID|ACTIVITY_DATE|ADJUSTMENT|FUNDING_AB|FUNDING_D|FUNDING_M EMBER_PREMIUM|GROSS_DC_ABOVE_ATTACH_PNT_AMT|IBNR|INST_CLAIM|IPA_CLAIM|IPA_DISBURSEMENTS|LO W_INCOME_COST_SHARING_AMT|MED_EXP_AB|MED_EXP_D|MEMBER_COUNT|MEMBER_PREMIUM|NET_AB|NET_PART _D|PART_D_INCLUDE_FLAG|PART_D_PREMIUM|PCP_CAP|PHARMACY|PLAN_DISBURSEMENTS|PREMIUM|PROF_CLA IM|REINSURANCE|RISK_CORRIDOR|RX_CLAIM_DOLLARS|RX_STOP_LOSS|SPEC_CAP|SSC_AMT|STOP_LOSS|WDW_ FUNDING_COUNTY|PLAN_CODE|PCP_LAST_NAME|PCP_FIRST_NAME|WDW_INPUT_CHANNEL|WDW_COHORT|WDW_ELI G_CATEGORY|MASTER_DOB|MASTER_SEX|MEDICAID_NO|MEDICARE_NO|SUBSCRIBER_ID|LAST_NAME|FIRST_NAM E|ADDRESS_LINE_1|ADDRESS_LINE_2|CITY|WDW_STATE|ZIP|RISK_SCORE_AB|RISK_SCORE_D|HOSPICE|ESRD |INSTITUTIONAL|NURSING_HOME_CERTIFIABLE|MEDICAID|MEDICAID_ADD_ON|PREVIOUS_DISABLE|PHONE|RE GION"
    addnewline="yes" />
    <cfquery name="textFiles" datasource="#request.dsn#">
    SELECT TOP 100
    WDW_PRODUCT,MASTER_IPA,WDW_IPA_ID,WDW_PCP_ID,EXTERNAL_PCP_ID,SEQ_MEMB_ID,ACTIVITY_DATE,
    ADJUSTMENT,FUNDING_AB,FUNDING_D,FUNDING_MEMBER_PREMIUM,GROSS_DC_ABOVE_ATTACH_PNT_AMT,IBNR, INST_CLAIM,
    IPA_CLAIM,IPA_DISBURSEMENTS,LOW_INCOME_COST_SHARING_AMT,MED_EXP_AB,MED_EXP_D,MEMBER_COUNT, MEMBER_PREMIUM,
    NET_AB,NET_PART_D,PART_D_INCLUDE_FLAG,PART_D_PREMIUM,PCP_CAP,PHARMACY,PLAN_DISBURSEMENTS,P REMIUM,PROF_CLAIM,
    REINSURANCE,RISK_CORRIDOR,RX_CLAIM_DOLLARS,RX_STOP_LOSS,SPEC_CAP,SSC_AMT,STOP_LOSS,WDW_FUN DING_COUNTY,PLAN_CODE,
    PCP_LAST_NAME,PCP_FIRST_NAME,WDW_INPUT_CHANNEL,WDW_COHORT,WDW_ELIG_CATEGORY,MASTER_DOB,MAS TER_SEX,MEDICAID_NO,
    MEDICARE_NO,SUBSCRIBER_ID,LAST_NAME,FIRST_NAME,ADDRESS_LINE_1,ADDRESS_LINE_2,CITY,WDW_STAT E,ZIP,RISK_SCORE_AB,
    RISK_SCORE_D,HOSPICE,ESRD,INSTITUTIONAL,NURSING_HOME_CERTIFIABLE,MEDICAID,MEDICAID_ADD_ON, PREVIOUS_DISABLE,
    PHONE,REGION,WDW_PRODUCT,MASTER_IPA,WDW_IPA_ID,WDW_PCP_ID,EXTERNAL_PCP_ID,SEQ_MEMB_ID,ACTI VITY_DATE,
    ADJUSTMENT,FUNDING_AB,FUNDING_D,FUNDING_MEMBER_PREMIUM,GROSS_DC_ABOVE_ATTACH_PNT_AMT,IBNR, INST_CLAIM,
    IPA_CLAIM,IPA_DISBURSEMENTS,LOW_INCOME_COST_SHARING_AMT,MED_EXP_AB,MED_EXP_D,MEMBER_COUNT, MEMBER_PREMIUM,
    NET_AB,NET_PART_D,PART_D_INCLUDE_FLAG,PART_D_PREMIUM,PCP_CAP,PHARMACY,PLAN_DISBURSEMENTS,P REMIUM,PROF_CLAIM,
    REINSURANCE,RISK_CORRIDOR,RX_CLAIM_DOLLARS,RX_STOP_LOSS,SPEC_CAP,SSC_AMT,STOP_LOSS,WDW_FUN DING_COUNTY,PLAN_CODE,
    PCP_LAST_NAME,PCP_FIRST_NAME,WDW_INPUT_CHANNEL,WDW_COHORT,WDW_ELIG_CATEGORY,MASTER_DOB,MAS TER_SEX,MEDICAID_NO,
    MEDICARE_NO,SUBSCRIBER_ID,LAST_NAME,FIRST_NAME,ADDRESS_LINE_1,ADDRESS_LINE_2,CITY,WDW_STAT E,ZIP,RISK_SCORE_AB,
    RISK_SCORE_D,HOSPICE,ESRD,INSTITUTIONAL,NURSING_HOME_CERTIFIABLE,MEDICAID,MEDICAID_ADD_ON, PREVIOUS_DISABLE,PHONE,REGION
    FROM dbo.CapPremSpecInload
    WHERE MASTER_IPA ='#TRIM(curLine)#'
    </cfquery>
    <cfset msg = "file"&#TRIM(curLine)#&"
    created!">
    #msg#<br />
    </cfloop>
    </cfoutput>
    <cfoutput>
    <cfloop query="textFiles">
    <cffile action="append" file="#filePath#"
    output="#WDW_PRODUCT#|#MASTER_IPA#|#WDW_IPA_ID#|#WDW_PCP_ID#|#EXTERNAL_PCP_ID#|#SEQ_MEMB_ ID#|#ACTIVITY_DATE#|#ADJUSTMENT#|#FUNDING_AB#|#FUNDING_D#|#FUNDING_MEMBER_PREMIUM#|#GROSS_ DC_ABOVE_ATTACH_PNT_AMT#|#IBNR#|#INST_CLAIM#|#IPA_CLAIM#|#IPA_DISBURSEMENTS#|#LOW_INCOME_C OST_SHARING_AMT#|#MED_EXP_AB#|#MED_EXP_D#|#MEMBER_COUNT#|#MEMBER_PREMIUM#|#NET_AB#|#NET_PA RT_D#|#PART_D_INCLUDE_FLAG#|#PART_D_PREMIUM#|#PCP_CAP#|#PHARMACY#|#PLAN_DISBURSEMENTS#|#PR EMIUM#|#PROF_CLAIM#|#REINSURANCE#|#RISK_CORRIDOR#|#RX_CLAIM_DOLLARS#|#RX_STOP_LOSS#|#SPEC_ CAP#|#SSC_AMT#|#STOP_LOSS#|#WDW_FUNDING_COUNTY#|#PLAN_CODE#|#PCP_LAST_NAME#|#PCP_FIRST_NAM E#|#WDW_INPUT_CHANNEL#|#WDW_COHORT#|#WDW_ELIG_CATEGORY#|#MASTER_DOB#|#MASTER_SEX#|#MEDICAI D_NO#|#MEDICARE_NO#|#SUBSCRIBER_ID#|#LAST_NAME#|#FIRST_NAME#|#ADDRESS_LINE_1#|#ADDRESS_LIN E_2#|#CITY#|#WDW_STATE#|#ZIP#|#RISK_SCORE_AB#|#RISK_SCORE_D#|#HOSPICE#|#ESRD#|#INSTITUTION AL#|#NURSING_HOME_CERTIFIABLE#|#MEDICAID#|#MEDICAID_ADD_ON#|#PREVIOUS_DISABLE#|#PHONE#|#RE GION#|#WDW_PRODUCT#|#MASTER_IPA#|#WDW_IPA_ID#|#WDW_PCP_ID#|#EXTERNAL_PCP_ID#|#SEQ_MEMB_ID# |#ACTIVITY_DATE#|#ADJUSTMENT#|#FUNDING_AB#|#FUNDING_D#|#FUNDING_MEMBER_PREMIUM#|#GROSS_DC_ ABOVE_ATTACH_PNT_AMT#|#IBNR#|#INST_CLAIM#|#IPA_CLAIM#|#IPA_DISBURSEMENTS#|#LOW_INCOME_COST _SHARING_AMT#|#MED_EXP_AB#|#MED_EXP_D#|#MEMBER_COUNT#|#MEMBER_PREMIUM#|#NET_AB#|#NET_PART_ D#|#PART_D_INCLUDE_FLAG#|#PART_D_PREMIUM#|#PCP_CAP#|#PHARMACY#|#PLAN_DISBURSEMENTS#|#PREMI UM#|#PROF_CLAIM#|#REINSURANCE#|#RISK_CORRIDOR#|#RX_CLAIM_DOLLARS#|#RX_STOP_LOSS#|#SPEC_CAP #|#SSC_AMT#|#STOP_LOSS#|#WDW_FUNDING_COUNTY#|#PLAN_CODE#|#PCP_LAST_NAME#|#PCP_FIRST_NAME#| #WDW_INPUT_CHANNEL#|#WDW_COHORT#|#WDW_ELIG_CATEGORY#|#MASTER_DOB#|#MASTER_SEX#|#MEDICAID_N O#|#MEDICARE_NO#|#SUBSCRIBER_ID#|#LAST_NAME#|#FIRST_NAME#|#ADDRESS_LINE_1#|#ADDRESS_LINE_2 #|#CITY#|#WDW_STATE#|#ZIP#|#RISK_SCORE_AB#|#RISK_SCORE_D#|#HOSPICE#|#ESRD#|#INSTITUTIONAL# |#NURSING_HOME_CERTIFIABLE#|#MEDICAID#|#MEDICAID_ADD_ON#|#PREVIOUS_DISABLE#|#PHONE#|#REGIO N#"
    addnewline="yes" />--->
    </cfloop>
    </cfoutput>
    </cfcase>
    </cfswitch>
    <!------Revised Code------>

  • Export of report/query to a file for background job runs

    I have a requirement to automate the export of a report or query to a file  so when a background job runs a  new file is generated to the drive. 
    This cannot be a customized solution for 1 report, it must be able to adapt to other reports or queries as well.
    Any help will be highly appreciated.
    Thank you,
    Thamina

    Hi,
    SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.
    Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
    It look exactly like what you see during a spool display.
    Please note that it is not restricted to sapsciprts spool only.  Any reports in the spool can be converted using the program 'RSTXPDFT4'.
    Regards,
    Pavan

  • Spool file problem,Can't see the query in output file.

    Hello ,
    I am facing a very old school kind of problem .....about spool file ....
    The scenario -
    I have made a script by name DB_Status_checkup.sql which i want to fire on the database to check the database status. In this script their are many queries regarding the data dictionary views to know about the database. It consist of nearly 25-30 different select queries..
    The problem is i want to make a spool file of the output of that query....i want to see the SQL query & the output below in the spool file, so it will be easy for me to judge the result. But i can't see the SQL query , i can only see the output , & in so many queries it all gets jumbled up....even i can't understand where the next output starts ...
    Sample of my SQL Script ....
    clear buffer
    spool D:\DB_status.txt
    /*To check the database startup time*/
    Select to_char(startup_time, 'HH24:MI DD-MON-YY') "Startup time"
    from v$instance
    .........next query n so on....
    spool off;
    In the output pf the spool file at D:\db_status.txt..
    Startup time
    08:25 16-JUL-10It shows only the output of the query in the spool file not the query,
    What should i do to get the SQL query as well as the output of that query just below it in the spool file ???
    Please suggest if you have anymore ideas , regarding this .....
    ORACLE 10g R2
    Windows Server 2008
    Thanks in advance ...

    Why don't you just use database control, instead of re-inventing the wheel?
    Apart from that, SQL*Plus has it's own reference manual, which you apparently refuse to read.
    The answer to your quiz/doc question is
    set echo on
    Sybrand Bakker
    Senior Oracle DBA

  • Can we write query in xml file to get desired field?

    I have  XML script like  below  can I query this file and get returns like Name only  for instance similar to 'select top 5 name from [HumanResources].[Department] order by DepartmentID'
    Engineering
    Tool Design
    Sales
    Marketing
    Purchasing
    <HumanResources.Department DepartmentID="1" Name="Engineering" GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="2" Name="Tool Design" GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="3" Name="Sales" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="4" Name="Marketing" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="5" Name="Purchasing" GroupName="Inventory Management" ModifiedDate="2002-06-01T00:00:00" />

    DECLARE @xml xml='<HumanResources.Department DepartmentID="1" Name="Engineering" GroupName="Research and Development"
     ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="2" Name="Tool Design" 
    GroupName="Research and Development" ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department 
    DepartmentID="3" Name="Sales" GroupName="Sales and Marketing" ModifiedDate="2002-06-01T00:00:00" />
    <HumanResources.Department DepartmentID="4" Name="Marketing" GroupName="Sales and Marketing" 
    ModifiedDate="2002-06-01T00:00:00" /><HumanResources.Department DepartmentID="5" Name="Purchasing" 
    GroupName="Inventory Management" ModifiedDate="2002-06-01T00:00:00" />'
    SELECT T.Name.value('@Name', 'VARCHAR(50)') AS Name
    FROM @xml.nodes('HumanResources.Department')
     AS T(Name);
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to query a database file on my hard drive?

    Hi,
    I have a filer called "server.dbs" on my hard drive. It is a database file. I use a simple program that allows you to view databases, and it loads up and I can traverse the database and see all the entries as any standard database.
    So I figured that Java's ability to handle SQL would allow me to make a standard SQL statement querying the database, and be able to get the results. The software stores servers in SID fields, and the value is the port the server runs on. I want to make a simple query to select a server by SID, and print the port in which that server is running on.
    So is there any way to, via my java application, load a database from a file (rather than a url) which has no authentication required, and simply make my queries directly to that file? If so, how?
    Thanks!
    -Josh

    Normal database access is via JDBC.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html
    To use that JDBC driver is needed to access the database. Databases in wide usage all have one. It isn't clear from your posting that you have a common database though.

  • Master-details query to XML file?

    Hi:
    I'm new in XML and Oracle. I want to create XML file from two tables (master-details).
    I made a small serach and tried some examples:
    Say we have these tables:
    CREATE TABLE "TEST_XML"
    (     "ID" NUMBER,
         "NAME" VARCHAR2(15),
         "AMOUNT" NUMBER,
         CONSTRAINT "TEST_XML_PK" PRIMARY KEY ("ID") ENABLE
    CREATE TABLE "TEST_XML2"
    (     "ID2" NUMBER,
         "NAME2" VARCHAR2(20),
         "AMOUNT2" NUMBER
    ALTER TABLE "TEST_XML2" ADD CONSTRAINT "TEST_XML2_FK" FOREIGN KEY ("ID2")
         REFERENCES "TEST_XML" ("ID") ENABLE
    INSERT INTO TEST_XML VALUES (1,'A',50);
    INSERT INTO TEST_XML VALUES (2,'B',30);
    INSERT INTO TEST_XML VALUES (3,'C',70);
    INSERT INTO TEST_XML2 VALUES (1,'AA',10);
    INSERT INTO TEST_XML2 VALUES (1,'AB',20);
    INSERT INTO TEST_XML2 VALUES (1,'AC',20);
    INSERT INTO TEST_XML2 VALUES (2,'BA',10);
    INSERT INTO TEST_XML2 VALUES (2,'BB',20);
    INSERT INTO TEST_XML2 VALUES (3,'CA',20);
    INSERT INTO TEST_XML2 VALUES (3,'CB',40);
    INSERT INTO TEST_XML2 VALUES (3,'CC',10);
    I want a query to create XML file contains data from TEST_XML table and for each row the related data from TEST_XML2 table.
    I did some tries (working in iSQL*PLUS):
    SET SERVEROUTPUT ON
    DECLARE
    v_ctx DBMS_XMLGEN.ctxType;
    v_file Utl_File.File_Type;
    v_xml CLOB;
    v_more BOOLEAN := TRUE;
    BEGIN
    -- Create XML document from query.
    v_ctx := DBMS_XMLGEN.newContext('select id,name,amount,cursor (select id2,name2,amount2 from test_xml2 t2 where t2.id2=t1.id) val from test_xml t1');
    DBMS_XMLGEN.setMaxRows(v_ctx, 10);
    DBMS_XMLGEN.setRowsetTag(v_ctx, 'CLAIM');
    -- Output XML document to file.
    v_file := Utl_File.FOpen('TEST_DIR', 'test1.xml', 'w');
    WHILE v_more
    LOOP
    v_xml := DBMS_XMLGEN.GetXML(v_ctx,0);
    EXIT WHEN dbms_xmlgen.getNumRowsProcessed(v_ctx) =0;
    Utl_File.Put(v_file,v_xml);
    END LOOP;
    Utl_File.FClose(v_file);
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,255));
    Utl_File.FClose(v_file);
    END;
    But hte output wasn't as I wanted:
    <CLAIM>
    <ROW>
    <ID>1</ID>
    <NAME>A</NAME>
    <AMOUNT>50</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>1</ID2>
    <NAME2>AC</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>3</ID>
    <NAME>C</NAME>
    <AMOUNT>70</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CA</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CB</NAME2>
    <AMOUNT2>40</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>3</ID2>
    <NAME2>CC</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    <ROW>
    <ID>2</ID>
    <NAME>B</NAME>
    <AMOUNT>30</AMOUNT>
    <VAL>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BA</NAME2>
    <AMOUNT2>10</AMOUNT2>
    </VAL_ROW>
    <VAL_ROW>
    <ID2>2</ID2>
    <NAME2>BB</NAME2>
    <AMOUNT2>20</AMOUNT2>
    </VAL_ROW>
    </VAL>
    </ROW>
    </CLAIM>
    Notice that for each details (from TEST_XML2) there is <VAL> tag which I don't need beside i want a query which is applicable on all environments.
    May anyone help me please......
    Regards,
    Saad

    The following looks like it produces your desired output. I used the WITH to simulate your two tables so I didn't have to CREATE them. This runs on 10.2.0.1. I'm not sure what bugs you are referring to as SQL/XML is stable in 10g that I have seen. I'm sure some bugs exist somewhere in it, just not with this usage. Just start with the SELECT statement to run on your system.
    WITH test_xml AS
    (SELECT 1 ID, 'A' name, 50 amount FROM DUAL UNION ALL
    SELECT 2, 'B', 30  FROM DUAL UNION ALL
    SELECT 3, 'C', 70  FROM DUAL),
    test_xml2 AS
    (SELECT 1 ID2, 'AA' name2, 10 amount2 FROM DUAL UNION ALL
    SELECT 1, 'AB', 20  FROM DUAL UNION ALL
    SELECT 1, 'AC', 20  FROM DUAL UNION ALL
    SELECT 2, 'BA', 10  FROM DUAL UNION ALL
    SELECT 2, 'BB', 20  FROM DUAL UNION ALL
    SELECT 2, 'BC', 20  FROM DUAL UNION ALL
    SELECT 3, 'CA', 20  FROM DUAL UNION ALL
    SELECT 3, 'CB', 40  FROM DUAL UNION ALL
    SELECT 3, 'CC', 10  FROM DUAL)
    SELECT XMLElement("CLAIM",
             XMLAgg(
               XMLElement("ROW",
                 XMLForest(id "ID",
                           name "NAME",
                           amount "AMOUNT"),
                 (SELECT XMLAgg(XMLElement("VAL_ROW",
                                 XMLForest(id2 "ID2",
                                           name2 "NAME2",
                                           amount2 "AMOUNT2")))
                          FROM test_xml2 t2
                         WHERE t2.id2=t1.id)
      FROM test_xml t1This solution works in any environment where you can issue a SQL statement from, be it SQL*Plus, PL/SQL, Java, etc.

Maybe you are looking for

  • Mac Creative Cloud menubar opens to blank window.

    This week the creative cloud menu bar opens to a blank window. I've tried delting opm.db in OOBE but that makes no difference. Anyone got any solutions or is the problem in the recent update to CC?

  • How expand an existing database in a cluster to an existing cluster node?

    Hi Guys, I was installing a RAC yesterday and below is my installation steps path, please help me to move forward. I have 2 Redhat5 servers: Node1 and Node2. I installed Clusterware and ASM on both nodes, so the system looks like this: Node1: Cluster

  • Commitment Item derivation from General Ledger

    Brothers! we want the system should derive the Commitment item from the general ledger master record.But the system is not deriving the Commitment item from General ledger. But as We read in the BCS Documentation, there are two way for derivation of

  • About Promotion Packs.

    Dear Experts, Greetings from Dubai ! I am looking for a standard step by step process for the following scenario: Scenerio 1: At times we have some finished products, which we need to send to a vendor for making promotion packs. In Simple terms, supp

  • Transaction Notification with DI Server

    Hello I am developing a Web Site with the DI Server, when I have validations in the Transaction Procedure the error  message is incorrect. Message: Could not commit transaction. Transaction Notification set @error='10' set @error_message = 'SP: 123'