Create a polygon via SQL

I have an existing spatial/polygon table in my database. I want to join it to a view and load the join into a new spatial enabled polygon table. In case you are wondering the join is very slow. I am new to SQL Server spatial and cant find anything describing
how to do this. Ultimately I will use SSIS to perform these steps for me. I have been able to do this with point data but not polygon. The existing polygon coordinates are in a Shape field and will load into another field of the same name. Here is the query
I have built so far:
select name, geography::Polygon(Shape, 4326) as Shape
FROM View as c inner join ExistingPolygonTable as v
on C.Name = v.Name
Thanks in advance.
Scott

There is no Polygon static method like there is with Point. You can create a polygon from WKT (well-known text format) using these methods:
http://technet.microsoft.com/en-us/library/bb933988.aspx Or use well-known binary, a standard binary format. But you don't have to convert a polygon from ExistingPolygonTable to string
just to store it, just store it with the TSQL insert...select statement
http://technet.microsoft.com/en-us/library/ms174335.aspx
Or maybe I've misunderstood the question, or don't know what's in the ExistingPolygonTable. Or what format it's in in that table.
Cheers, Bob

Similar Messages

  • Creating APEX pages via SQL scripts..

    Hi Guys,
    I want to create APEX pages via SQL Script. The main reason to have this option that I have couple of applications which has XML files for screen definition where I can read all screen properties (field types, sizes, caption, etc...)
    Is there any documentation or help stuff where I can find the APEX page definition tables? I found something like WWV tables but I couldnt figure it out properly...
    Any help ?
    Thanks,
    Osman...

    We have built our entire apex app in a similar way. We create the shell apex pages using apex (eg, Item Detail, Insert Item, etc.). Then we create a PL/SQL region on the page. The PL/SQL region simply calls a stored procedure to render the controls on the page. For example, our regions looks similar to this:
    begin
    apex_pkg.sp_render_page('ITEM_DETAIL',Param1,Param2,Param3);
    end;
    The sp_render_page procedure in the database generates the appropriate HTML for the page. This procedure reads meta data in the database (eg, field label, field size, field type, field position, etc.) and renders the same HTML that apex would render if the apex page was manually created. For example, in the procedure we use lines similar to these:
    HTP.p(apex_item.text(...))
    HTP.p(apex_item.select_list_from_query(...))
    Because the procedure is reading meta data, the apex page is dynamic and can be different for different users or clients.
    Darrin

  • Creating XML file via sql in 10g database

    Hi
    I am using an Oracle 10g database and via a procedure that is called from Forms 10g, I want to output data in XML format so that this file can be fed into an accounting system that uses XML.
    How do I go about doing this?

    How do I go about doing this?The most flexible way is via SQL/XML publishing functions.
    And use DBMS_XSLPROCESSOR.CLOB2FILE to write the result to a file in a single call :
    DECLARE
      xmlresult      clob;
    BEGIN
      select xmlelement("Departments",
               xmlagg(
                 xmlelement("Department",
                   xmlattributes(
                     d.deptno as "id"
                   , d.dname as "name"
                 , xmlelement("Employees",
                     xmlagg(
                       xmlelement("Employee",
                         xmlattributes(e.empno as "id")
                       , xmlforest(
                           e.ename as "Name"
                         , e.job as "Job"
                         , e.mgr as "ManagerId"
                       ) order by e.empno
                 ) order by d.deptno
             ).getclobval()
      into xmlresult    
      from scott.dept d
           join scott.emp e on e.deptno = d.deptno
      group by d.deptno, d.dname
      dbms_xslprocessor.clob2file(xmlresult, 'TEST_DIR', 'departments.xml');
    END;
    /Output : departments.xml in Oracle directory TEST_DIR :
    <Departments>
      <Department id="10" name="ACCOUNTING">
        <Employees>
          <Employee id="7782">
            <Name>CLARK</Name>
            <Job>MANAGER</Job>
            <ManagerId>7839</ManagerId>
          </Employee>
          <Employee id="7839">
            <Name>KING</Name>
            <Job>PRESIDENT</Job>
          </Employee>
          <Employee id="7934">
            <Name>MILLER</Name>
            <Job>CLERK</Job>
            <ManagerId>7782</ManagerId>
          </Employee>
        </Employees>
      </Department>
      <Department id="20" name="RESEARCH">
        <Employees>
          <Employee id="7369">
            <Name>SMITH</Name>
            <Job>CLERK</Job>
            <ManagerId>7902</ManagerId>
          </Employee>
          <Employee id="7566">
            <Name>JONES</Name>
            <Job>MANAGER</Job>
            <ManagerId>7839</ManagerId>
          </Employee>
          <Employee id="7902">
            <Name>FORD</Name>
            <Job>ANALYST</Job>
            <ManagerId>7566</ManagerId>
          </Employee>
        </Employees>
      </Department>
      <Department id="30" name="SALES">
        <Employees>
          <Employee id="7499">
            <Name>ALLEN</Name>
            <Job>SALESMAN</Job>
            <ManagerId>7698</ManagerId>
          </Employee>
          <Employee id="7521">
            <Name>WARD</Name>
            <Job>SALESMAN</Job>
            <ManagerId>7698</ManagerId>
          </Employee>
          <Employee id="7654">
            <Name>MARTIN</Name>
            <Job>SALESMAN</Job>
            <ManagerId>7698</ManagerId>
          </Employee>
          <Employee id="7698">
            <Name>BLAKE</Name>
            <Job>MANAGER</Job>
            <ManagerId>7839</ManagerId>
          </Employee>
          <Employee id="7844">
            <Name>TURNER</Name>
            <Job>SALESMAN</Job>
            <ManagerId>7698</ManagerId>
          </Employee>
          <Employee id="7900">
            <Name>JAMES</Name>
            <Job>CLERK</Job>
            <ManagerId>7698</ManagerId>
          </Employee>
        </Employees>
      </Department>
    </Departments>(formatted for display purpose)

  • Creating User account via SQL query

    Hi,
    Is it possible to create a user account programmatically?
    thanks,
    Dekel

    In SQL, use the CREATE USER statement. In PL/SQL, see Re: Creating user in PL/sql procdure.

  • How to determine via SQL who created the sales order

    Hello I am trying to determine via SQL who created the Sales Order.  I'm looking at the ADOC table but having a hard time determining which record points to the sales order creation.

    Hi Jimmy,
    Try this:
    select
         T0.[DocNum], T2.[DocDate], T2.[CardCode], T2.[CardName],
         T1.U_NAME as [User Name], T2.UpdateDate as [Cancelled Date]
    from
         ORDR T0
         inner join OUSR T1 on T0.UserSign = T1.UserID
         inner join ADOC T2 on T0.DocNum = T2.DocNum
    where
         T2.LogInstanc = (select min(LogInstanc) from ADOC T3 where T3.ObjType = 17 and T3.DocNum = T0.DocNum and T3.CANCELED = 'Y')
         and T2.CANCELED = 'Y'
         and T2.ObjType = 17
    group by
         T0.DocNum, T2.DocDate, T2.CardCode, T2.CardName, T1.U_NAME, T2.UpdateDate
    Kind Regards,
    Owen

  • Creating large polygons in PL/SQL - memory leak?

    I'm using PL/SQL to create a polygon with a very large number of vertices. I use SQL*Plus to execute the procedure. I check the memory usage in Windows Task Manager before and after the procedure. After the procedure finishes, 200K or more of memory does not get released. When I exit SQL*Plus, the memory is released. I wonder if I'm mis-understanding garbage collection in PL/SQL?
    Background: This is an experiment to prove the feasibility of composing polygons in PL/SQL. I need a procedure that selects x and y vertex coordinates from a table where the x and y are stored as normal numbers. The procedure will then compose an SDO_GEOMETRY and insert it into a spatial table. The procedure may process many thousands of polygons in this way. My experiment is to show that PL/SQL can 1) be used to populate geometry with a large number of vertices, and 2) that performance is adequate for this job.
    As a side note: I found that PL/SQL will generate an error when the ordinate array exceeds about 1,040,000 ordinates (500,000 2D vertices).
    My real question though is this: What should I do in my procedure to release the memory? Once I figure this out, I will be composing and destroying the geometry object once for each iteration of a loop that generates the object.
    Sample:
    SET SERVEROUTPUT ON
    DECLARE
    geom MDSYS.SDO_GEOMETRY;
    arrElemInfo MDSYS.SDO_ELEM_INFO_ARRAY;
    arrOrd MDSYS.SDO_ORDINATE_ARRAY;
    x integer := 0;
    y integer := 0;
    BEGIN
    arrElemInfo := MDSYS.SDO_ELEM_INFO_ARRAY(1,3,1); -- Start offset 1, etype is polygon, Interpret ETYPE as Simple polygon whose vertices are connected by straight line segments
    arrOrd := MDSYS.SDO_ORDINATE_ARRAY();
    FOR i IN 1..500000 LOOP
    x := 1;
    y := i;
    arrOrd.EXTEND(2);
    arrOrd(arrOrd.COUNT-1) := x;
    arrOrd(arrOrd.COUNT) := y;
    END LOOP;
    -- Close the polygon
    arrOrd.EXTEND(2);
    arrOrd(arrOrd.COUNT-1) := arrOrd(1);
    arrOrd(arrOrd.COUNT) := arrOrd(2);
    geom := mdsys.sdo_geometry(2003,NULL,NULL,arrElemInfo,arrOrd);
    DBMS_OUTPUT.PUT_LINE(geom.sdo_ordinates.count);
    END;
    null

    Hi Dale,
    There have been a couple of PL/SQL bug fixes in 9i related to memory use with objects. It is possible you have run into one of those issues.
    Also, I've noticed a one-time cost associated with certain functions that cause memory usage to jump once, then stabilize.
    Also, the maximum size for a varray column in Oracle (and hence the max size for the sdo_ordinates and sdo_elem_info arrays) is 1048576.
    hope this helps,
    dan
    null

  • Tables created via SQL...

    There is a way to show information stored in a table creadted via SQL in the SBO Print Forms ?

    Hello!
    yes, this will work as such, but might not give you the
    correct values as there is no link between the table and the layout! Usually, it pulls simply the first value in the table.
    Or, you might be lucky that it works now, but not after an upgrade.
    Be careful when adding field with "ALT", if you encounter problems at any stage, you will not receive any support!
    When adding fields via "ALT", check if you can create manual links between the table and the layout via "next segment" and "link to".
    Kind regards

  • Create statspack report using sql*developer

    Hello,
    While connecting with PERFSTAT user I can not create statspack report using SQL*Developer:
    @?/rdbms/admin/awrrpt
    Error starting at line 1 in command:
    @?/rdbms/admin/awrrpt
    Error report:
    Unable to open file: "?/rdbms/admin/awrrpt.sql"
    Actually, my problem or question is that how can PERFSTAT user can generate statspack reports from a Client side. What is the other way a non-dba can see the snapshots histroy and generate report (by using perfstat user ) while joing tables or using views?
    Thanks a lot.
    Best Regards

    Hi,
    for awr reports @?/rdbms/admin/awrrpt (you need EE+Diagnostic Pack) there is a solution.
    Grant execute dbms_workload_repository to <user>;
    Grant select_catalog_role to <user>;
    get all SNAP_IDs
    SELECT   TO_CHAR(s.startup_time,'YYYY.MM.DD HH24:MI:SS') INSTART_FMT,
             di.instance_name INST_NAME,
             di.db_name DB_NAME,
             s.snap_id SNAP_ID,
             TO_CHAR(s.end_interval_time,'YYYY.MM.DD HH24:MI:SS') SNAPDAT,
             s.snap_level LVL
    FROM    dba_hist_snapshot s,
             dba_hist_database_instance di
    WHERE   di.dbid = s.dbid
             AND di.instance_number = s.instance_number
             AND Di.Startup_Time = S.Startup_Time
    ORDER BY snap_id desc;
    Select * From Table(Sys.Dbms_Workload_Repository.Awr_Report_Html(DBID, 1, BEGIN_SNAP_ID, END_SNAP_ID));
    For statspack i don't know a solutuion. I think the best idea is, create a job to make the statspack report on the server side and access it via external tables or mail them forward to you.
    Best regards
    Thomas

  • Error trying to run SSIS Package via SQL Server Agent: DTExec: Could not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object

    Situation:
    SSIS Package designed in SQL Server 2012 - SQL Server Data Tools
    Windows 7 - 64 bit.
    The package (32 bit) extracts data from a SQL Server db to an Excel Output file, via an OLE DB connection.
    It uses 3 package variables:
    *) SQLCommand (String) to specify the SQL Statement to be executed by the package
    Property path: \Package.Variables[User::ExcelOutputFile].Properties[Value]
    Value: f:\Output Data.xls
    *) EXCELOutputFIle (String) to specify path and filename of the Excel output file
    Property path: \Package.Variables[User::SQLCommand].Properties[Value]
    Value: select * from CartOrder
    *) VarObjectDataSet (Object) to hold the data returned by SQL Server)
    Property path: \Package.Variables[User::VarObjectDataSet].Properties[Value]
    Value: System.Object
    It consists out of 2 components:
    *) Execute SQL Task: executes the SQL Statement passed on via a package variable. The resultng rows are stored in the package variable VarObjectDataSet
    *) Script Task: creates the physical output file and iterates VarObjectDataSet to populate the Excel file.
    Outcome and issue:The package runs perfectly fine both in SQL Server Data Tools itself and in DTEXECUI.
    However, whenever I run it via SQL Server Agent (with 32 bit runtime option set), it returns the errror message below.
    This package contains 3 package variables but the error stating that a package variable can not be set, pops up for the VarObjectDataSet only.  This makes me wonder if it is uberhaupt possible to set the value of a package variable
    of type Object.
    Can anybody help me on this please ?
    Message
    Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  6:40:20 PM  DTExec: Could
    not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object.  Started:  6:40:20 PM  Finished: 6:40:21 PM  Elapsed:  0.281 seconds.  The package execution failed.  The step failed.
    Thank you very much in advance
    Jurgen

    Hi Visakh,
    thank you for your reply.
    So, judging by your reply, not all package variables used inside a package need to be set a value for when run in DTEXEC ?
    I already tried that but my package ended up in error (something to do with "... invocation ...." and that error is anything but clearly documented. Judging by the error message itself, it looks like it could be just about anything. that is why I asked my
    first question about the object type package variable.
    Now, I will remove it from the 'set values' list and try another go cracking the unclear error-message " ... invocation ...". Does an error message about " ... invocation ..." ring any bells, now that we are talking about it here ?
    Thx in advance
    Jurgen
    Yes exactly
    You need to set values only forthem which needs to be controlled from outside the package
    Any variable which gets its value through expression set inside package or through a query inside execute sql task/script task can be ignored from DTExec
    Ok I've seen the invocation error mostly inside script task. This may be because some error inside script written in script task. If it appeared after you removed the variable then it may because some reference of variable existing within script task.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Can connect via ODBC but not via SQL Developer?

    Hi, all.
    My setup:
    Windows XP Pro
    JDK 1.6
    SQL Developer 2.1.1.64.45
    I'm attempting to connect to an Oracle DB using OS authentication and trying hand-entry of the host and SID; and also trying my TNS file. When I attempt to connect via SQL Developer, I get the following error:
    "Status : Failure -Test failed: ORA-01017: invalid username/password; logon denied."
    When I attempt this same connection, however, using ODBC and Access, I can get right in and see the tables.
    What can I try in order to get SQL Developer working correctly?
    Thanks,
    IVR Avenger

    I'm not really familiar with connections Using OS authentication, but if OCI+TNS based connections work you could try to activate OCI connections by selecting
    Preferences -> Database -> Advanced -> Use OCI/Thick Driverand then use the TNS connection type when creating your connection.
    It should work well even with the thin driver but i cannot help you in this case because i've never had to use this kind of authentication.

  • Is this possible via SQL or not ?

    Hi There
    I have a scenario. Am not sure if this is possible via SQL or not.
    For Example Consider two tables
    T1
    product_id location_id stock
    A 1 100
    T2
    product_id location_id aging_phase received_qty
    A 1 1 20
    A 1 2 30
    A 1 3 70
    Now in T1 there is actual stock that is 100, while aging wise if i see stock that is 20+30+70=120
    What i want is, generate a SQL that should yield quantity equals stock in T1 but with AGING PHASE wise break up
    Result should be like this :
    product_id location_id aging_phase qty
    A 1 1 20
    A 1 2 30
    A 1 3 50
    It would be a great help if somehow it becomes possible. Anyone have some solution ?
    Regards
    Capri

    Capri wrote:
    May i have your email id please so that i can describe my problem in detail ?As Billy mentioned I would prefer not to do this. However, you can explain your problem here in detail. Please provide the following information:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements
    3. Expected output.
    4. The business logic to achieve the expected output.
    5. Please use \ tags to surround #2 and #3.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Internal PLSQL Tables Access via SQL. But how ?

    Hello,
    I want to write the result of a database query in an internal PLSQL Table. After that i would like work with this internal PLSQL Table
    in a Package/Procedure/Function.
    Important for me is to access the internal Table via SQL because i have to refactor a package wich is working with 46 Database Tables an plain SQL. I
    would like to change these DB Tables into internal PLSQL Tables.
    I have written a short example wich will explain my approach to solving this problem.
    The syntax will be accepted by the Database but my 'dbms_output.put_line' statement at the end is empty or blank.
    What do i wrong ? Would be nice if anyone can help me out.
    With best regards
    Jens
    pre work :
    create table PERSON_DB_TABLE
    (SURNAME  VARCHAR2(50),
    LASTNAME VARCHAR2(50));
    insert into PERSON_DB_TABLE values
    ('JENS','FOERSTER');
    insert into PERSON_DB_TABLE values
    ('MAX','MEIER');
    insert into PERSON_DB_TABLE values
    ('MARTHA','MUSTERMANN');
    create type PERSON_OBJECT as object (
        SURNAME  VARCHAR2(50),
        LASTNAME VARCHAR2(50));
    create type PERSON_NESTED_TABLE as table of PERSON_OBJECT;
    now my anonymous block
    declare
       v_PERSON_OBJECT        PERSON_OBJECT;
       v_PERSON_NESTED_TABLE  PERSON_NESTED_TABLE;
       v_PERSON_OBJECT_2      PERSON_OBJECT;
    begin
       for v_counter in (select SURNAME, LASTNAME into v_PERSON_OBJECT.SURNAME,
                                                                                            v_PERSON_OBJECT.LASTNAME
                                  from PERSON_DB_TABLE)
         loop
            v_PERSON_NESTED_TABLE := PERSON_NESTED_TABLE(v_PERSON_OBJECT);
         end loop;
       for v_counter in (select SURNAME, LASTNAME into v_PERSON_OBJECT_2.SURNAME,
                                                                                            v_PERSON_OBJECT_2.LASTNAME
                                  from TABLE (v_PERSON_NESTED_TABLE))
         loop
            dbms_output.put_line(v_PERSON_OBJECT_2.LASTNAME);
         end loop; 
    end;

    1386a7b8-e834-43bf-a0d4-922b548bb70b wrote:
    I need this, because my customer didn't like the idea to use Database Tables instead of Variables in the RAM. So he wants this procedure redesigned.
    As Mike says, keep this person away from your database.
    Customers should not be dictating how to implement technical solutions, they should be providing business and logical requirements.
    PL/SQL arrays/collections use expensive PGA memory, taking up valuable server resources.
    Copying data from the database to PGA memory to try and process it using PL/SQL is bad design.  SQL is designed specifically for data manipulation using database tables, so it's the ideal way to do process data... directly on database tables.

  • Reading the contet via SQL

    Hello,
    I've created a file test.txt with some example content and uploaded it to xml db via ftp.
    When I execute
    SELECT r.RES.getClobVal()
    FROM RESOURCE_VIEW r WHERE equals_path(RES, '/LCS/order/V23184/test.txt') = 1;
    i get
    <Contents>
    <text>this is my content</text>
    </Contents>
    as part of the clob. Thats what I need.
    When I now rename the file to test.bwa for example and try to get the content via sql again, this is the result:
    <Contents>
    <binary>626C61626C75626220454E2039373831323334353637383930</binary>
    </Contents>
    I guess XML DB does not know the ending .bwa so it does not show the text value. How can I show my original text instead of the binary content?
    Thank you in advance
    Philipp
    Edited by: philippd on 23.03.2009 12:34

    Which db version are you working with. Youl'll need to mimetype mappings for this. In 10gR2 and earlier you'll need xdb_configuration from the xdbUtilties package. in 11g I think DBMS_XDB has a method for this.

  • Creating a pre-configured SQL instance installation file

    Hi,
    Is it possible to create a pre-configured SQL instance installation file?
    I want to pre-configure authentication mode, sa password, collation etc so that users will just need to run the .exe and everything will be done for them. At the moment users need to run a batch file that contains the unattended installation script, but
    that is proving to be too much for some...

    Hi RRozanski,
    To meet your own requirement, you can firstly change the ConfigurationFile.ini file which is generated by SQL Server setup wizard. Then users can install SQL Server with the new ConfigurationFile.ini file via installer wizard as follows.
    Go to SQL Server Installation Center and click on the Advanced page. Click on Install based on configuration file, specify the location of the ConfigurationFile.ini file and the SQL Server setup.exe location. You can find setup.exe at the root level of the
    SQL Server installation media.
    Like a normal installation you can see all the screens with the prefilled information and this gives you the advantage to review or make changes if needed.
    For more details, please review below blog.
    Standardize SQL Server Installations with Configuration Files
    http://www.mssqltips.com/sqlservertip/2511/standardize-sql-server-installations-with-configuration-files/
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • .csv data import via SQL developer

    I am trying to load an Access 2003 table into an Oracle 10g database via SQL developer. The Access file is located on another system and there is no ODBC connection between it and the SQL server.
    What I have done so far is the following:
    i) Export Access table as comma-delimited text file;
    ii) Open text file and re-saved as .CSV;
    iii) On SQL developer - created a table that matches the column structure in the original Access table, then right-clicked > Import Data > on Data Import Wizard I click Next...
    after this, the wizard hangs on step 1, and does not allow me to move to the second step. It doesn't matter whether or not the SQL *Loader option is checked.
    If anyone could offer some advice on the procedure I have applied above and possible sources of weakness, I'd be grateful to hear your thoughts. I'm relatively new to Oracel SQL and not very experienced with databases in general.
    Thanks

    Since this is not native export/import, a better place could be this forum:
    SQL Developer

