Monday, 10 April 2017

Node.js - The multi part could not be bound

I have an error (node:1152) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): RequestError: The multi-part identifier "SC1.refb" could not be bound.

In console log show all select but it seems that comes to the last and gives the error.

My code:

return Promise.all(parts.map(function(part) {
          console.log("SELECT sc.scstamp, st.u_posic, st.fornec, st.fornecedor, sc.ref, sc.qtt, sc.design FROM sc INNER JOIN st  ON st.ref = sc.ref WHERE sc.refb = '"+kitRef+"' AND st.u_posic = '"+part.u_order+"'"+
          "UNION SELECT SC2.scstamp, st.u_posic, st.fornec, st.fornecedor, SC2.ref, SC2.qtt, SC2.design FROM sc AS SC1"+
          "INNER JOIN sc SC2 ON SC2.refb = SC1.ref INNER JOIN st  ON st.ref = SC2.ref WHERE SC1.refb = '"+kitRef+"' AND st.u_posic = '"+part.u_order+"'");
            return request.query("SELECT [sc].[scstamp], [st].[u_posic], [st].[fornec], [st].[fornecedor], [sc].[ref], [sc].[qtt], [sc].[design] FROM sc INNER JOIN st  ON st.ref = sc.ref WHERE sc.refb = '"+kitRef+"' AND st.u_posic = '"+part.u_order+"'"+
            "UNION SELECT [SC2].[scstamp], [st].[u_posic], [st].[fornec], [st].[fornecedor], [SC2].[ref], [SC2].[qtt], [SC2].[design] FROM sc AS SC1"+
            "INNER JOIN sc SC2 ON SC2.refb = SC1.ref INNER JOIN st  ON st.ref = SC2.ref WHERE SC1.refb = '"+kitRef+"' AND st.u_posic = '"+part.u_order+"'")
            .then(function(articles) {

                return {part:part, articles:articles};
            });
        }));

The query is ok because if i put it in sql works well.

Thank you



via user3242861

No comments:

Post a Comment