Top x when using Oracle 8i

Hi folks,
The RANK feature looks like it would do what I need, but since I'm not at 9i, it doesn't do me a lot of good. Does anyone have any suggestions for handling the following coding problem:
I have 7.5 million rows in a table with a code, charge_amt, charge_date, vendor#, etc. I need to run through my entire table to sum the charge_amt by code so that I can display just the TOP 50 or 100 of the charges at a group level. Allow me to elaborate:
Here is the SQL I use to group my charges and have them come out in desc order. The problem I am having is limiting the number of rows selected. I was thinking I could do something with the count, but unsure. Can anyone help me out?
SELECT
     SUBMITTED_CODE,
     SUM(CHARGE_AMT_DETAIL) SUM_CHARGE,
     SUM(ALLOWANCE_AMT_DETAIL) SUM_ALLOW,
     COUNT(DISTINCT(SUBMITTED_CODE)) COUNT_OF_WHAT
FROM READ_ONLY.PAYMENT_ANALYSIS
WHERE
PROVIDER_ID_NUM IN ('18072147')
     AND TO_CHAR(SERVICE_DATE, 'YYYYMMDD') >= '20030101'
     AND TO_CHAR(SERVICE_DATE, 'YYYYMMDD') <= '20030106'
GROUP BY SUBMITTED_CODE
ORDER BY SUM_CHARGE DESC, SUBMITTED_CODE
THANKS a bunch for reading this!
Janet

Justin,
Thanks for responding so quickly.
In answer to your first question, we are running 8.1.7.2.
Re: your reply and using rownum, I am encountering a problem. See below for how I inserted the line, but when I do this, I am getting only 50 rows to be included in my selection which is not what I want. I am looking to get the top 50 rows AFTER I have grouped together all of my data in order to figure out the top 50. Does that make any sense?
Thanks! Janet
SELECT
     SUBMITTED_CODE,
     SUM(CHARGE_AMT_DETAIL) SUM_CHARGE,
     SUM(ALLOWANCE_AMT_DETAIL) SUM_ALLOW,
     COUNT(DISTINCT(SUBMITTED_CODE)) COUNT_OF_WHAT
FROM READ_ONLY.PAYMENT_ANALYSIS
WHERE
PROVIDER_ID_NUM IN ('18072147')
     AND TO_CHAR(SERVICE_DATE, 'YYYYMMDD') >= '20030101'
     AND TO_CHAR(SERVICE_DATE, 'YYYYMMDD') <= '20030106'
     AND ROWNUM <50
GROUP BY SUBMITTED_CODE
ORDER BY SUM_CHARGE DESC, SUBMITTED_CODE