Maybe you are looking for

  • Need help in understanding the result logged in gateway log file

    I have installed unixODBC.x86_64 (2.2.14) and mysql-connector-odbc-5.3.4-linux-el6-x85-64 on Oracle Linux Server 6.5 64 bit with Oracle 12c and MySQL Community Server 5..6.14.  Oracle database character set is AL32UTF8 and MySQL database character se

  • Macbook air "Aboout This Mac" storage indicator incorrect

    I'm using a Macbook air 13'' thats running on OSX Yosemite 10.10.1. There seems to be  a problem with the storage indicator. I click on the apple logo on the top left and go to storage to check the remaining space and the numbers don't seem to be rig

  • Error Function module " " not found in Smartforms

    Hi all, Please help me out…. I created the form using the smartforms, check it and activated it. I can see the unique function module is assigned to the form. I wrote the ABAP program and use function module ‘SSF_FUNCTION_MODULE_NAME’and also define

  • Attached style sheet wont work

    Hi, Im on the cs3 in a winxpPro environment. Start cs3 Create simple page Link in a style sheet for simplicity I just grabbed one of dreamweavers <link href="file:///C|/websites/membership design/system/application/CSS/Level1_Arial.css" rel="styleshe

  • EAP-AUTH-AAA-ERROR: Reply received on stale handle

    Hi, I try to deploy 802.1x EAP-TLS in Lab enviroment with ACS 4.2 and Cisco IOS Software, C3560 Software (C3560-ADVIPSERVICESK9-M), Version 12.2(46)SE If I use the PEAP, it is working, but if EAP-TLS, then nothing show in logs on ACS, but error messa