I am trying to concatenate 2 columns from oracle apex to fill out one of the column. P3_ID contains text data like 09842 and P3_Type also contains data like 04214. I am trying to concatenate P3_ID +'.'+P3_Type (09842.04214) to put it into p3_total. So I add default value into P3_total to
select concat('P3_ID'+'.'+'P3_Type') from dual;
but It doesn't work for me. Does anyone have an idea to make p3_total to work?
Try
Assuming this is a computation assigned to P3, try
:P3_ID || '.' || :P3_Type
Docs here and here.
Related
My database has a table with columns genus, species, and inatcode. inatcode is blank for every row it hasn't been manually added to. I imported a new table that contains all the codes and want to create an Update query that copies them all to the corresponding rows of the first table. However, because the species column of my first table has additional strings, the match is not perfect and many rows were not updated. table.a.species might look like :
x bimundorum
vesicula (sexgen)
sinuata breviloba
And I want it to match these values in table.b.species:
bimundorum
vesicula
sinuata
I know to use table.a.species LIKE '%table.b.species%' when b is a substring of a, but this is the opposite case and just flipping (shown below) doesn't seem to work. Is there another way to accomplish this in SQLite? The differences between a and b are heterogeneous, but there are only a few cases and I could potentially do multiple queries to account for each.
"UPDATE table.a SET inatcode = table.b.inatcode
FROM table.b
WHERE table.b.genus = table.a.genus
AND table.a.species LIKE '%table.b.species%' "
I am working with SQLite through the DBI package in R, and could make all of this happen in R and reinsert instead. But it seems like this I should be able to do in SQLite.
The modified formatting posted here does what I wanted; I just needed to use the || to concatenate the values and the % operator to make the LIKE function behave as I wanted it to.
"UPDATE table.a SET inatcode = table.b.inatcode
FROM table.b
WHERE table.b.genus = table.a.genus
AND table.a.species LIKE '%' || table.b.species || '%'
AND table.b.species != '' "
Hello I am very new to Teradata Assistant. I wish to make a data dictionary of columns from views in Teradata. So far what I've been able to do is click on Tools > List Columns, then enter the database and view name. The output is what I am looking for. However there are hundreds and views, and this method seems tedious. Is there a way where I can collect the output of all the columns for all of the views?
That output from tools>>list columns looks like the output from HELP databasename.tablename.
You could write some sql to generate the HELP statements and then execute the output:
SELECT 'HELP ' || TRIM(databasename) || '.' || TRIM(tablename) FROM dbc.tablesv WHERE databasename = 'YOURDATABASE' AND tablekind = 'V';
use help column db.tb.*
using insignificance character for match 30 char limit
I have been looking all day for a solution that works for my situation. I have found some things that are very similar but don't work for my situation, I tried them.
Here is the scenario; I have two table base and partdetails. I have an asp website (internal ONLY) that has drop down lists to select the parameters for a SQL query that fills a data grid view.
My problem is this, I need to be able, based on the drop down list boxes on the page, assign the column name that the criteria that is entered to be searched for.
Here is the query that I am trying to define: (This one returns 0 rows)
sqlCmd.CommandText = ("Select ba.referenceid, ba.partnum, pd.width, pd.length, CONVERT(varchar(12), pd.dateentered, 101) As [dateentered], ba.partqty, ba.status, ba.material From tbl_dlbase ba Join tbl_partdetails pd On ba.referenceid = pd.referenceid Where Case #field1 When 'part #' Then 'ba.partnum' When 'Spacing' Then 'pd.spacing' When 'Surface' Then 'pd.surface' When 'Height' Then 'pd.height' When 'Thickness' Then 'pd.thickness' End Like '%' + #criteria1 + '%'")
sqlCmd.Parameters.AddWithValue("#field1", ddlSc1.SelectedItem.Text)
sqlCmd.Parameters.AddWithValue("#criteria1", txbCriteria1.Text)
This is the latest version of the SQL statement that I have tried. I need to be able to set the field/column name based on the selection from the drop down list ddlsc1 on the asp page.
I have also been trying the queries in Studio manager to see if maybe I have fat fingered something but it also returns 0 rows so I know something is wrong with the query.
So how can I set the column name field using a parameter for the name. I know this is a huge security concern with SQL injection but this is an internal only site, and more importantly my boss said he wants it done with variables.
I don't really see a problem with this other than you have single quotes around your THEN values. Does this fix it?
SELECT ba.referenceid
,ba.partnum
,pd.width
,pd.length
,CONVERT(VARCHAR(12), pd.dateentered, 101) AS [dateentered]
,ba.partqty
,ba.STATUS
,ba.material
FROM tbl_dlbase ba
JOIN tbl_partdetails pd ON ba.referenceid = pd.referenceid
WHERE CASE #field1
WHEN 'part #'
THEN ba.partnum
WHEN 'Spacing'
THEN pd.spacing
WHEN 'Surface'
THEN pd.surface
WHEN 'Height'
THEN pd.height
WHEN 'Thickness'
THEN pd.thickness
END LIKE '%' + #criteria1 + '%'
select (Civilimg1 + Civilimg2) as civilimagefull
from NewCus
but I get an error:
Msg 8117, Level 16, State 1, Line 2
Operand data type image is invalid for add operator.
How can I solve this problem?
As mentioned by Mark_S I dono what are you trying to do here by adding to image columns but still if you want to do then cast the image column as Binary then you can concatenate the two columns together. Try this.
select cast(Civilimg1 as varbinary(max))+cast(Civilimg2 as varbinary(max))
from NewCus
I need to select v_col1, from table_x and that column gives me string that i need to put(update) into same
rowid but into diffrent column(h_col2) in sama table table_x - sorry it seems easy but i am beginner....
tabl_x
rowid V_col1, h_col2 etc .....
1 672637263 GVRT1898
2 384738477 GVRT1876
3 263237863 GVRT1832
like in this example i need to put GVRT1898 (update) instead of 672637263 and i need to
go into every row in this table_x and fix -
like next line would be (rowid2 would be GVRT1876 instead of 384738477 :-)
this table has 40000 lines like this and i need to loop for every rowid
THX for your responce Justin - this is a little more complex,
i have this string in h_col and need to take only GVRTnumber out and put into v_col - but it's
hard becouse GVRTnumber is in various place in column see down here....
"E_ID"=X:"GVRT1878","RCode"=X:"156000","Month"=d:1,"Activate"=d:5,"Disp_Id"=X:"4673498","Tar"=X:"171758021";
2"E_ID"=X:"561001760","RCode"=X:"156000","Month"=d:1,"Activate"=d:5,"Disp_Id"=X:"GVRT1898","Tar"=X:"171758021";
h_col column have this number that i want but in various place like somethimes it's in this 600byte column it's in byte nr 156 - sometimes in 287 but the only unique is "GVRT...." how can i take that string and put it to v_col -
Can you show me how to write such SQL pl/sql ?
regards & thanks
It sounds like you just want
UPDATE tabl_x
SET h_col2 = v_col1
Of course, if you do something like this, that implies that one of the two columns should be dropped or the data model needs to get fixed. Having two copies of the same data in each row is a bad idea from a normalization standpoint if nothing else.