Similar Messages

  • Error when using oracle.j2ee.ws.StatelessJavaRpcWebService as ws wrapper

    I have a problem when using Oracle oracle.j2ee.ws.StatelessJavaRpcWebService as a web service wrapper. I get the exception below in the server.log:
    java.lang.IllegalStateException: Data has already been written to the OutputStream
         at com.evermind.server.http.EvermindHttpServletResponse.setBufferSize(EvermindHttpServletResponse.java:1965)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:541)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    The server response with “500 Internal Server Error” when contacted as a web service.
    The error only occurs patriotic on the server.
    If anyone have experience with this error please response :-)

    Hi,
    can you point me to the "FSCM TUD" doc you follow so I can reproduce the issue ? Is it a JDeveloper tutorial? Also, which version of JDeveloper do you use ?
    Frank

  • Error when using Oracle Migration WorkBench (Sql Server 2k to Oracle 8i)

    I'm trying to migrate a Sql Server 2k database to an Oracle 8i schema using OMWB. After using BCP to collect metadata information on the source database, I tried to capture the source data model and got a "Capture aborted" message on the progress screen (even though then it appears a dialog window reporting "0 errors and 0 warnings", funny!). Down there is the error log OMWB generated. After reading some posts, I changed some columns of the OMWB dictionary that holds the source database name, but still got the same error. If someone can enlighten me on this toppic, I'd greatly appreciated it.
    Here's the error log of OMWB:
    ** Oracle Migration Workbench
    ** Production
    ** ( Build 20050629 )
    ** OMWB_HOME: D:\Datos\Download\Oracle\Oracle Migration Workbench\omwb
    ** user language: es
    ** user region: null
    ** user timezone:
    ** file encoding: Cp1252
    ** java version: 1.4.2_04
    ** java vendor: Sun Microsystems Inc.
    ** o.s. arch: x86
    ** o.s. name: Windows 2000
    ** o.s. version: 5.0
    ** Classpath:
    ..\lib\boot.jar
    ** Started : Fri Feb 23 17:18:48 GMT-03:00 2007
    ** Workbench Repository : Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production
    With the Partitioning option
    JServer Release 8.1.6.0.0 - Production
    Repository Connection URL: jdbc:oracle:thin:@ServerCms:1521:sigcewbc
    ** The following plugins are installed:
    ** Microsoft Access 2.0/95/97/2000/2002/2003 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 2000 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 6.5 Plugin, Production Release 10.1.0.4.0
    ** Microsoft SQLServer 7.0 Plugin, Production Release 10.1.0.4.0
    ** Active Plugin : SQLServer2K
    EXCEPTION :SQLServer2KDisconnSourceModelLoad.loadSourceModel(): oracle.mtg.migration.MigrationStopException: java.lang.IndexOutOfBoundsException: Index: 15, Size: 15
    ** Shutdown : Fri Feb 23 18:00:50 GMT-03:00 2007

    Duplicate thread
    Error when using Oracle Migration WorkBench (Sql Server 2k to Oracle 8i)

  • Capturing error messages from Oracle EBS APIs when using Oracle Apps Adapter

    We are using Oracle applications adapter to call Oracle EBS (both R11.5 and R12) APIs. I want to understand the best practice around error handling when using Oracle Apps Adapter to call Oracle EBS.
    Here are some observations:
    1. Most of the APIs return X_RETURN_STATUS and X_MSG_DATA containing the status and messages if any.
    2. If the MSG COUNT is 1 then X_MSG_DATA contains the message, if MSG COUNT is > 1. X_MSG_DATA is empty.
    We know that when calling the API directly from PL/SQL, we need to loop through FND_MSG_PUB to fetch all messages when there are more than 1. How do we achieve the same using Apps Adapter as Apps Adapter generates the PL/SQL block to call the API dynamically at runtime.
    In some APIs, which have table/rec types as input or output parameters, Apps Adapter generates a wrapper package to do conversion from SQL--> PL/SQL and viceversa. In this case the adapter calls the custom package generated which internally calls the API. For these APIs we were able to put the logic to loop through FND_MSG_PUB and return a concatenated string as value of X_MSG_DATA.
    But what should we do for the APIs which do NOT have a rec/table type as input or output, in which case the Apps Adapter directly calls the API and there is no intermediate custom package?
    How are others handling this?

    Please see the section "Handling Functional Errors" in the below link
    Oracle Fusion Middleware Adapter for Oracle Applications User's Guide

  • Unsatisfied Link Error when using Oracle OCI (Type II) driver

    Using Oracle OCI (Type II) driver on HPUX with Oracle 9.2.0.4.
    If when creating a connection pool via the console, using the Oracle OCI (Type
    II) driver, you get the error "Unsatisfied link error with library libocijdbc9.sl
    or format error" then check that the library included in the SHLIB_PATH is pointing
    at the $ORACLE_HOME/lib32 directory and not just the $ORACL_HOME/lib

    We do not offer a JDBC driver for Linux in version 5.1. In version 6.0,we
    do offer a type 4 driver for Linux.
    In version 5.1, I suggest trying the platform independent type 4 JDBC driver
    available for free from Oracle. It is supported (as is any JDBC driver)
    with WebLogic Server. To download it:
    Go to http://www.oracle.com and select the "Download" option.
    From the resulting page, use the "Select Utility or Driver" dropdown to
    select Oracle JDBC drivers
    From the resulting page, scroll down a little (since SQLJ stuff appears at
    the top).
    Or, to go directly there:
    http://technet.oracle.com/software/tech/java/sqlj_jdbc/software_index.htm
    Thanks,
    Michael
    Michael Girdley, BEA Systems Inc
    Learning WebLogic? Buy the book.
    http://www.learnweblogic.com/
    "Michael W. Warren, Sr." <[email protected]> wrote in message
    news:[email protected]..
    I have installed WebLogic 6.0 on Solaris platform and verified that the
    server comes up
    and that I can connect to it via Netscape. Next step was to verify
    installation of WebLogic
    jDriver for Oracle. When I run the following:
    java utils.dbping ORACLE scott tiger
    I get the following error:
    Starting Loading jDriver/Oracle .....
    Error encountered:
    java.sql.SQLException: System.loadLibrary threw
    java.lang.UnsatisfiedLinkError
    with the message
    '/ldatae/bea/wlserver6.0/lib/solaris/oci816_8/libweblogicoci37.so:
    ld.so.1: /ldatae/bea/jdk130/jre/bin/../bin/sparc/native_threads/java:
    fatal: libgen.so.1: open failed: No such file or directory'.
    at
    weblogic.jdbcbase.oci.Driver.loadLibraryIfNeeded(Driver.java:202)
    at weblogic.jdbcbase.oci.Driver.connect(Driver.java:57)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:146)
    at utils.dbping.main(dbping.java:182)
    Anyone seen this? Help!!!
    Thanks in advance
    Mike Warren, Sr.
    [email protected]

  • Samba mount problem when using Oracle VM Server 2.1

    Hello
    I´m trying to mount a remote samba share from an Oracle VM Server 2.1 installation.
    To be able to do a mount.cifs, I installed samba-client manually using yum.
    yum repository based on Enterprise Linux 5 Update 1
    In the first step the mount failed with
    CIFS VFS: Server requests plain text password but client support disabled
    CIFS VFS: Send error in SessSetup = -13
    CIFS VFS: cifs_mount failed w/return code = -13
    After doing an
    echo 0x37 > /proc/fs/cifs/SecurityFlags
    the plain text password error message is gone.
    but
    CIFS VFS: Send error in SessSetup = -13
    CIFS VFS: cifs_mount failed w/return code = -13
    still exists.
    The mount command looks like that:
    mount.cifs //*servername*/*share* /mnt/*localdir* -o sec=none,user=*username*,pass=*password*
    The samba server which provides the share, only accept plain text password with no chance to get this adjusted.
    Is there anybody who knows how to fix this issue? Help would be really appreciated.

    [2008/02/08 14:58:07, 0]
    auth/pampass.c:smb_pam_passcheck(810)
    smb_pam_passcheck: PAM: smb_pam_auth failed - Rejecting User install !
    Which is an indicator that the password is transfered incorrectly.
    As the password is for sure correct, it seems to me that the sec=none option is not working correctly when using OVM 2.1.
    When using Enterprise Linux 5 Update 1 all is working well.
    There you did not even need to use the "echo 0x37"
    It works out of the box using sec=none mount option.
    That is also a reason why I started this post under Virtualization and not under Linux ;-)
    I assume it is a OVM 2.1 specific issue.

  • Security when using oracle text

    Hello,
    We would like to use Oracle text functionality on Oracle 10 but the System Admin told us that Oracle is accessing the filesystem with the user account who launched the oracle instance.
    He told us that this is a security problem : giving oracle password gives access to the file system.
    Is that true and is there a solution to make oracle connect to the filesystem with another linux user account ?
    Thanks a lot !

    raford wrote:
    This only applies when you use the FILE_DATASTORE to index documents on disk, rather than in the file system.
    You can restrict access to this feature by only allowing users having a specific role to use it - see
    http://download.oracle.com/docs/cd/B28359_01/text.111/b28304/cdatadic.htm#BHCBIFEA
    (NB. this is in the 11g documentation - I can't find it in the 10g manual but the functionality is the same).
    It's the database process itself which accesses the files, so it will always access them as the owner of the database process, there's no way to change that.What do you mean when you said " FILE_DATASTORE to index documents on disk, rather than in the file system" ?

  • Performance issue: stmt.execute() takes a long time when using Oracle objs

    Folks,
    I have a PL/SQL API that returns a REF CURSOR over an Oracle object that contains other objects. In the JDBC layer, when I do a stmt.execute(), it takes about 1.2s for this statement to run while the execution of the PL/SQL API in the database takes only about 100ms or so. When I connect to a database that is physically located really far away, the delta here increases (perhaps due to the network latency).
    I believe it is not as efficient to use Oracle ADTs in conjunction with JDBC. However, not using an Oracle object and replacing that with a bunch of linear arrays is not really an option for me considering the amount of change involved and what a maintenance nightware that would be. At the same time, I need to get this to perform better. Any thoughts?
    I suspect that there are a number of network round trips with Oracle objects are involved. If that is infact true, what are my options?
    I use Oracle 10g, and the Oracle JDBC thin driver. Thanks.

    I have an Oracle object that has say 3 fields - number, number and number_table (indexed table of numbers). Right now, I return a REF CURSOR and do a getObject() in the java layer. But, I want to try and change this so that I return linear arrays (meaning, all these fields are not embedded in an Oracle object). Dont know if that would make things quicker but wanted to check to see if there were other alternatives.
    Also, can I define a procedure that returns an OUT parameter which is an indexed table, and then do a registerOutParameter(<index>, OracleTypes.ARRAY)? I tried that but it gives me a PLS-00306 error (wrong number of types of arguments).

  • URGENT! SEGV-errors when using Oracle C XML Parser for Solaris

    I often (not always) got SEGV-error with core dump when I use Oracle Oracle C XML Parser for Solaris. This Error is always got in the call of the the function xmlinit(...) with all params as NULL but the first required for the error code and the second which i assign a macro that evaluates to "US-ASCII". Does anyone knows about this problem?
    I am using a very short, wellformed and validated XML document.
    I would be very glad for some help about this!
    null

    Please provide a sample program along with the version number of the XML parser.

  • Websphere Application Server 5.1 Hangs when using Oracle Connection Pool

    I have a j2ee application that runs on WAS 5.1 ( IBM JDK 1.4 ) and Oracle 10g 10.2.0 . My customer is doing load testing with 25 virtual users and a connection pool with a max size of 10. When the test starts all 25 users attempt to get a connection, and the first 10 get a connection. At this point the application server hangs with the connection pool in allocation. This is seen in Tivoli. Each thread only needs one connection to process it's request.
    I have my own home grown connection pool which when used under this load does not experience and issue. Monitoring from Oracle's admin console I see a max of 10 sessions. The home grows connection pool does not use a WAS DataSource.
    I have configured my application to use DB2 with a WAS DataSource and the application server does not hang. Monitoring using Tivoli shows the connection pool going into allocation, but it recovers as is expected.
    Are there any known issues with the Oracle JDBC drivers when used with WAS 5.1 DataSources?
    Any direction would be helpful, as I currently thing there is an issue with Oracle's Connection Pool and the IBM JVM.
    Thanks,
    J

    just an attention call: OracleDatasource connection pool does not accept parameters such as removeAbandoned, minEvictableIdleTimeMillis, timeBetweenEvictionRunsMillis, etc, these are specific for the tomcat dbcp implementation (http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources).
    For the accepted ones read this http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/concache.htm
    Edited by: user7428636 on 24/Jan/2011 6:22

  • Error oracle.sql.* and oracle.jdbc.driver.* not found when using oracle as a database

    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama

    Hi Anupama,
    First of all I would be surprised if you would not like to use the connection pooling feature of weblogic (in which case you might not be needing the import the classes directly), and would like to open direct connections to your database. Anyways for doing that I would recommend you to check out the readme doc that ships
    along with the jdbc oracle (classes12.zip etc). I am giving an excerpt over here:
    These are a few simple things that you should do in your JDBC program:
    1. Import the necessary JDBC classes in your programs that use JDBC.
    For example:
    import java.sql.*;
    import java.math.*;
    2. Register the Oracle driver before before calling other JDBC APIs.
    (This is not needed if you are using the JDBC Server-side Internal
    Driver because registration is done automatically in the server.)
    To register the Oracle driver, make sure the following statement
    is executed at least once in your Java session:
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    3. Open a connection to the database with the getConnection call.
    Different connection URLs should be used for different JDBC
    drivers. The following examples demonstrate the different URLs.
    For the JDBC OCI8 Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:oci8:@<database>",
    "scott", "tiger");
    where <database> is either an entry in tnsnames.ora or a SQL*net
    name-value pair.
    For the JDBC Thin Driver, or Server-side Thin Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:thin:@<database>",
    "scott", "tiger");
    where <database> is either a string of the form
    <host>:<port>:<sid> or a SQL*net name-value pair.
    For the JDBC Server-side Internal Driver:
    Connection conn = DriverManager.getConnection(
    "jdbc:oracle:kprb:");
    Note that the trailing ':' character is necessary. When you use
    the Server-side Internal Driver, you always connect to the
    database you are executing in. You can also do this:
    Connection conn
    = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    Hope this helps,
    Thanks,
    Anupama wrote:
    I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
    Please Advice!
    Thanks in advance
    AnuPama--
    Apurb Kumar

  • Connection Problem When Using Oracle Developer Tools for Visual Studio

    I tried to create an Oracle Connection in my Visual Studio 2008 after installing Oracle 11g, Oracle Data Access Components (ODAC) with Oracle Devleoper Tools for Vissual Studio version 11.1.0.6.20.
    I followed the directions according to "Building .NET Applications Using Oracle Developer Tools for Visual Studio, when I click Test Connection, I keep getting the error message below.
    Microsoft Visual Studio
    ORA-12170: TNS:Connect timeout occurred
    OK
    ---------------------------

    I solved the problem.
    This is what I did for the benefit of the embryonic newbe like me.
    On the Add Connection Dialog
    1.     For Data source name I selected Local Database
    2.     I clicked on the specific User Name and I typed SYSTEM
    3.     For Password, I typed orcl (the password I setup during the installation) (HR did not work for me for User name and Password according to the tutorial instructions)
    4.     For Role, I selected Default
    5.     Connection Name, I selected Local Database
    6.     Before proceeding any further went to Windows XP SP3 where I was operating from, under Start Menu, I selected Administrative Tools then Services
    a.     On the Windows Services (Local) Dialog, under name, I selected OracleServiceORCL and OracleOraDb11g_home1TNSListener. I clicked on them one at a time
    b.     On the presented Dialog, under Service Status, I Clicked on the Start Button to start the Services
    c.     Then I went back to the Add Connection Dialog. I clicked on Test Connection, it connected okay. I finally clicked on Okay to connect.

  • Why getting WebLogic Connection when using Oracle Driver?

    Does anyone know why I would be getting back an instance of weblogic.jdbc.rmi.SerialConnection
    when retrieving a connection out of the connection pool, via my JDBC TX DataSource,
    when my JDBC Connection pool is configured to use oracle.jdbc.OracleDriver. Seems
    that since I'm using the Oracle driver I should not be getting back this WebLogic
    connection.
    Any insight is appreciated :)
    thanks,
    Dan

    innumonenu wrote:
    Even we are facing the same problem of ClassCastException when we try to cast to
    OracleCallableStatement from the weblogic pool made of Oracle JDBC driver.
    What is the URL which explains,
    "Our wrappers do provide access to various non-standard
    Oracle methods, and we document how to cast (to our concret class or to an interface
    we define) in order to access these calls." as said by Joseph.http://e-docs.bea.com/wls/docs70/jdbc/thirdparty.html#1043705
    >
    >
    "Dan Branley" <[email protected]> wrote:
    Joseph,
    Thanks for the insight. This answers a lot of questions. I appreciate
    the thorough
    explanation. Your assumption is correct. I am trying to use an Oracle
    extension,
    specifically I need to call PreparedStatement.setBlob() passing an instance
    of
    an Oracle BLOB.empty_lob(). I'll take a look at the WLS documentation
    for an
    alternative.
    thanks,
    Dan Branley
    Joseph Weinstein <[email protected]> wrote:
    We never give application code direct access to pooled connections.We
    always
    supply a wrapper class. These wrapper classes have various extra functionality,
    such as cooperating under-the-covers with the transaction coordinator
    to provide
    EJB/UserTransaction transactional semantics/guarantees, regardless of
    the number
    of EJBs involved in a given transaction. For instance, when in an EJB/UserTransaction,
    our wrapper will cheerfully ignore if application code calls a Connection.commit().
    The
    application code has no idea really when the transaction is done and
    commitable, only
    the transaction coordinator does. Most simply, our pools guarantee that
    whatever
    application reserves a pool connection will have sole use of it until
    they close the connection
    to return it to the pool. If we allowed direct access to a pooled connection,
    one application
    could cache the reference, and re-use it later when we presumed to allow
    another user to
    use it from the pool. Some of our wrapper objects are RMI-enabled so
    they work in
    external client JVMs and will do JDBC over the wire to the weblogicserver
    and it's
    pool connections. This wayt application code need not change to work
    inside or
    outside weblogic.
    I suspect this question is because you want to use some of Oracle's
    non-standard
    extensions to JDBC. Our wrappers do provide access to various non-standard
    Oracle methods, and we document how to cast (to our concret class or
    to an interface we
    define) in order to access these calls. Not all calls can be successfully
    proxied by our wrappers
    because some Oracle methods (which claim to take java.sql object asarguments)
    actually
    require oracle specific classes, and reject our proxies, even if they
    are standard JDBC objects.
    Joe
    Dan Branley wrote:
    Does anyone know why I would be getting back an instance of weblogic.jdbc.rmi.SerialConnection
    when retrieving a connection out of the connection pool, via my JDBCTX DataSource,
    when my JDBC Connection pool is configured to use oracle.jdbc.OracleDriver.Seems
    that since I'm using the Oracle driver I should not be getting backthis WebLogic
    connection.
    Any insight is appreciated :)
    thanks,
    Dan

  • Oracle Text: How to add/get stopwords list when using Oracle Text world lexer?

    I have a use case that we currently use Oracle Text World Lexer to index and search multilingual documents. As we know that World Lexer does the language auto detection. I would like to know the following questions:
    Is there anyway I can get the current document's language that Oracle Text detected?
    Is there anyway to get the language's stopwords list?
    Any thoughts and points will be appreciated.
    - Charles

    1. If you're using 12c, you can use ctx_doc.policy_languages. (https://docs.oracle.com/database/121/CCREF/cdocpkg011.htm#CCREF24102)
    2. If you want multiple stoplists based on each document's language, you have to use the multi-lexer. For world_lexer, there is one stoplist; since the stoplists are somewhat dynamic (you can add but not remove them), the most accurate way to fetch the list is using ctx_report.describe_index or ctx_report.create_index_script and parse the report.

  • Legalities when using Oracle XE

    I am planning to host a web Application , for which i have used Oracle XE as the back-end.I would like to know what are the limitations with respect to the legalities involved using XE for commercial use.
    It would be great if you could also shed light on the limitations of Oracle XE in terms of Functionality .
    For now I know that it can be installed on single CPU , and can have 11gb of data(apart from the system data)

    Oracle XE can certainly be used for commercial purpose. But if you want to know the Legal Terms then this is not the place where people can share their own views. Contact Oracle Sales Team to get all the required information.

Maybe you are looking for