Hi, i have one problem with a query update for me more hard. the result of this select:

SELECT "DBA"."web_tracciato_prodotti_prestashop"."Riferimento ",
"DBA"."web_tracciato_prodotti_prestashop"."Caratteristica",
"DBA"."web_ktype_articoli"."ktype"
FROM ( "DBA"."web_tracciato_prodotti_prestashop" INNER JOIN "DBA"."web_articoli" ON "DBA"."web_tracciato_prodotti_prestashop"."ID" = "DBA"."web_articoli"."id" ) INNER JOIN "DBA"."web_ktype_articoli" ON "DBA"."web_articoli"."precodice" = "DBA"."web_ktype_articoli"."precodice" AND "DBA"."web_articoli"."articolo" = "DBA"."web_ktype_articoli"."articolo"

is correct. For each records of the web_tracciato_prodotti_prestashop table correspond n records of the web_ktype_articoli table because because to each web_tracciato_prodotti_prestashop.Riferimento correspond n records web_ktype_articoli.ktype. I have to update the web_tracciato_prodotti_prestashop.caratteristica field (initially null) with "Ktypes:" + value of web_ktype_articoli.ktype.

I'm a beginner and I've tried it but it doesn't work:

update dba.web_tracciato_prodotti_prestashop
If dba.web_tracciato_prodotti_prestashop.Caratteristica <>  Null
    then 
        set Caratteristica  = ", " & DBA.web_ktype_articoli.ktype
    else 
        set Caratteristica  = "KTypes: " & DBA.web_ktype_articoli.ktype 
end if
FROM ( "DBA"."web_tracciato_prodotti_prestashop" inner JOIN "DBA"."web_articoli" ON "DBA"."web_tracciato_prodotti_prestashop"."ID" = "DBA"."web_articoli"."id" ) inner JOIN "DBA"."web_ktype_articoli" ON "DBA"."web_articoli"."precodice" = "DBA"."web_ktype_articoli"."precodice" AND "DBA"."web_articoli"."articolo" = "DBA"."web_ktype_articoli"."articolo"

HELP ME PLEASE

asked 05 Jul, 10:48

pignatale's gravatar image

pignatale
111
accept rate: 0%

edited 08 Jul, 03:26

Volker%20Barth's gravatar image

Volker Barth
33.8k330486716


update 
    dba.web_tracciato_prodotti_prestashop 
    set Caratteristica = 
    (If dba.web_tracciato_prodotti_prestashop.Caratteristica is not  Null then

        ', ' + DBA.web_ktype_articoli.ktype 
    else 
        'KTypes: ' + DBA.web_ktype_articoli.ktype 
    end if) 
FROM 
    "DBA"."web_tracciato_prodotti_prestashop" 
inner JOIN "DBA"."web_articoli" ON "DBA"."web_tracciato_prodotti_prestashop"."ID" = "DBA"."web_articoli"."id"
inner JOIN "DBA"."web_ktype_articoli" ON "DBA"."web_articoli"."precodice" = "DBA"."web_ktype_articoli"."precodice" AND "DBA"."web_articoli"."articolo" = "DBA"."web_ktype_articoli"."articolo"

Please have a look if this is what you were needing. Table names were so hard to read so I have not checked the where condition just corrected the query.

permanent link

answered 06 Jul, 08:08

Dev's gravatar image

Dev
66113
accept rate: 50%

edited 08 Jul, 03:26

Volker%20Barth's gravatar image

Volker Barth
33.8k330486716

Good morning Thank you for your answer the syntax gives me an error SQLCODE 157 Cannot convert 'Ktypes:' to a numeric the Caratteristica field in sql is text I don't understand why it generates this error

(08 Jul, 02:49) pignatale
Replies hidden

You are using the arithmetic addition operator... Switch the + to || (string concatenation).

(08 Jul, 07:54) Mark Culp

wonderful it worked you are great thank you very much

(08 Jul, 11:37) pignatale
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×35
×3

question asked: 05 Jul, 10:48

question was seen: 95 times

last updated: 08 Jul, 16:18