How to insert column values into database as rows
Hi,
I have 8 columns and some not null columns. Based on not null columns I want to insert into table as rows. The 8 columns may contain values or no value. If the first column contains data, then I have to insert into one row. if the second column contains data I have to insert a row and in second column. respectively...So How can I insert column values into rows. Can I write 8 insert statements. (OR) is it possible to insert data from columns using where clause.
Please help me out....
Thanks in Advance
Lines Table:
line_id, orcl_bank_account_num, product_type, service_type, lease_type,
funding_type, cpi, billing_frequency_unit_cd , annual_due_date ,
pricing_start_date, pricing_end_date, install_date, contract_end_date ,
prdct_replacement_cost_amt, cradle_replacement_amt, supranet_contract,
issuance_fee, board_inactive_date, header_id, creation_date, last_modified_date,
created_by_nam, modified_by_nam, activeinactive_flg, prdct_bill_amt_yr1,
prdct_bill_amt_yr2, prdct_bill_amt_yr3, prdct_bill_amt_yr4, prdct_bill_amt_yr5,
prdct_bill_amt_yr6, prdct_bill_amt_yr7, prdct_bill_amt_yr8, activation_fee_yr1,
activation_fee_yr2, activation_fee_yr3, activation_fee_yr4, activation_fee_yr5,
activation_fee_yr6, activation_fee_yr7, activation_fee_yr8,
In this table the columns structure is :
-- PRDCT_BILL_AMT_YR (1 to 8) NUMBER(14,4)
-- ACTIVATION_FEE_YR (1 to 8) NUMBER(8,2)
I have one more table:
PRDCT_INS_AMT NUMBER(14,4)
ACTIVATION_FEE_AMT NUMBER(14,4)
I want to insert prdct_bill_amt_yr (1 to 8) columns data into PRDCT_INS_AMT column. similarly activation_fee (1 to 8) columns data.
But the data should be inserted based product_type, service_type, lease_type columns values. (These 3 columns may contain upto 45 combinations).
Similar Messages
-
How to insert a value into a field of binary type?
I've been using Oracle for a while now but never dealt with BLOB
or long raw type before. Does anyone here know how to insert a
record into a field of either blob or long raw type?
Any suggestions would be very appreicated.
Thanks.pls used the loadfromfile procedure which is in the DBMS_LOB
package to insert the data from external os file into blob data
type column.
Kunjan -
How to import column values into SharePoint 2013 Term Store Using Powershell(CSOM)
Hi,
I do have SharePoint 2013 list with more than 500 items in it.Now I am trying to import column values into SharePoint 2013 Term Set A using Powershell scripts.
I am new to Powershell(csom) and can anybody help me out to accomplish this task?
Any help would be greately appreciated.
Thank you,
AA.
AA.Hi
check this doc
http://wellytonian.com/2012/10/sharepoint-2010-2013-term-store-importer-using-csv/
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you. -
How to insert parameter value into multiple columns and rows
Hi All,
I have one procedure insert_tab and I am passing
100~101~102:103~104~105:106~107~108 as a parameter to that procedure. I wanted to insert each numeric value into one column. The output of the table should contain
Table:
Col1 Col2 Col3
100 101 102
103 104 105
106 107 108
Awaiting for your reply..That's not more clear for me...
Anyway, if you really want a procedure for that, try :
SQL> create table tblstr (col1 number,col2 number,col3 number);
Table created.
SQL>
SQL> create or replace procedure insert_fct (p_string IN varchar2)
2 as
3 v_string varchar2(4000):=p_string||':';
4 v_substring varchar2(4000);
5
6 begin
7 while instr(v_string,':') > 0 loop
8 v_substring := substr(v_string,1,instr(v_string,':')-1)||'~';
9 insert into tblstr(col1,col2,col3)
10 values (substr(v_substring,1,instr(v_substring,'~',1,1)-1),
11 substr(v_substring,instr(v_substring,'~',1,1)+1,instr(v_substring,'~',1,2)-instr(v_substring,'~',1,1)-1),
12 substr(v_substring,instr(v_substring,'~',1,2)+1,instr(v_substring,'~',1,3)-instr(v_substring,'~',1,2)-1));
13 v_string:=substr(v_string,instr(v_string,':')+1);
14 end loop;
15 end;
16 /
Procedure created.
SQL>
SQL> show err
No errors.
SQL>
SQL> select * from tblstr;
no rows selected
SQL> exec insert_fct('100~101~102:103~104~105:106~107~108')
PL/SQL procedure successfully completed.
SQL> select * from tblstr;
COL1 COL2 COL3
100 101 102
103 104 105
106 107 108
SQL> exec insert_fct('109~~')
PL/SQL procedure successfully completed.
SQL> exec insert_fct('~110~')
PL/SQL procedure successfully completed.
SQL> exec insert_fct('~~111')
PL/SQL procedure successfully completed.
SQL> select * from tblstr;
COL1 COL2 COL3
100 101 102
103 104 105
106 107 108
109
110
111
6 rows selected.
SQL> Nicolas. -
How to get column value of a selected row of ALV
Hello ,
I have application POWL POWL_UI_COMP uses another component POWL_TABLE_COMP.
This POWL_TABLE_COMP uses SALV_WD_TABLE.
I want to select value of ORDER id and it need to be passed whenever user selects a display order button(Which is self defined function generated in POWL_TABLE_COMP) . I am calling a display order on action of this display button(http://nap60.nalco.one.net:8042/sap/bc/webdynpro/sap/mt_order_app?IV_ACTIVITYTYPE=A&IV_EQUIPMENT=aaaa&IV_ORDERID=90001511&IV_ORDERTYPE=STD&IV_QMNUM=00&IV_TPLNR=00)
ORDERID is one column value of selected row of ALV table.
So please can you suggest , how to read ORDERID and pass it to the self defined function..
thanks in advance,
SharadaAnoop,
I have plcaed this code in event handler of on_lead_select.
Its giving error the element doesnt exist.
static_attributes should give me row data but it's giving short dump saying
Pl can you suggest.
data: set_of_element type WDR_CONTEXT_ELEMENT_SET,
element1 type ref to IF_WD_CONTEXT_ELEMENT,
result type POWL_CRESULT_STY,
table_helper type ref to CL_POWL_TABLE_HELPER,
context_node type ref to IF_WD_CONTEXT_NODE,
lt_selected_elements TYPE wdr_context_element_set,
static_attributes type ref to data.
table_helper = wd_comp_controller->mr_table_helper.
context_node = table_helper->get_data_node( ).
context_node = wd_comp_controller->mr_table_helper->get_data_node( ).
context_node->get_static_attributes( exporting index = r_param->index
importing static_attributes = static_attributes ).
thanks,
Sharada -
How to insert a value into a table
I have an ordering system. It displays all the orders by
customer ID. If an order is complete, a check number is entered for
the corresponding line item, otherwise it is left blank.
My code uses the following code to display the form. All are
display fields only, except for the last one, where the check
number can be entered.
<cfoutput query="qryDetail" group="partNumber">
<tr>
<td valign="top" class="TitleText"
align="center">#lineItem#</td>
<td valign="top" class="TitleText"
align="center">#OrderNumber#</td>
<td valign="top" class="TitleText"
align="center">#partNumber#</td>
<td valign="top" class="TitleText"
align="center">#dollarformat(qryDetail.unitValue)#</td>
<td valign="top" class="TitleText" align="center">
<cfinput type="text" name="checkNumber#keyID#">
<input type="hidden" name="keyID"
value="#qryDetail.keyID#">
</td>
I use something like the following to update the table with
the check numbers entered.
<cfloop index="KeyID" list="#form.KeyID#"
delimiters=",">
<cfquery name="qryUpdate" datasource="dbName">
update tblChecks
set checkNumber = '#Evaluate("form.checkNumber#KeyID#")#'
where custID = '#form.custID#'
and KeyID = '#KeyID#'
</cfquery>
</cfloop>
Now we have another table that will contain the customer
order history. If the check number was entered for a particular
line item, I need to insert that line item nubmer into this table,
along with some other columns. I tried to use the same loop, then
other loops, but cannot seem to get this to work. Seems simple
enough, but I obvisouly am missing something.
How would I insert the line item number (only if a check
number was entered for that line item) into the table ?Here is the code with the queries commented out :
<cfloop list="#form.fieldnames#" index="field">
<cfif left(field, 11) is "checkNumber" AND
len(trim(form[field]))>
<cfset keyID = listlast(field, '_')>
<cfset lineItem = listgetat(field, 2, '_')>
<cfset checknum = form[field]>
<!---cfquery name="qryUpdate" datasource="dbName">
UPDATE tblChecks
SET checkNumber = '#checknum#'
WHERE custID = #form.custID#
AND KeyID = #keyid#
</cfquery--->
<cfoutput> loop is
field: <b>#field#</b><br>
checknum: #checknum#<br>
lineitem: #lineitem#<br>
keyID: #keyID#<br>
</cfoutput>
<cfelse>
<cfoutput>Else is
field: <b>#field#</b><br>
form[field]: #form[field]#<br>
len: #len(trim(form[field]))#<br>
</cfoutput><cfabort>
</cfif>
</cfloop>
This is the output. If I do not put in cfabort, the code just
drops thru and I never see any output display, so I use cfabort to
stop so I can see the output.
loop is field: CHECKNUMBER_11_218
CHECKNum: xxxxxxxxxxxxxxxxxxxx
lineitem: 11
keyID: 218
Else is field: CHECKNUMBER_1_24
form[field]:
I entered the x's into checknum for line item 11, so that is
correct.
I then took out the comments from the update query and tried
it again and it updated for line item 11 (you were right, I had to
take out the single quotes in the query). I then removed the
commets for the insert query and it did not insert. I tried the
whole thing again and tried to add to line item 10 and it dropped
straight to the else part, displaying :
Else is field: CHECKNUMBER_1_24
form[field]:
len: 0
So it seems the if statement if failing the second time thru
the loop :
<cfif left(field, 11) is "checkNumber" AND
len(trim(form[field]))>
This is my input statement :
<cfinput type="text"
name="checkNumber_#lineItem#_#keyID#">
I am really confused now. It seems to work the first time
thru the loop, then the second time it fails. -
How to insert date value into oracle?
hi,
iam reading date from xml using vb.net and inserting it into oracle table.
the date value in xml file is in the format of "01012003".
i want to insert into oracle table.but iam getting an error "ORA-1843: not a valid month".
how to solve this problem.
Any suggestions or examples...That's not a date. It's just a string. Convert it to a date using,
DateTime d = DateTime.ParseExact("01022003", "MMddyyyy", null);
or
Dim d As DateTime = DateTime.ParseExact("01022003", "MMddyyyy", Nothing)
and then bind it to a parameter. ODP.NET will take it from there.
You should never be hard-coding the date literal into your SQL query.
David -
Sqlloader: how to insert -ve value into table
hi..
i had problem during loading. The error is Record 1: Rejected - Error on table FILE01, column AMOUNT.
ORA-01722: invalid number
For AMOUNT, the datatype is number(20,2).
here is my .ctl
LOAD DATA
INFILE 'file1bp0103.txt'
BADFILE 'file01.bad'
APPEND
INTO TABLE file01
acct_no POSITION(01:13),
amount POSITION(14:28),
description POSITION(29:32)
my .dat file
A500000030401- 32.74PYMT
A500000320106- 46.95PYMT
A500000520408- 63.95PYMT
A500000610301- 12.99PYMT
A500001720110- 56.21PYMT
A500001800103- 55.65PYMT
A500002000109- 27.25PYMT
A500002000305- 53.35PYMT
A500002080210- 75.04PYMT
A500002250106- 103.38PYMT
A500002500104- 60.69PYMT
A500002620902- 509.77PYMT
A500002621010- 398.69PYMT
what is the problem? is it because of my datatype?
please help me..
TQIs there a need to use dynamic sql here?
at the very least, try using bind variables instead of concatenating values like that.
EXECUTE IMMEDIATE 'insert into your_table (column_list) values (:val1, :val2, ...)'
USING l_val1, l_val2, l_val3 ... ; -
How to insert object values into table.
Hi All,
I have a problem with passing java object to procedure. Procedure is running properly when I execute in oracle,but it is not executing when I call from Java.
I am getting Error :
java.sql.SQLException: invalid name pattern: Pkg_Bulk_Insert.ITW_EMP_OBJ_ARRAY
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.oracore.OracleTypeADT.initMetadata(OracleTypeADT.java)
at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java)
at oracle.sql.ArrayDescriptor.initPickler(ArrayDescriptor.java)
at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java)
at JavaObjectToOracle.main(JavaObjectToOracle.java:31)
Here I am copying my procedure,oracle version is 9i.
Package specification:
CREATE OR REPLACE PACKAGE Pkg_Bulk_Insert AS
TYPE ITW_EMP_OBJ_ARRAY IS VARRAY(20) OF VARCHAR2(200);
PROCEDURE BULK_INSERT_TEST(strTable IN ITW_EMP_OBJ_ARRAY);
END Pkg_Bulk_Insert;
package body:
CREATE OR REPLACE PACKAGE BODY Pkg_Bulk_Insert AS
PROCEDURE BULK_INSERT_TEST(strTable IN ITW_EMP_OBJ_ARRAY) AS
i BINARY_INTEGER;
BEGIN
FORALL i IN 1..strTable.COUNT
INSERT INTO TEMP(NAME)
VALUES(strTable(i));
COMMIT;
END BULK_INSERT_TEST;
END Pkg_Bulk_Insert;
Here I am invoking the procedure:
DECLARE
x Pkg_Bulk_Insert.ITW_EMP_OBJ_ARRAY;
BEGIN
x := Pkg_Bulk_Insert.ITW_EMP_OBJ_ARRAY('A','B','C');
Pkg_Bulk_Insert.BULK_INSERT_TEST(x);
DBMS_OUTPUT.PUT_LINE('AFTER INSERTION');
END;
Please any body can help me on this regard.Your PL/SQL seems reasonable.
My suspicion would be that the oracle.sql.ArrayDescriptor.createDescriptor class only supports persistent collection types, i.e. those declared at the schema level with CREATE TYPE. -
How get grid column value into textfield
hi master
sir i have one grid thad bound table and one texttield
i want when my user click in grid column then that row value move to textfiled
i use this code
RowKey rowkey = tableRowGroup1.getRowKey();
tt.setValue(chartofaccDataProvider.getValue("chartofacc.accid",rowkey ));
but this code give me error
please give me ideasir when i click the any record it is give me this error
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: java.lang.IllegalArgumentException
chartofacc.accid
Possible Source of Error:
Class Name: com.sun.data.provider.impl.CachedRowSetDataProvider
File Name: CachedRowSetDataProvider.java
Method Name: getFieldKeyInternal
Line Number: 481
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
Stack Trace:
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeyInternal(CachedRowSetDataProvider.java:481)
com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKey(CachedRowSetDataProvider.java:439)
com.sun.data.provider.impl.AbstractTableDataProvider.getValue(AbstractTableDataProvider.java:126)
iqra.Page1.hyperlink1_action(Page1.java:462)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
javax.faces.component.UICommand.broadcast(UICommand.java:312)
com.sun.rave.web.ui.component.TableRowGroup.broadcast(TableRowGroup.java:1611)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
java.security.AccessController.doPrivileged(AccessController.java:-2)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
java.security.AccessController.doPrivileged(AccessController.java:-2)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Exception Details: javax.faces.el.EvaluationException
java.lang.IllegalArgumentException: chartofacc.accid
Possible Source of Error:
Class Name: com.sun.faces.el.MethodBindingImpl
File Name: MethodBindingImpl.java
Method Name: invoke
Line Number: 130
please give me idea how i get value of column
thank
aamir -
How to insert new value into an array
I have an already declared array (including the size) and want to write a method for inserting a new value. Do I have to re-declare the array to the new size? ie old size + 1, then add the new value or is there a java method for this. I can't find one.
Thanks in advance....
MikeHi,
there is no method for that. Look up class Vector. That class implements automatic growing of the Vector.
Phil -
Inserting new records into database table at runtime
Hi all ,
How to insert new records into database table at runtime on click update?
Thanks.Hi Sasikala,
Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
1) Obtain the reference of your context node.
2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
3) Use your normal ABAP logic to update the database table with the data from your internal table
In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
data: node_sflight type ref to if_wd_context_node,
elem_sflight type ref to if_wd_context_element,
lt_elements type WDR_CONTEXT_ELEMENT_SET,
stru_sflight type if_main=>element_sflight_node,
it_flights type if_main=>elements_sflight_node.
" navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE' ).
lt_elements = node_sflight->get_elements( ).
" Get all the rows from the table for saving on to the database
loop at lt_elements into elem_sflight.
elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
append stru_sflight to it_flights.
endloop.
" Finally save the entries on to the database
modify ZSFLIGHT99 from table it_flights.
if sy-subrc eq 0.
endif.
However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
Regards,
Uday -
Insert multiple records into database through internal table
Hi
please help me how to insert multiple records into database through internal tableHi,
Welcome to SCN.
Press F1 on INSERT statement and you will teh syntax as well the docu for the same. -
Hi all,
In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'MacLochlainnsDB')
DROP DATABASE MacLochlainnsDB
GO
CREATE DATABASE MacLochlainnsDB
GO
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL)
INSERT INTO marvel
(avenger_name)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8)
I got the following error Message:
Msg 110, Level 15, State 1, Line 5
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
How can I correct this problem?
Please kindly help and advise.
Thanks in advance,
Scott Chang
P. S.
The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
DECLARE @x xml;
SET @x = N'<marvel>
<avenger_name>Captain America</avenger_name>
</marvel>';
SELECT @x.query('/*');
You can query the avenger_name elements from the marvel_xml table with the following syntax:
SELECT xml_table.query('/marvel/avenger_name')
FROM marvel_xml;
It returns the following set of avenger_name elements:
<avenger_name>Hulk</avenger_name>
<avenger_name>Iron Man</avenger_name>
<avenger_name>Black Widow</avenger_name>
<avenger_name>Thor</avenger_name>
<avenger_name>Captain America</avenger_name>
<avenger_name>Hawkeye</avenger_name>
<avenger_name>Winter Soldier</avenger_name>
<avenger_name>Iron Patriot</avenger_name>
You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
SELECT xml_table.query('/marvel[4]/avenger_name')
FROM marvel_xml;
It returns the following avenger_name element:
<avenger_name>Thor</avenger_name>Hi Scott,
The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
object within it.
To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
Open SQL Server Management Studio
--> Go to Object explorer(the left panel by default layout)
--> Extend "Security"
--> Extend "Logins"
--> Right click on your login, click "propertites"
--> Choose the "Default database" at the bottom of the pop-up window.
--or simply by T-SQL
Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
Regarding your question, you can reference the below.
SELECT * FROM master.sys.all_objects where name ='Marvel'
--OR
SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
--usually the OBJECT_ID is used if a if statement as below
IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
PRINT ('TABLE EXISTS') --Or some other logic
What is the sys.all_objects? See
here.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
How to insert varchar2 value in timestamp column in table?
Hi all,
Hope doing well,
sir i am using one stored procedure and storing time in varchar2 variable in this format: 08:00:00
now i have to insert this value in timestamp column in table. how to insert this value in timestamp column?
thanks952646 wrote:
Hi all,
Hope doing well,
sir i am using one stored procedure and storing time in varchar2 variable A "Very Bad Idea"(tm)
When you do this, there is no fundamental difference between "08:00:00" and "here's your sign".
Data should always be stored in the correct data type. For dates and times, that data type is either DATE or TIMESTAMP. Period.
in this format: 08:00:00
now i have to insert this value in timestamp column in table. how to insert this value in timestamp column?
Hopefully as remediation to the original bad design.
thanks
Maybe you are looking for
-
Making a java program on network
Hi, I am not an expert in java. So far all my small programs were for fun but now I am thinking of making a small CRM program to help my friend in his business. His office has two computers which are networked. So this small program which I am going
-
Hello, first the situation and then my question. I have to implement a search help exit on knttp. I know the search help and have implemented the exit. Know i need proccesing data in the exit of the purchase. For example: I start ME22N, then i push F
-
Bootcamp does not recognize windows 7 installer disc
I am trying to install windows 7 on my mac using Boot Camp. I have a bootable version of windows 7 that is NOT a branded version on a usb flash drive. No matter what I do when I hit install, I get the following error: The installer disc could not
-
My new Passport for Mac portable hard drive does not show up on the desktop. when connected to another computer the icon shows up on the desktop. When i first connected it it asked do you want to connect to time machine? I said "later"or "no" becau
-
Spaces allowed in role names for access credentials?
Are spaces allowed in role names for access credentials? We have a credential from our Leanring Management Sustem (Sakai) that is named "Project Owner." We would, most likely, need to url encode this name when we send a credential over http post or g