Using PL/SQL to retrieve column names and column values

If I have a table as follows
Table A(
meal varchar2(32),
beverage varchar2(32),
desert varchar2(32));
and the table contains a row
meal beverage desert
pork chops iced tea apple crisp
Is there a way in pl/sql to retrieve the column names along with the values. I have an object type
DATA_DEFINITION_T AS OBJECT (
          "FIELD_NAME"          VARCHAR2(32),
          "FIELD_VALUE" VARCHAR2(32)
I need to store the column name in field_name and the column value in field_value.
So the result would be:
FIELD_NAME = meal
FIELD_VALUE = pork_chops
FIELD_NAME = beverage
FIELD_VALUE = iced tea
FIELD_NAME = desert
FIELD_VALUE = apple crisp
Thanks in advance.

Hi,
try this procedure ....just create it and give the table name..the object M_DATA_TAB has the required data
procedure l_fill_data_dict(p_table_name varchar2) is
connection_id EXEC_SQL.CONNTYPE;
bIsConnected BOOLEAN;
cursorID EXEC_SQL.CURSTYPE;
nIgn PLS_INTEGER;
m_val VARCHAR2(40);
m_col_name varchar2(40);
m_col_val varchar2(240);
m_cnt number;
m_id number := 0;
m_incr number := 0;
p_sqlstr varchar2(4000);
p_sql_cnt varchar2(4000) ;
p_org_sql varchar2(4000);
TYPE DATA_DEFINITION_TABS IS RECORD (
FIELD_NAME VARCHAR2(32),
FIELD_VALUE VARCHAR2(240));
TYPE DATA_DEFINITION_TAB IS TABLE OF DATA_DEFINITION_TABS;
M_DATA_TAB DATA_DEFINITION_TAB := DATA_DEFINITION_TAB();
--m_file text_io.file_type;
Begin
--     m_file := text_io.fopen('c:\eg.txt','w');
     --Set default connection
connection_id := EXEC_SQL.DEFAULT_CONNECTION;
bIsConnected := EXEC_SQL.IS_CONNECTED;
IF bIsConnected = FALSE THEN
     message('Connection Failed');
RETURN;
END IF;
--Find the total no.of columns in the given table
p_sql_cnt := 'Select COUNT(column_name) from user_tab_columns where table_name='''||p_table_name||''' order by column_id';
cursorID := EXEC_SQL.OPEN_CURSOR;
EXEC_SQL.PARSE(cursorID, p_sql_cnt, exec_sql.V7);
EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_val,40);
nIgn := EXEC_SQL.EXECUTE(cursorID);
IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
     EXEC_SQL.COLUMN_VALUE(cursorID, 1, m_val);
end if;
EXEC_SQL.CLOSE_CURSOR(cursorID);
--EXEC_SQL.CLOSE_CONNECTION;
m_cnt := m_val;---column count
---get the column names from the user_Tab_columns and fetch the values from the given table for that column...
For i in 1..m_cnt loop
     m_id := m_id+1;
p_sqlstr := 'Select column_name from user_tab_columns where table_name='''||p_table_name||''' and column_id ='||m_id||' order by column_id';
cursorID := EXEC_SQL.OPEN_CURSOR;
EXEC_SQL.PARSE(cursorID, p_sqlstr, exec_sql.V7);
EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_col_name,40);
nIgn := EXEC_SQL.EXECUTE(cursorID);
IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
     EXEC_SQL.COLUMN_VALUE(cursorID, 1, m_col_name);
end if;
EXEC_SQL.CLOSE_CURSOR(cursorID);
--fetch the column value from the given table
     p_org_sql := 'select DISTINCT '||m_col_name||' from '||p_table_name;
     cursorID := EXEC_SQL.OPEN_CURSOR;
EXEC_SQL.PARSE(cursorID, p_org_sql, exec_sql.V7);
EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_col_val,240);
     nIgn := EXEC_SQL.EXECUTE(cursorID);
     Loop      
     nIgn := EXEC_SQL.FETCH_ROWS(cursorID);
          IF (nIgn > 0) THEN
               EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, m_col_val);
M_DATA_TAB.extend();
               M_DATA_TAB(M_DATA_TAB.last).field_name := m_col_name;
               M_DATA_TAB(M_DATA_TAB.last).FIELD_VALUE := m_col_val;
               m_incr := m_incr+1;
               -- text_io.put_line(m_file,m_col_name||'##'||m_col_val);
          else
               exit;
          End if;
     End loop;--loop of records in the table for the given column
EXEC_SQL.CLOSE_CURSOR(cursorID);
End loop; ---loop of columns in the table
--text_io.fclose(m_file);
message('Total no. of items in the object='||m_incr);
EXEC_SQL.CLOSE_CONNECTION;
EXCEPTION
When EXEC_SQL.Invalid_Connection then
     message('invalid connection');
     when EXEC_SQL.Package_Error     then
     message('pkg err');
     when EXEC_SQL.Invalid_Column_Number          then
     message('invalid col num defined');
     when others then
          MESSAGE(SQLERRM);
End;
Regards
Dora
Edited by: Dora on Sep 27, 2009 3:13 PM

Similar Messages

  • How to put the column name and variable value in the alert message.

    Dear,
    how can i put the column name and variable value in the alert message text. i want to display an alert which tell the user about the empty textboxes. that these textboxes must be filled.
    Regards:
    Muhammad Nadeem
    CHIMERA PVT. LTD.
    LAHORE
    [email protected]

    Hello,
    The name of the item that fires the current trigger is stored in the :SYSTEM.TRIGGER_ITEM system variable.
    The value contained in this item can be retrived with the Name_In() built-in
    value := Name_In( 'SYSTEM.TRIGGER_ITEM') ;
    LC$Msg := 'The item ' || :SYSTEM.TRIGGER_ITEM || ' must be entered' ;
    Set_Alert_Property('my_alert_box', ALERT_MESSAGE_TEXT, LC$Msg ) ;
    Ok := Show_Alert( 'my_alert_box' ) ;
    ...Francois

  • BAPI Structure populating using field name and field value frm internal tbl

    Hi Experts,
                     Need your help, my requirement is to populate BAPI import structure using its field name and filed value  stored in a internal table.  Please advise the best approach.
    Regards
    Ram.

    Hi, in an ABAP program you can make use of FIELD-SYMBOLS and the ASSIGN statement for filling the BAPI fields based on the fieldname found in the internal table. Hopes it answer your question. Succes

  • Query parameters with the same name and different values

    According to HTTP, multiple query or post parameters with the
    same name and different values are permitted. They are transfered
    over the wire in the following format -
    name1=val1&name1=val2&name1=val3
    The problem is that I can't see anyway of assigning multiple
    parameters with the same name and different values to the request
    object of mx.rpc.http.HTTPService. I have tried using the
    flash.utils.Dictionary object as it does strict key comparison but
    that doesn't work too. I have tried setting an array of values to a
    property of the request object but that sends the request to the
    server in the following format -
    name1=val1,val2,val3
    The java servlet engines throw exceptions when they see this.
    Any help would be greatly appreciated.

    If you're not on 8.1.4 move there. 8.1.3 had limitations in the wsrp
    release.
    wrote:
    I have an html select box that contains several values, and multiple
    selection is enabled. When my code runs as a remote portlet, the
    following is showing up in the soap monitor when I select multiple
    values and submit the form:
    <urn:interactionParams>
    <urn:portletStateChange>cloneBeforeWrite</urn:portletStateChange>
    <urn:interactionState>_action=addEmployeesToGroup</urn:interactionState>
    <urn:formParameters
    name="P62005wlw-select_key:{actionForm.selectedEmployees}OldValue">
    <urn:value>true</urn:value>
    </urn:formParameters>
    <urn:formParameters
    name="P62005wlw-select_key:{actionForm.selectedEmployees}">
    <urn:value>beatest1</urn:value>
    </urn:formParameters>
    In this case, I selected beatest1 and beatest2, but only beatest1 comes
    through to the remote portlet. Is this a known bug, and, if so, is
    there a patch or workaround available?
    Thanks in advance,
    Andy

  • Srvrmgr syntax: how can I create Named Subsystem with both Name and Description values?

    In looking through bookshelf, there is no syntax discussed that allows you to include both the Name value and the Description value for a Named Subsystem/Profile Configuration.  In the screenshot, the circled values were created with the server manager command-line.
    In contrast, you can create a component definition with a Name (full name) and Description.
    For CompDef, this works:
    create component definition CompDefTest1_enu for component type AppObjMgr component group Fins run mode Interactive full name "Test Comp Def Test 1" description "Test 1 Object Manager CompDef"
    For Named Subsytem, this does NOT work:
    create named subsystem Test5 for subsystem EAITransportDataHandlingSubsys full name "Test 5" description 'Test 5 Description'
    Can anyone tell me if, for a Named Subsytem, there is a proper syntax to include both the Name and Description values in the command-line, or is the only way to manually create it in the UI?

    Hi,
    I have reviewed the help for create command in srvrmgr, it does not give the full name and description as parameters for subsystem creation. However, as you indicated these parameters are available for component definition creation:
    srvrmgr> help create
      create { component group | compgrp } <component group name>
           [ full name <descriptive name> ]
           [ { description | desc } <description of component group> ]
      create { component definition | compdef } <component definition name>
           for { component type | comptype } <component type name>
               { component group | compgrp } <component group name>
           run mode { batch | interactive | background }
           [ full name <descriptive name> ]
           [ { description | desc } <description of component definition> ]
           [ with [param <param_name>=<value>[, <param_name>=<value>...]]
                  [fixparam <fixed_param_name>=<fixed_value>[,...]]]
      create named subsystem <named_subsystem_name> for
           subsystem <subsystem_name> with <param_name>=<param_value> [, ..]
    Bookshelf also has an example of subsystem creation that does not include full name and description:
    http://docs.oracle.com/cd/E14004_01/books/StoreFwdMsg/StoreFwdMsg_InstallConfig14.html#wp1351472
    In this case I suggest you to create a ticket on My Oracle Support to confirm that srvrmgr does not support creating a new subsystem with full name and description parameters, and request an enhancement request for these parameters to be included in create statement for new subsystems when using srvrmgr.
    Hope it helps,
    WSiebel

  • Using a SQL Query in an Alert and Matching a String

    I've created an alert in 12.0.4 using a SQL Query and the field that I'm trying to match is a string.  Originally the query returned multiple rows but when the alert still didn't fire, I modified the query WHERE clause to return only one row:
    NAME                                RESPONSE
    Are area lights working?            No
    My expression in the metric is RESPONSE.  In the Monitor I'm matching a string equal to No.  (Do I need double quotes around the matchvalue?  Single quotes?  No quotes?)  The metric is in the 15min scan group, the role is xMII Developers and I'm in that role. The monitor alert string is ' =  '.  Both metric and monitor are active and I've subscribed to the monitor.  Other alerts in the 15min scan group (all based on tag queries) are firing off properly.
    Why is nothing showing up in the Alert Log?
    David Macindoe

    David,
    Did you figure out the answer?  If not, I will try to find someone to address your question.
    Mike

  • Retrieving column value from multiselect managed metadata column and updating metadat column in list.

    I have Library having metadata column when a document is uploaded i need update another list with metadata column of
    library in list.I have an event reciever to do that,Code is given below
    public override void ItemUpdated(SPItemEventProperties properties)
                base.ItemUpdated(properties);
                    SPList saList = properties.Web.Lists["mylist"];
                    SPListItem item = saList.AddItem();
                    item["Department"] = properties.ListItem["Department"].ToString();
                    EventFiringEnabled = false;
                    item.Update();
                    EventFiringEnabled = true;   
    my elements.xml file is as below
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Receivers ListUrl="Documents">
          <Receiver>
            <Name>DocumentItemUpdated</Name>
            <Type> ItemUpdated</Type>
            <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
            <Class>MyDocuments.Documents.Documents</Class>
            <SequenceNumber>10000</SequenceNumber>
          </Receiver>
      </Receivers>
    </Elements>
    but i did not see the the List column getting updated.But when i use the code to update a column of single line of text
    it works fine.But when i do it for multi select metadata column in debug mode i could see its giving null value even though Library had column value.
    Any pointers on how to update Multiselect metadata column programatically on itemeadding event in library to a list will
    be helpful.

    You need to use the TaxonomyFieldValueCollection class. The following code is from SP2010 but should still apply in SP2013. It is an example of updating multivalued taxonomy fields.
    public static void SetListItemMultiMetaDataColumn(Int32 id)
    using (SPSite site = new SPSite("http://basesmc2008"))
    using (SPWeb web = site.OpenWeb())
    TermSet termSet = null;
    TaxonomySession txs = new TaxonomySession(site);
    SPList list = web.Lists["Shared Documents"] as SPList;
    SPListItem item = list.GetItemById(id);
    TaxonomyField field = item.Fields["multimanage"] as TaxonomyField;
    if (field != null)
    termSet = txs.DefaultSiteCollectionTermStore.GetTermSet(field.TermSetId);
    Term term = termSet.GetTerms("sts", false).FirstOrDefault();
    if (field.AllowMultipleValues)
    TaxonomyFieldValueCollection currentCollection = item[field.Id] as TaxonomyFieldValueCollection;
    TaxonomyFieldValue tfv = new TaxonomyFieldValue(field);
    tfv.TermGuid = term.Id.ToString();
    tfv.Label = term.GetPath();
    tfv.WssId = TaxonomyField.GetWssIdsOfTerm(site, txs.DefaultSiteCollectionTermStore.Id, termSet.Id, term.Id, false, 1).First();
    currentCollection.Add(tfv);
    field.SetFieldValue(item, currentCollection);
    item.Update();
    Blog |SharePoint Field Notes Dev Tool |
    SPFastDeploy

  • Please Help - SQL Report long column value required in a separate cell

    Hi.
    I need to create a SQL report with the structure like below:
    Country State City Vertical Business Details (detail desc)
    US MA Quincy Healthcare
    This is a detail desc value that needs to displayed in a different cell.
    This is a detail desc value that needs to displayed in a different cell.
    This is a detail desc value that needs to displayed in a different cell.
    This is a detail desc value that needs to displayed in a different cell.
    US MA Braintree IT
    This is a detail desc value that needs to displayed in a different cell.
    This is a detail desc value that needs to displayed in a different cell.
    This is a detail desc value that needs to displayed in a different cell.
    I came through a solution where you can hide/display the long column value in a different cell. But my requirement is that it should be displayed when the page opens and user don;t want to click on a button to see the value. This is mainly for their presentations and printing. so its very annoying for them to click on so many buttons to see the detail desc value for every record. I am new to Java script, Please help

    I'm not sure I understand your requirements--are you showing us 2 lines of data, 7 lines, or 9? Do you want the long detail description on the same row, or underneath it?
    I'm going to go on the assumption that you're showing us two rows, and that the long descriptions in this example happen to be 3-4 lines long, and that you want the long descriptions underneath the details. In which case, I suggest using "named column" templates. They're a lot easier to use than they appear when you first look at them, so bear with me.
    Under "Shared Components", select "Templates", and then click on the yellow Create> button. You're creating a report template, from scratch. On the final page of the wizard, select "Named Column (row template)" for the template type. This will create a rather generic (and useless) template, which you'll have to edit; I don't know why they chose to not send you straight into the editor. When you edit it, you'll see that the only field with a value in it is "Row Template 1", and it's set to:
    <tr><td>#1#</td><td>#2#</td><td>#3#</td><td>#4#</td><td>#5#</td></tr>For meeting your requirements with basic functionality, change it to something along the lines of:
    <tr><td>#COUNTRY#</td><td>#STATE#</td><td>#CITY#</td><td>#VERT#</td></tr>
    <tr><td colspan="4">#DETAILS#</td></tr>Then you'll probably want to put something under Column Heading Template, like:
    <tr><td>Country</td><td>State</td><td>City</td><td>Vertical Business</td></tr>
    <tr><td colspan="4">Details</td></tr>Apply whatever CSS styles you want to it, of course.
    Using the template is straightforward: if your report, chose the template, and make sure your SQL returns values using the column names you specified in your template. Otherwise, you'll see literal "#COUNTRY#" text in your report.
    You can get fancy with these, of course, such as applying different styles to alternating rows, but I'll leave this as good enough to get you started (I hope).
    -David

  • SQL Developer - Pulling column value from previous row

    I am using Oracle SQL developer and trying to pull a value from a column from the previous row.
    Currently this is an example from the code im using.
    Select CD1.nbr_dw, CD1.SEQ_DW, CD1.CDL_NET_PAID, CD1.UNITS_ALLOW,CD1.ALLOW_AMT, CD1.UNIT_PRICE, CD1.BACKED_OUT,
    case
    When CD1.NET_PAID = 0 then 0
    ****NEW CODE*****
    Else CD1.ALLOW_AMT / CD1.UNIT_PRICE
    end as NEW_UNITS
    From Table_A CD1
    join (Select nbr_dw, DET_DW, SEQ_DW
    From Table_B
    ) CD2
    on CD1.nbr_dw = CD2.nbr_dw
    I need to add another when statement that says when CD1.BACKED_OUT = 'Y' populated the NEW_UNITS field with the previous rows value of CD1.UNIT_PRICE. Note, the CD1.SEQ_DW can be used to determine the previous row. Any ideas?

    Hi,
    Welcome to the forum!
    The analytic LAG function can return a value from the previous row:
    LAG (cd1.unit_price) OVER ( -- PARTITION BY  x          -- if needed
                                   ORDER BY          cd1.seq_dw
                     )It's unclear if you need a PARTITION BY clause or not.
    "PARTITION BY x" means that you want the value from the last row that has the same value of x as the current row.
    If you omit the PARTITION BY clause, it means you want the last row regardless of what any other columns are.
    Whenever you have a problem, it ehlps if you post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
    Explain how you get those results from that data.
    Always say what version of Oracle you're using.

  • HR - dynamic selections field name and field value in the program

    HI all,
       I am using dynamic selections for a HR report.
    I have created a view with 20 fields and added it to HR report category ___00003(All fields suppressed).
    I need to check these fields in the program. But i am not able to get the field name and value in the program for dynamic selections fields.
    Please let me know how to get the field names and values in the program for dynamic selections .
    Thanks,
    Kranthi.

    You have to read the itab <i>pnpdynse</i> in your Program to obtain the Dynamic Selection values. This itab has a deep structure.. you can set a break point in one of the events before <b>get pernr</b> & in the debug mode, you will able to display the itab <i>pnpdynse</i>.. you can then identify how to get the values into your code..
    ~Suresh

  • SQL Loader - adding column values

    Hi everybody,
    Is it possible to have a column value in SQL Loader control file that is a function of two other columns. For example I have table of 3 columns c1, c2, c3
    and data file is having c1, c2 and I want to specify c3 as c1+c2 in the control file, so that it's populated in the table while loading data file. I tried this on date column but it gave me error ora-00981.
    Can you tell me exact sysntax if possible.

    LOAD DATA
    INFILE 'C:\SQLLOADER\AREA.TXT'
    APPEND INTO TABLE AREA
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    (c1,
    c2,
    c3 ":c2+:c1"
    kuljeet pal singh

  • How to obtain a variable Server Account Name using an @SQl with an @variable_server_ name + 'master.dbo.xp.instance.regread ...'

    Hi,
    I am trying to make a flexible script to get the Service Account Name from several servers.
    I am using "servername.master.dbo.xp_instance_regread.......", but I want to use a variable for the servername.
    So I started doing this:
    Declare @servername varchar(100)
    Declare @SQL varchar(1000)
    Declare @agtServAccName varchar(250)
    set @servername = 'Server1'
    set @sql = @servername + '.master.dbo.xp_instance_regread
    N''HKEY_LOCAL_MACHINE'',
    N""SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT'',
    N''ObjectName'',
    @AgtServAccName Output,
    N''no_output'''
    Execute (@SQL) 
    How am I able to get a flexible script (@sql), which gives me the Service Account Name of the server called @servername after I execute this script (@sql)
    If there is another way without this regread, I like to hear that too ofcourse...
    EDIT: the reason I use a variable for the servicename is, that I am running it on a central management server and not on the server with this servername itself.

    This did the trick. Now I can loop through all my centrally managed servers and obtain the Service Account Names.
    Thanks for the help. There's probably a better way to do it (sp_executesql?) , but at least I got something.
    Declare @ServerName varchar(50)
    Declare @SQL as varchar(500)
    If object_id('tempdb..#ServAccName') is not null
    drop table #ServAccName;
    create table #ServAccName (ServAccName varchar(50))
    set @ServerName = 'Server1'
    set @SQL = '
    declare @ServAccName varchar(50)
      execute ' + @ServerName + '.master.dbo.xp_instance_regread
                       HKEY_LOCAL_MACHINE,
                       ''SYSTEM\CurrentControlSet\Services\MSSQLServer'',
                      ObjectName,
                      @ServAccName OUTPUT
    Insert #ServAccName Select @ServAccName
    Exec (@SQL)
    Select ServAccName from #ServAccName

  • Using PL/SQL Function with CLOB types and a Java Source

    Hi people.
    I have some problems trying to use a function in pl/sql with a CLOB parameter to a java source function.
    Here is the problem: I have to read a TXT file and return a CLOB with the data of the file. The reading is done with a java source function.
    The problem is how to read the file without messing the content and return it to the pl/sql function?
    Another problem: If I pass a CLOB as a parameter to a pl/sql function and have to write the content to a file, how to do it without screwing the EOL chars and so?
    My code is:
    /******** PLSQL FUNCTIONS ********/
    function fn_gravaconteudoarquivo( pv_caminho in varchar2
    , pv_nomearquivo in varchar2
    , pc_conteudo in clob ) return varchar2 as language java
    name 'Importacao.gravaConteudoArquivo(java.lang.String, java.lang.String, oracle.sql.CLOB) return varchar2';
    function fn_lerconteudoarquivoclob( pv_caminho in varchar2
    , pv_nomearquivo in varchar2 ) return clob as language java
    name 'Importacao.lerArquivoClob(java.lang.String, java.lang.String) return clob';
    /******** JAVA SOURCE FUNCTIONS *********/
    public static String gravaConteudoArquivo(String caminho, String nomeArquivo, CLOB conteudo) {
    File file = new File(caminho, nomeArquivo);
    PrintWriter pwFile;
    String mensagem = "";
    StringBuffer sb = new StringBuffer();
    try {
    pwFile = new PrintWriter(new BufferedWriter(new FileWriter(file,true)));
    for (int i=0;i<=(conteudo.length()/32000);i++) {
    sb.append(conteudo.getSubString(conteudo.getLength()+1,32000));
    pwFile.println(sb.substring(0));
    pwFile.close();
    } catch (Exception ex) {
    mensagem = "Erro: "+ex;
    return mensagem;
    public static CLOB lerArquivoClob(String caminho, String nomeArquivo) throws SQLException {
    File file = new File(caminho, nomeArquivo);
    Connection conn;
    CLOB clob = null;
    String lineSep = System.getProperty("line.separator");
    StringBuffer sb = new StringBuffer();
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:csdesv", "csestoque", "liberada");
    clob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    BufferedReader brFile = new BufferedReader(new FileReader(file.getPath()));
    while (brFile.ready()) {
    sb.append(brFile.readLine());
    sb.append(lineSep);
    clob.open(CLOB.MODE_READWRITE);
    clob.setString(clob.getLength()+1, sb.toString());
    clob.close();
    } catch (Exception ex) {
    ex.printStackTrace();
    return clob;
    Ah, just remembered... This will work as a JOB.... >.< ... So the connection aparently is at localhost.
    Thanks.

    No one? I really need this....

  • Using slugs on database for categories names and others

    Hello,
    I have the following SQL Categories table:
        create table dbo.Categories (
          Id int not null primary key clustered (Id),
          Name nvarchar (40) not null
            constraint UQ_Genders_Name unique (Name)
    On an ASP.NET MVC application I need to display products by category but I would like the url to be meaningful, something like:
        http://mydomain.com/books-and-magazines
    So I suppose I need a slug field in my database. But should the slug be unique?
    On the MVC application I could also use the following url:
        http://mydomain.com/2/books-and-magazines
    Where 2 is the id of the category and now I would look by id ...
    Or should I create a slug which would be equal to "name converted to slug" + id so:
        http://example.com/books-and-magazines-2
    How is this usually done on the MVC side and on the SQL side?
    And if a name changes should I change the slug?
    Is there a way to generate the slug on the database?
    Thank You,
    Miguel

    It is possible to display 
    CatergoryID,  url
    1                   http://mydomain.com/books-and-magazines
    2                    http://mydomain.com/books-and-magazines_something
    else
    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

  • SQL to retrieve faulted instances and fault reason code for SOA composites

    Hi,
    Could you please provide me some SQL which will retrieve composite faults with details on a particular period?
    Thanks in advance.

    SELECT ID, COMPOSITE_DN, STATE, CREATED_TIME FROM COMPOSITE_INSTANCE. You can add filters for created_time and state. Refer to this link for a list of composite states. https://blogs.oracle.com/dasoa/entry/list_of_all_states_from

Maybe you are looking for

  • Adobe TV not working on Macbook Pro

    Hi I need a solution for a unique problem that I am facing on a Apple Macbook pro I have the latest Flash Player installed on my machine All the flash content can be viewed on my machine However when I am trying to access www.tv.adobe.com The videos

  • How to track the person who has stolen my macbook pro.

    I have lost my mac recently. but just now i have received email thru my another device showing that the thief has been tried to ask the question in apple support community. He asked about how to access new operating system because it can't be open by

  • Same invoice number for two delivery documents

    Dear Folks, We are having the following business flow: Contract- S.O.- Del- PGI- PI- Excise Invoice- Commercial Invoice Now The system is generating the same commercial invoice number for two delivery documents. 1.The two deliveries have 40 and 50 MT

  • R/3-MDM-XI Scenaio!

    Hi All, Can anyone send me some Business scenarios of R/3-MDM-XI to my mail: <b>[email protected]</b> Thanks and appreciate all your help! Best Regards, Girish

  • What is the tracking ID for checking the status of a sent text message??

    i don't know what the tracking ID is for checking the status of a sent text message...