![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Must be Sunday and I have a mental block. I'm trying to display some fields from a table and the result columns from a SP (which needs the ID from the main table). Something like this: Select p.ID, p.Name, t.Status, t.Status from Products p, spProductStatus(p.ID) t I have tried many different ways without result ... any ideas? BTW, I'm using 9.x |
#3
| |||
| |||
|
|
Is there an error message you're getting? Or just no data? -- Paul Horan[TeamSybase] Cynergy Systems www.cynergysystems.com "Jan K. van Dalen" <janATjanvandalen.com> wrote in message news:4454f675$1 (AT) forums-1-dub (DOT) .. Must be Sunday and I have a mental block. I'm trying to display some fields from a table and the result columns from a SP (which needs the ID from the main table). Something like this: Select p.ID, p.Name, t.Status, t.Status from Products p, spProductStatus(p.ID) t I have tried many different ways without result ... any ideas? BTW, I'm using 9.x |
#4
| |||
| |||
|
|
LATERAL "(" <table_expression> ")" |
|
Must be Sunday and I have a mental block. I'm trying to display some fields from a table and the result columns from a SP (which needs the ID from the main table). Something like this: Select p.ID, p.Name, t.Status, t.Status from Products p, spProductStatus(p.ID) t I have tried many different ways without result ... any ideas? BTW, I'm using 9.x |
#5
| |||
| |||
|
|
I cannot resist copying and pasting from Section 3.8 of my book, LATERAL Procedure Call, because it starts off with a *direct answer* to your question: ===== If a column from another table is passed as an argument to a procedure reference in a FROM clause, that procedure reference must appear as part of a LATERAL derived table definition. Also, the other table must appear ahead of the LATERAL derived table definition, and be separated from it by a comma rather than one of the join operators like INNER JOIN. This is a situation where the "comma join operator" must be used, and the ON condition cannot be used. Here is the general syntax for a LATERAL derived table: lateral_derived_table ::= LATERAL subquery [ AS ] <correlation_name [ <derived_column_name_list> ] | LATERAL "(" <table_expression> ")" [ AS ] <correlation_name [ <derived_column_name_list> ] Here is the simplified syntax for a join between a table and a procedure reference where a column from that table is passed as an argument; this is the only use of the comma join and the LATERAL keyword that is discussed in this book: typical_lateral_procedure_call ::= <table_name> "," LATERAL "(" <procedure_name "(" <table_name>.<column_name> ")" ")" AS <correlation_name ===== So, your query should look like this (caveat emptor: I have not tested this)... Select p.ID, p.Name, t.Status, t.Status from Products p, LATERAL ( spProductStatus(p.ID) ) t Breck On 30 Apr 2006 10:40:05 -0700, "Jan K. van Dalen" janATjanvandalen.com> wrote: Must be Sunday and I have a mental block. I'm trying to display some fields from a table and the result columns from a SP (which needs the ID from the main table). Something like this: Select p.ID, p.Name, t.Status, t.Status from Products p, spProductStatus(p.ID) t I have tried many different ways without result ... any ideas? BTW, I'm using 9.x -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
#6
| |||
| |||
|
|
Breck, that did it ... many thanks ... What Book? Link to Amazon? "Breck Carter [Team iAnywhere]" <NOSPAM__bcarter (AT) risingroad (DOT) com> wrote in message news:j55a52lph4am3nfs25mirr17b2ghqoopv9 (AT) 4ax (DOT) com... I cannot resist copying and pasting from Section 3.8 of my book, LATERAL Procedure Call, because it starts off with a *direct answer* to your question: ===== If a column from another table is passed as an argument to a procedure reference in a FROM clause, that procedure reference must appear as part of a LATERAL derived table definition. Also, the other table must appear ahead of the LATERAL derived table definition, and be separated from it by a comma rather than one of the join operators like INNER JOIN. This is a situation where the "comma join operator" must be used, and the ON condition cannot be used. Here is the general syntax for a LATERAL derived table: lateral_derived_table ::= LATERAL subquery [ AS ] <correlation_name [ <derived_column_name_list> ] | LATERAL "(" <table_expression> ")" [ AS ] <correlation_name [ <derived_column_name_list> ] Here is the simplified syntax for a join between a table and a procedure reference where a column from that table is passed as an argument; this is the only use of the comma join and the LATERAL keyword that is discussed in this book: typical_lateral_procedure_call ::= <table_name> "," LATERAL "(" <procedure_name "(" <table_name>.<column_name> ")" ")" AS <correlation_name ===== So, your query should look like this (caveat emptor: I have not tested this)... Select p.ID, p.Name, t.Status, t.Status from Products p, LATERAL ( spProductStatus(p.ID) ) t Breck On 30 Apr 2006 10:40:05 -0700, "Jan K. van Dalen" janATjanvandalen.com> wrote: Must be Sunday and I have a mental block. I'm trying to display some fields from a table and the result columns from a SP (which needs the ID from the main table). Something like this: Select p.ID, p.Name, t.Status, t.Status from Products p, spProductStatus(p.ID) t I have tried many different ways without result ... any ideas? BTW, I'm using 9.x -- Breck Carter [Team iAnywhere] RisingRoad SQL Anywhere and MobiLink Professional Services www.risingroad.com The book: http://www.risingroad.com/SQL_Anywhe...ers_Guide.html breck.carter (AT) risingroad (DOT) com |
![]() |
| Thread Tools | |
| Display Modes | |
| |